'EMAIL   - called from ORD_STAT for entry/update of email address; sending e-mails

external _GEMS_EmailTo() _GEMS_Email() _GEMS_SetSWTitle() userid logintime _GEMS_Web()
external _GEMS_CheckList() _GEMS_Get_Choice() _GEMS_Input() _GEMS_ListBox()
external _GEMS_ResetCtrlParam() #GEMS_ctrl_fontsize _GEMS_GetName()
external #GEMS_Cancel messboxwait() _GEMS_Display_Message()
external _GEMS_MessageOn() _GEMS_ResetStdParam() #GEMS_fontsize #GEMS_fg #GEMS_bg
external #GEMS_Error _GEMS_MessageOff() _GEMS_WinDialog() $ownemail EnterEmail() $email

public $emailaddr

global $title $p_code $url $text $options #mode #sepchar x delpostcode
global $text1 $text2 $text3 $text4 $buttons $choice jobnr $temp


Main
$emailaddr=""
single-step on

' delpostcode=""
' delpostcode=[Del_Postcode]
' message "delpostcode is:"&str(delpostcode)
' $temp =_GEMS_Input("Here is an input box","Enter up to 20 chars","Start with this",20,"0","")
' delpostcode=_GEMS_Input("Delivery Postcode","Enter or update",trim(delpostcode),8,0,"")
'         if len(trim(delpostcode))=0
' 	        _GEMS_WinDialog("No delivery postcode yet entered","ERROR",16)
' 	  	delpostcode=_GEMS_Input("Delivery Postcode","Enter or update",delpostcode,8,0,"")
' 	end if
' _GEMS_WinDialog("No e-mail address yet entered","ERROR",16)
' x=_GEMS_Input("EMAIL ADDRESS","Enter or update","none",50,0,"")
' message "x) is:"&str(x)
' x=asc(";")
'  x=_GEMS_GetName(2)                            'message "x) is:"&str(x)
' jobnr=""
' jobnr="F17549"
' $emailaddr=[Email_Addr]        '
' $emailaddr="davidcooper@mr-carpet.co.uk"
$emailaddr=EnterEmail()
message "$email is:"&str($email)
message "$ownemail is:"&str($ownemail)

' x=_GEMS_Input("EMAIL ADDRESS","Enter or update",$emailaddr,50,0,"")
' message "$emailaddr) is:"&str($emailaddr)
' _GEMS_Email($emailaddr,$ownemail,"Test","testing copy to own email","")
_GEMS_Email($emailaddr,$ownemail,"Test","David%0A%0AI am just testing sending a copy to one's own email. Could you just text me if it arrives please?","")

' _GEMS_EmailTo($emailaddr)
'   _GEMS_SetSWTitle($title)

'==POSTCODE================================================================
' message "PostCode"
'   $p_code=[Postcode]               ' message "$p_code) is:"&str($p_code)
'   $p_code=replacestr($p_code," ","+")  'message "$p_code) is:"&str($p_code)
'   $url="www.streetmap.co.uk/streetmap.dll?postcode2map?"|$p_code|chr(32)
'   _GEMS_Web($url)
'==========================================================================

 	#GEMS_fontsize = 15
 	#GEMS_fg = 12
 	#GEMS_bg = 1
 	_GEMS_MessageOn("ERROR","No email address yet entered","","")
 	_GEMS_ResetStdParam()
 	IF #GEMS_Error = 0
 		WAIT 10
 		_GEMS_MessageOff()
 	END IF
MESSAGE "messageon"
'==CHECKLIST===============================================================
' message "Check List"
' $title="Window Caption - Check List"
' $text ="Check List text"
' $options="Customer details;Email;Map of site"
' #mode   =0
' #sepchar=59
' x=_GEMS_CheckList($title,$text,$options,#mode,#sepchar)
' message "x is:"&str(x)
'==========================================================================

  while true
'     z = 0
    $title="EMAIL"
    $text ="Click on selection and then click on OK"
    $options="Send email;Enter/Update addresses"
    #mode   =0
    #sepchar=59
    #GEMS_ctrl_fontsize=11
    $choice=_GEMS_ListBox($title,$text,$options,#mode,#sepchar)
' message "$choice is:"&str($choice)
' repaint on
' repaint
' single-step on
    if #GEMS_Cancel
message "Cancel pressed - exiting"
      _GEMS_ResetCtrlParam()
      exit while
    elseif len($choice)=0
message "no entry - try again"
    else
      if $choice = "1"
message "Send email"
message "$emailaddr is:"&str($emailaddr)
' repaint on
' repaint
' single-step on
        if len($emailaddr)=0 or $emailaddr=blank
'           _GEMS_Display_Message("No Email address entered yet","","")
  		#GEMS_fontsize = 15
  		#GEMS_fg = 12
		#GEMS_bg = 1
		_GEMS_MessageOn("ERROR","No email address yet entered","","")
		_GEMS_ResetStdParam()
		IF #GEMS_Error = 0
			WAIT 3
			_GEMS_MessageOff()
		END IF
repaint on
repaint
single-step on
        	$emailaddr=_GEMS_Input("EMAIL ADDRESS","Enter or update",$emailaddr,50,0,"")
        end if
        _GEMS_EmailTo($emailaddr)
      elseif $choice = "2"
message "Updateÿaddress"
        $emailaddr=_GEMS_Input("EMAIL ADDRESS","Enter or update",$emailaddr,50,0,"")
      end if
    end if
'     _GEMS_ResetCtrlParam()
' 1 = "ÿÿSendÿEmail"
' 2 = "Updateÿaddress"
message "$emailaddr is:"&str($emailaddr)
  end while




'==LIST BOX================================================================
' message "List Box"
while true
  $title="List Box"
  $text ="Click on selection and then click on OK"
  $options="Customer;Fittings;Instructions;Orders;Requisitions;Receipts;Emails;StreetMap;Comments"
  #mode   =0
  #sepchar=59
  #GEMS_ctrl_fontsize=11
  x=_GEMS_ListBox($title,$text,$options,#mode,#sepchar)
'   message "x is:"&str(x)
  if #GEMS_Cancel
message "Cancel pressed - exiting"
    exit while
  elseif len(x)=0
message "no entry - try again"
  else
message x
  end if
  _GEMS_ResetCtrlParam()
end while
'==========================================================================


'==GET CHOICE==============================================================
' message "Get Choice"
' $text1="Customer's details"
' $text2="Send Email"
' $text3="Enter/update email address"
' $text4="View Streetmap"
' $buttons ="Details Sendÿemail Emailÿaddress Streetmap"
'   _GEMS_Get_Choice($text1,$text2,$text3,$text4,$buttons,"")
' message "x is:"&str(x)
'==========================================================================

'==GEMS INPUT==============================================================
' message "Input"
' x=_GEMS_Input("Window title","Input title","",100,0,"")
' message "x) is:"&str(x)
'==========================================================================

END MAIN


' This URL displays the street map for the post code SW18 4EY
' http://www.streetmap.co.uk/streetmap.dll?postcode2map?sw18+4ey

' This URL displays the street map for the post code SW18 4EY, with the page title "We Are Here" :
' http://www.streetmap.co.uk/streetmap.dll?postcode2map?sw18+4ey&We+Are+Here

' This URL displays the street map for the post code SW18 4EY, with the page title "We Are Here", and a link back to us :
' http://www.streetmap.co.uk/streetmap.dll?postcode2map?sw18+4ey&We+Are+Here&Back+To+Us&http://www.streetmap.co.uk/howto.htm

' This URL displays the street map for the post code SW18 4EY, with the page title "We Are Here", and a link back to us, without showing the local sites:
' http://www.streetmap.co.uk/streetmap.dll?postcode2map?sw18+4ey&We+Are+Here&Back+To+Us&http://www.streetmap.co.uk/howto.htm&y

' This URL displays the street map for the post code SW18 4EY, with the page title "We Are Here", and a link back to us, without showing the local sites, using the image image6.gif as the background:
' http://www.streetmap.co.uk/streetmap.dll?postcode2map?sw18+4ey&We+Are+Here&Back+To+Us&http://www.streetmap.co.uk/howto.htm&y&background%3dimage6.gif

' This URL displays the street map for the post code SW18 4EY, with the page title "We Are Here", without a link back to us, without showing the local sites, using the image image6.gif as the background:

' Note that by naming the parameters, we can place them in any order and omit them where necessary.
' http://www.streetmap.co.uk/streetmap.dll?postcode2map?code=sw18+4ey&title=We+Are+Here&nolocal=y&bimage=background%3dimage6.gif

