<actions>

<meta>
  <description>Template das PICA-System mit LBS zum Benutzerkontozugriff, üblicherweise von den GBV Bibliotheken verwendet</description>
  <variable name="server"><description>Serveraddresse, inklusive Protokoll und Parameter (z.B.: http://katalog.uni-hildesheim.de)  </description></variable>
  <variable name="picadb" default="1"><description>Datenbanknummer, wenn mehrere Datenbanken auf demselben Server liegen</description></variable>
  <variable name="borrower" default=""><description>Parameter in der URL für den Kontozugriff</description></variable>    
  <variable name="searchKeysOverride" default="tit;prs;isb;jah;slw"><description>Abkürzungen der Suchschlüssel bei Katalogsuchen</description></variable>
</meta>


<action id="connect">
  <s>loggedIn := false()</s>
</action>

<action id="internal-login">
  <if test="not($loggedIn)">
    <s>nextpage := $server||"/LBS_WEB/borrower/borrower.htm?"||uri-combine(x"USR={1000 + get('picadb', 0)}&BES={get('picadb', 1)}&LAN=DU", get("borrower", ""))</s>
    <page url="{$nextpage}">
      <template>
        <DIV id="main_wrapper">
          <FORM> 
            <input t:condition="@name=('username', 'j_username')" t:form-request="$username"/>
            <input t:condition="@name=('password', 'j_password')" t:form-request="$password"/>
          </form>
        </DIV>
      </template>
    </page>

    <page url="{$form-request}">
      <template>
        <t:switch prioritized="true">
          <FORM class="topbox">
            <DIV class="tabbar">
              <DIV class="navlink">
                <A><t:s>updateUrl := @href</t:s>Entleihungen</A> 
              </DIV>
              <DIV class="navlink">
                <A>{reservationsUrl := @href}</A> <!-- vormerkungen -->
              </DIV>
            </DIV>
          </FORM>
      
      
      	<h2><font color="red">{
          string() ! (if (matches(., "nummer und/oder.*Passwort.*(falsch|nicht korrekt)")) then vl:raise-login(.)
          else vl:raise(.))
          }</font></h2>
        </t:switch>
      </template>
    </page>

    <s>loggedIn := true()</s>
  </if>
</action>

<action id="update-all">
  <call action="internal-login"/>
  
  <!-- if the link is missing, it is "#", otherwise /LBS_WEB/borrower/loans.htm and /LBS_WEB/borrower/reservations.htm -->
  <s>vl:delete-current-books()</s>
  <page url="{if (string-length($updateUrl) > 3) then $updateUrl else ()}" templateFile="list"/>
  <page url="{if (string-length($reservationsUrl) > 3) then $reservationsUrl else ()}" templateFile="listOrders"/>
</action>

<action id="renew-list">  
  <s>renew := form-combine($renew-form, for $book in $renew-books return {"volumeNumbersToRenew": $book.renewId})</s>
  
  <page url="{$renew}"/>

  <call action="update-all"/>
</action>

<action id="cancel-list">  
  <s>cancel := form-combine($cancel-form, for $book in $cancel-books return {"volumeReservationsToCancel": $book.cancelId})</s>
  
  <page url="{$cancel}"/>

  <call action="update-all"/>
</action>


<action id="order-single">
  <page url="{$holding._orderId}"/>
  <if test="//input[@name='j_username']">
    <pattern><form name="borrowerForm"><input name="j_username"/>{nextpage := form(., ({"j_username": $username, "j_password": $password} ) )}</form></pattern>
    <page url="{$nextpage}"/>
  </if>
  <pattern><form>
    <input name="process"/> <!-- type="submit"-->
    {orderform := form(., .//input[@name="process"])}
  </form></pattern>
  <page url="{$orderform}"/>
  <!--   <span class="alertmessage"> Für den Benutzer TestKlute ist der Band 9941062409 vorgemerkt.</span> -->
</action>






<include href="../pica/searchTemplate"/>


</actions>
