<?xml version="1.0"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->

<xsp:page xmlns:xsp="http://apache.org/xsp"
          xmlns:xsp-request="http://apache.org/xsp/request/2.0"
	  xmlns:esql="http://apache.org/cocoon/SQL/v2">
  <document>
    <header>
      <title>Search Results</title>
    </header>
    <body>
      <s1 title="Department Search Results">
        <p>
	  You can edit a department by clicking on the "edit"
	  button, and you can delete a department by clicking on
	  the "delete" button.
	</p>
	  <esql:connection>
	    <esql:pool>personnel</esql:pool>
	    <esql:execute-query>
	      <esql:query>
	        SELECT id, name FROM department
		WHERE name LIKE <esql:parameter>%<xsp-request:get-parameter name="name"/>%</esql:parameter>
		ORDER BY name
	      </esql:query>
	      <esql:results>
		<esql:row-results>
		  <s2>
		  <xsp:attribute name="title"><esql:get-string column="name"/></xsp:attribute>
		  <form handler="edit-dept.html">
		    <xsp:attribute name="name"><esql:get-string column="id"/></xsp:attribute>
		    <p>
		      <parameter name="id">
		        <xsp:attribute name="value"><esql:get-string column="id"/></xsp:attribute>
		      </parameter>
		      <submit name="Edit Department"/><submit name="Delete Department"/>
		    </p>
		  </form>
		  </s2>
		</esql:row-results>
	      </esql:results>
	        <esql:no-results>
		  <p>
		    We could find any departments that matched your search
		    criteria of "<xsp-request:get-parameter name="name"/>".
		    <link href="search-dept.html">Go back and try again?</link>
		  </p>
		</esql:no-results>
	    </esql:execute-query>
	  </esql:connection>
      </s1>
    </body>
  </document>
</xsp:page>
