<?xml version="1.0" encoding="UTF-8"?>
<t:switch prioritized="true">
<form>

{$mode := @name/string(),
 $form := form(., {"": {"kind": "submit"}}),
 switch ($mode) 
   case "vorml" return (
     $cancel-form := $form,
     if (@action[string()]) then ()
     else 
       $cancel-form.url := resolve-uri(
         if (contains(base-uri(), "/opac/")) then "vorml.C" 
         else "delreserv.C"
       )
   )
   case "medkl" return (
     $renew-form := $form,
     if (@action[string()]) then ()
     else 
       $renew-form.url := resolve-uri(
         if (contains(base-uri(), "/opac/")) then "verl.C" 
         else "renewmedia.C"
       )
   )
   default return vl:raise-internal("Unknown list: " || $mode)
}

<TABLE>
<tr><th><font/></th></tr>
<TR>
<t:siblings-header>
	<TH></TH>
	<th><img/></th>
	<th>Nr</th>
	<th>F&#228;llig</th>?
	<th>Mediennr</th>?
	<th>A</th>?
	<th>V</th>?
	<th>M</th>?
	<th><template:match-text regex="Signatur|Kurztitel|Kurzinformation"/></th>
	<th>Status</th>?
	
	<th>gültig ab</th>?
	<th>gültig bis</th>?
	<th><template:match-text regex="entliehen bis|ausgeliehen bis"/></th>?
	<th>Rang</th>?

	<th/>*
</t:siblings-header>
</TR>

<TR>
{book:={"status": ""}}
<t:siblings>
 <td/>
 <td><input type="checkbox">{$book._internalId := @name/string()}</input>?</td>
 <td/>
 <TD>{if (matches(., "[0-9]+")) then $book.duedate := parse-date(.) else () }</TD> 
 <td/>
 <td>{$book.libraryBranch := join((normalize-space(), .//@title), ", ")}</td>
 <TD>{$book.renewCount := normalize-space()}</TD>
 <TD>{$book.status := $book.status || (extract(., "[0-9]+")[.]!x"{.} Mahnungen") }</TD>
 <TD>{book.id := extract(., "^[^/]+"), 
      book.title := substring-after(., ":"),
      book.author := extract(., "/([^:]+)", 1),
      book._internalTitleId := extract(a/@href, "[0-9]+")
 }</TD>
 <TD>{$book.status := $book.status || .}</TD>
 
 
 <TD>{if (matches(., "[0-9]+")) then $book.issuedate := parse-date(.) else () }</TD> 
 <TD>{if (matches(., "[0-9]+")) then $book.duedate := parse-date(.) else () }</TD> 
 <TD>{$book.status := $book.status || " Entliehen bis: " || . }</TD>
 <TD>{$book.status := $book.status || " Rang: " || . }</TD>
 
 <td/>
</t:siblings>
{$book.statusId := if ($mode eq "vorml") then "ordered" 
                   else if (exists($book._internalId)) then "curious" 
                   else if (empty($book.duedate) and contains($book.status || td[last()], "abholbereit")) then (
                     (let $temp := extract($book.status || td[last()], "[0-9]+\.[0-9]+\.[0-9]+") where $temp 
                     return $book.dueDate := parse-date($temp))[0],
                     "provided" 
                   ) else "critical" }
</tr>+
</table>
 
</form>

<font>Kein Medium</font>
<font>Sie haben keine Medien</font>
<font>Nothing <!--reserved! also: No charges--></font>
<!--
<form name="errorl" >{vl:raise-login((../preceding::table)[1])}</form>


<html>
<title>Status</title>
<font color="red">{vl:raise(.)}</font>
</html>

<body>
  <div class="formTitle"></div>
  <t:element class="error">{vl:raise(.)}</t:element>
</body>
-->
</t:switch>
