// art_form - form for entering / updating info for one listing
//
// uses the shsql record locking facility for exclusive access..

#cgivar formmode id
#set TITLE = "Enter/edit a listing"
#include top

<center>

#if $sqlwritable() != 0
  <h2>Warning - database not writable... check project setup and configuration.</h2>
  #set formmode = new
#endif

//
// 
#if @formmode = new
  // new listing.. initialize blank fields..
  #sqlblankrow examp_art

#elseif @formmode = update
  // load the requested listing, using record locking for exclusive access
  #sql #load select * from examp_art where id = @id for update
  #set STAT = $sqlerror()
  #if @STAT != 0
    <h3>Record in use by someone else (code @STAT)</h3>
    #exit
  #endif
#endif


<a href="?rtn=art_cancel&id=@id">Cancel</a>
#if @formmode = update
  &nbsp; &nbsp; <a href="?rtn=art_details&id=@id" target=new>View entry</a>
#endif

<form action="@CGIPROG" method=GET>
#formtarget art_saver
#pass formmode, id


<table cellpadding=2 cellspacing=2 ><tr>

<tr bgcolor=FFFFFF align=left>
<td bgcolor=FFFFEC align=right><b>Artist</b><br>beginning with<br>last name</td>
<td><input name=artist size=30 maxlen=30 value="@artist">
<br><small>(use <tt>unknown</tt> if not known)</td></tr>

<tr bgcolor=FFFFFF align=left>
<td bgcolor=FFFFEC align=right><b>Title</b><br>of the work</td>
<td><input name=title size=60 maxlen=100 value="@title"></td></tr>

<tr bgcolor=FFFFFF align=left>
<td bgcolor=FFFFEC align=right><b>Format</b><br>of the work</td>
<td><select name=format size=1>
#optionlist selected=@format 
  #options
	oil	oil painting
	watercolor	watercolor painting
	acrylic	acrylic painting
	engraving	engraving
	penink	pen and ink
	woodcut	woodcut
	print	print
	mixedmedia	mixed media
	sculpture	sculpture
	other	other
</select></td></tr>


<tr bgcolor=FFFFFF align=left>
<td bgcolor=FFFFEC align=right><b>Year</b><br>that the work<br>was created</td>
<td><input name=year_created size=8 maxlen=80 value="@year_created">
<br><small>(use <tt>unknown</tt> if year is not known)
</td></tr>

<tr bgcolor=FFFFFF align=left>
<td bgcolor=FFFFEC align=right><b>Frame</b></td>
<td><input name=frame size=40 maxlen=80 value="@frame"></td></tr>

// double quote is stored as tilde to avoid quoting hassles.. note also single quotes used
// in the input tag..
#if @formmode = update
  #set size = $change( "~", '"', @size )
#endif
<tr bgcolor=FFFFFF align=left>
<td bgcolor=FFFFEC align=right><b>Dimensions</b><br>(inches, unframed)</b></td>
<td><input name=size size=40 maxlen=80 value='@size'></td></tr>

<tr bgcolor=FFFFFF align=left>
<td bgcolor=FFFFEC align=right><b>Image names</b></td>
<td>
1. <input name=img1 size=60 maxlen=120 value="@img1"><br>
2. <input name=img2 size=60 maxlen=120 value="@img2"><br>
3. <input name=img3 size=60 maxlen=120 value="@img3"><br>
<br><small>(leave blank if none)
</td></tr>

<tr bgcolor=FFFFFF align=left>
<td bgcolor=FFFFEC align=right><b>Longer description</b></td>
<td>
<textarea name=textdesc rows=4 cols=40>
#if @formmode = update
  #showtext examp_art/@id
#endif
</textarea>
</td></tr>

<tr bgcolor=FFFFFF align=left>
<td bgcolor=FFFFEC align=right><b>Est. current value (USD)</b></td>
<td>$<input name=current_value size=8 maxlen=80 value="@current_value"></td></tr>

<tr bgcolor=FFFFEC>
<td align=center colspan=2><input type=submit value="Save"> &nbsp;
<a href="@CGIPROG?rtn=art_cancel&id=@id">Cancel</a></td></tr>

</table>
</center>
</form>

<br>
<br>

