;;; modify-task.mhtml: -*- Meta-HTML -*- 

;;;  Copyright (c) 1996 Universal Access Inc.
;;;  Author: Henry Minsky (hqm@ua.com) Fri Sep  6 16:50:54 1996.

<set-var title="Create Rolodex Entry">
<include header.mhtml>
<include rolodex.mhtml>

<require-rolodex-login>

<h1>Create/Modify Rolodex Entry</h1>

<when <match <get-var posted::action> "Cancel">>
  <redirect welcome.mhtml>
</when>

<when <match <get-var posted::action> "(Create|Modify)">>
  
  ;;; We pass the *whole* POSTED package, as an alist,
  ;;; to the rolodex add-entry routine, which saves it
  ;;; into a row into the PEOPLE table in the MSQL database.
  
  ;;; Find the "last name" to use for sorts.
  <set-var posted::lastname = <subst-in-string <get-var name> "(.*) ([a-zA-Z]*)" "\\2">>

  <add-entry <package-to-alist posted>>
  <redirect "welcome.mhtml">
</when>

<when <match <get-var posted::action> "Delete">>
  <set-session-var entry-name=<get-var entry-name>>
  <redirect "confirm-delete.mhtml">>
</when>


;;; We got here from a "change" button, so load up
;;; all the relevant data, keyed off of the entry-name.
<when <match <get-var posted::action> "Change">>
  <load-entry <get-var entry-name>>
</when>

;;; Put up a text input field
<defsubst input-field var1 var2>
  <tr>
    <tr>
      <th align=left><get-var var1></th>
      <th align=left><get-var var2></th>
    </tr>

    <tr>
      <td>
	<input type=text size=24 name=<get-var var1> value="<get-var <get-var var1>>">
      </td>

      <td>
	<if <get-var var2>
	    <input type=text size=24 name=<get-var var2> value="<get-var <get-var var2>>">>
      </td>
    </tr>
</defsubst>

<defsubst create-entry>
  <form action="<get-var mhtml::current-doc>" method=post>
    <b>Name:</b> <input type=text name="entry-name" 
			value="<get-var entry-name>"
			size=48><br>
    <b>Created:</b> 
    <date <get-var creation-time>><br>
    
    <table>
      <input-field Street City>
      <input-field State Zip>
      <input-field Country "" >
      <input-field Email "">
      <input-field Dayphone Evephone>
      <input-field Fax "">

    </table>
    <b>Comments:</b><br>
    <textarea name=comments cols=48 rows=6><get-var comments></textarea>
    <br>

    <center>
      <if <and <not <match <get-var action> "Modify">>
	       <not <match <get-var action> "Change">>>
	  <input type=submit name=action value="Create">>
      <if <not <get-var new-entry>>
	  <input type=submit name=action value="Modify">>
      <input type=submit name=action value="Delete">
      <input type=submit name=action value="Cancel">
    </center>
  </form>
</defsubst>

<create-entry>

<include footer.mhtml>