#!/bin/sh  
# \
exec oagwish "$0" "$@"


set auto_path [linsert $auto_path 0  /usr/local/oag/apps/lib/$env(HOST_ARCH)]
set auto_path [linsert $auto_path 0 /usr/local/oag/lib_patch/$env(HOST_ARCH)]
APSDebugPath

set CVSRevisionAuthor "\$Revision: 1.2 $ \$Author: flood $"

set brief 0
set timeOnly 0
set args $argv
APSStrictParseArguments {brief timeOnly}
set status "Ready"
set width 22
if $timeOnly {
    set width 8
}

if $brief {
    APSStandardSetup
    wm title . wishClock
    frame .userFrame -width 200 -height 100
    pack .userFrame -side top -fill both -expand 1
    APSLabeledOutput .time -parent .userFrame \
            -label "" \
            -textVariable theTime -width $width
} else {
    APSApplication . -name notification -version $CVSRevisionAuthor 
   
APSScrolledStatus .dialog -parent .userFrame -textVariable status \
                          -height 2 -width 65 -packOption "-fill both -expand true"

}





proc UpdateClockOutput {} {
    global theTime timeOnly
    if !$timeOnly {
        set theTime [clock format [clock seconds] -format "%a %b %e %H:%M"]
    } else {
        set theTime [clock format [clock seconds] -format %T]
    }
    update
    after 500 UpdateClockOutput
}

UpdateClockOutput

frame .userFrame.holdmessage -borderwidth 3 -relief ridge -bg grey
   pack .userFrame.holdmessage -padx 10 -pady 6 -fill x

frame .userFrame.holdbuttons -borderwidth 3 -relief ridge -bg grey
   pack .userFrame.holdbuttons -padx 10 -pady 6 -fill x




set mailList [APSGetSDDSColumn -fileName  /home/phoebus/FLOOD/information -column start_mail]
set pvChange [APSGetSDDSColumn -fileName  /home/phoebus/FLOOD/information -column caput]
set end_mailList [APSGetSDDSColumn -fileName  /home/phoebus/FLOOD/information -column end_mail]



APSComboboxFrame .cbox -parent .userFrame -label "Select message " -width 50 \
      -packOption "-side top" -itemList \
      "$pvChange" \
      -textVariable update -maxWidth 1 \
      -callback mycallback \
       -contextHelp "Select a scenario to inform the users of"

APSButton .button -parent .userFrame  -text "Generate start e-mail" -command {sendmail a}
APSButton .button1 -parent .userFrame  -text "Generate end e-mail"  -command {send_mail a}

global update


proc sendmail {a} {
  
    global msg status
    APSScrolledStatus .newStatus -parent .userFrame -textVariable msg -withButtons 1 
    if [winfo exists .userFrame.status] {
            destroy .userFrame.status


} 
}

proc send_mail {a} {
    
    global message status
    APSScrolledStatus .status -parent .userFrame -textVariable message -withButtons 1 
     if [winfo exists .userFrame.newStatus] {
            destroy .userFrame.newStatus

}



}
proc mycallback {a} {
    global pvChange msg mailList message end_mailList pv 
    set msg [lindex $mailList $a]
    set update [lindex $pvChange $a]
    set message [lindex $end_mailList $a]
    set pv OPS:message4
    exec caput $pv $update


} 

