<?xml version="1.0" encoding="UTF-8"?>
<actions max-version="1836" version-mismatch="skip">


<meta>
  <description>Template für das Libero-System, version 5.4</description>
  <variable name="baseurl"><description>Serveraddresse (inklusive Protokoll)</description></variable>
  <variable name="loginBaseurl" default=""><description>Serveraddresse für Kontozugriff(inklusive Protokoll)</description></variable>
</meta>

<action id="connect">
  <s>$baseurl := get("loginBaseurl", $baseurl),
     $update-page := ()</s>
</action>

<action id="internal-connect">
  <page url="{$baseurl}WebOpac.cls" templateFile="start"/>
  <page url="{$baseurl}WebOpac.cls?VERSION=2&amp;ACTION=MEMBERSERV&amp;RSN=0&amp;DATA={$data}&amp;TOKEN={$token}&amp;Z=1&amp;NewBreadCrumb=1&amp;{$loginToken}">
    <template><form><input name="usernum"/><t:s>update-page := form(., {"usernum": $username, "password": $password, "btnlogin": "LOGIN"})</t:s></form></template>
  </page>
</action>

<action id="update-all">
  <if test="not($update-page)"><call action="internal-connect"/></if>
  <s>$new-update-page := (), $session-lost := false()</s>
  <page url="{$update-page}" templateFile="update"/>  
  <s>$update-page := $new-update-page</s> <!-- Pattern assigns to $new-update-page instead $update-page as some libraries might not have that link. todo: check all libs, and remove $new-update-page if possible-->
  <if test="$session-lost">
    <call action="internal-connect"/>
    <page url="{$update-page}" templateFile="update"/>
  </if>
</action>

<action id="renew-list">
  <s>$update-page := (),
     $book-list := string-join(for $book in $renew-books return x"{$book.extendid}=1", "&amp;")
  </s>
  <page url="{$baseurl}WebOpac.cls">
    <post name="MGWCHD" value="0"/>
    <post name="TOKEN" value="{$token}"/>
    <post name="TOKENX" value="{$tokenx}"/>
    <post name="DATA" value="{$data}"/>
    <post name="usercode" value=""/>
    <post name="VERSION" value="{$version}"/>
    <post name="ACTION" value="MEMSLFISS"/>
    <post name="bno" value="{$username}"/>
    <post name="mid" value="{$mid}"/>
    <post value="{$book-list}"/>
<!--    <post name="SubmitIssued" value="Senden"/>-->
    <template><body><a t:condition="contains(@href, 'MEMSTAT')">{$update-page := @href}</a>?</body></template>
  </page>
  <call action="update-all"/>
</action>

<action id="cancel-list">
  <s>$update-page := (), 
     $book-list := string-join(for $book in $cancel-books return $book.cancelId, "&amp;"),
     $f := $cancelForm, 
     $f.post := concat($f.post, "&amp;", $book-list)
   </s>
  <page url="{$f}">
  <template>
    <b>Löschen der Benutzervormerkung wird bearbeitet</b>
    <b>Transaktion verarbeitet</b>
  </template>
  </page>
</action>

<action id="search-connect">
  <s>$search-branch-values := (), $search-branch-id := 0</s>,
  <page url="{$baseurl}WebOpac.cls">
  <template>
    <t:switch-prioritized>
      <a t:condition="contains(@href, 'WebOpac.cls')">Erweiterte Suche<t:s>search:=@href</t:s></a>
      <title>LIBERO WebOPAC Erweiterte Suche<t:s>search:=$url</t:s></title>
      <font>Server ist zurzeit nicht verfügbar<t:s>vl:raise(.)</t:s></font>
    </t:switch-prioritized>
  </template> <!-- condition is for dresden which has a link "erweiterte suche in der Hilfe" -->
  </page>

  <variable name="search-keys">{"author": "kb", "title": "k", "keywords": "kj", "isbn": "i"}</variable>

  <page url="{$search}">
  <template><form>
    {search-form := form(., .//input[@type="submit"]), keyword-key := ""}
    
    <option>Schlagwörter<t:s>search-keys.keywords := @value</t:s></option>?
    <option>Schlagwort<t:s>search-keys.keywords := @value</t:s></option>?
    
    <select name='LIMLOC' t:optional="true">
    {search-branches := option, search-branch-values := option/@value}
    </select>?
  </form></template>
  </page>
</action>


<action id="search">  
  <s>
     i := 1, 
     f := $search-form,
     f.post := uri-combine($f.post, (
       if (boolean($book.year)) then 
         if (contains($book.year, "-")) then 
           {"YEARFROM": normalize-space(substring-before($book.year, "-")), "YEARTO": normalize-space(substring-after($book.year, "-"))} 
         else 
           {"YEARFROM": $book.year, "YEARTO": $book.year} 
       else (),
       if ($search-branch-values[$search-branch-id]) then {"LIMLOC": $search-branch-values[$search-branch-id]} else (),
       for $key in jn:keys($book) return if (boolean($book($key)) and exists($search-keys($key))) then (
         {x"TERM_{$i}": $book($key), x"USE_{$i}": $search-keys($key)},
         (i := $i + 1)[2]
       ) else ()
    )
     )
  </s>
  <page url="{$f}" templateFile="searchList"/>
  
</action>

<action id="search-next-page">
  <page url="{$next-page}" templateFile="searchList"/>
</action>

<action id="search-details">
  <page url="{$book._detail-url}" templateFile="searchDetails"/>
</action>

<action id="order-confirm-single"> 
  <s>$order := if ($book._order-url) then $book._order-url
               else if ($book._order-id and get("order-form")) then
                 request-combine(get("order-form"), {$book._order-id: 1})
               else ()
   </s>
  <page url="{$order}">
    <template><form>{f := form(., {"usernum": $username, "password": $password})}</form></template>
  </page>
  <page url="{$f}">  
    <template>
     <t:switch>
      <form>
        {issuePoints := (), confirm := form(.)}
        <select t:condition="@name=('BRANCH','PICKUPBR')">
          {order-branch-name := @name,
           book.orderConfirmationOptionTitles := option, 
           issuePoints := $book.orderConfirmationOptionTitles/@value}
        </select>
        
        {if (count($issuePoints) > 1 ) then book.orderConfirmation := "Wohin soll das Buch vorbestellt werden?"
         else book.orderConfirmation := ""
        }
      </form>
      <ul class='SysMsgList'>
        <b>Die Transaktion wurde abgelehnt</b>
        <t:s>vl:raise(.)</t:s>
      </ul>
    </t:switch></template>   
  </page>
</action>


<action id="order-single"> 
  <if test="boolean($book.orderConfirmation)">
    <s>confirm.post := uri-combine($confirm.post, {$order-branch-name: $issuePoints[$book.choosenConfirmation*1]})</s>
  </if>
  <page url="{$confirm}">
  <template><t:switch>    
    <b>Ihre Vormerkung wurde vorgenommen</b>
    <div>Ihre Vormerkung wurde vorgenommen</div>
    <ul class="SysMsgList">
      <b>Für diesen Titel konnte keine Vormerkung eingetragen werden</b>
      <t:s>vl:raise(.)</t:s>
    </ul>    
  </t:switch></template>
  </page>
</action>


<action id="catalogue">
  <variable name="url" value="{$baseurl}WebOpac.cls"/>
</action>


</actions>
