<?php
  global $FORM, $TABLE_PREFIX;
  require_once "lib/menus/default/list_functions.php";

  //
  showHeader();
?>

<form method="get" name="preview" action="<?php echo @$schema['_listPage'] ?>" target="_blank">
</form>

<form method="get" action="<?php echo $_SERVER['PHP_SELF'] ?>" autocomplete="off">
<input type="submit" style="width: 0px; height: 0px; position: absolute; border: none" /> <!-- bugfix: hitting enter in textfield submits first submit button on form -->
<input type="hidden" name="menu" id="menu" value="<?php echo htmlspecialchars($menu) ?>" />
<input type="hidden" name="_defaultAction" value="list" />
<input type="hidden" name="page" value="<?php echo $listDetails['page'] ?>" />

<table border="0" cellspacing="0" cellpadding="0" width="690">
 <tr>
  <td class="title">
   <?php if ($GLOBALS['isAdminMenu']): ?>
     <a href="?menu=admin&amp;action=home">Admin</a> &gt;
   <?php endif ?>
   <a href="?menu=<?php echo $menu ?>" ><?php echo $schema['menuName'] ?></a>
  </td>
  <td align="right">

   <?php if (!@$schema['_disableAdd']): ?>
     <input type="submit" name="action=add" value="<?php _e('Create') ?>" class="inputButton" />
   <?php endif ?>

   <?php if (@$schema['_listPage']): ?>
     <input type="button" name="" value="<?php _e('Preview') ?>" class="inputButton" onclick="document.forms.preview.submit();"/>
   <?php endif ?>

  </td>
 </tr>
</table>

<div class="divider_line"></div>

<!-- search and results bar -->
<table border="0" cellspacing="0" cellpadding="0" width="690">
 <tr>
  <td>

   <table border="0" cellspacing="0" cellpadding="0">
    <tr>
     <td><?php _e('Search for keyword') ?></td>
     <td><?php _e('perPage') ?></td>
     <td>&nbsp;</td>
    </tr>
    <tr>
     <td><input type="text" name="keyword" value="<?php echo htmlspecialchars(@$listDetails['keyword']) ?>" size="25" />&nbsp;</td>
     <td>
       <select name="perPage">
       <option <?php selectedIf($listDetails['perPage'], '5')?>>5</option>
       <option <?php selectedIf($listDetails['perPage'], '10')?>>10</option>
       <option <?php selectedIf($listDetails['perPage'], '25')?>>25</option>
       <option <?php selectedIf($listDetails['perPage'], '50')?>>50</option>
       <option <?php selectedIf($listDetails['perPage'], '100')?>>100</option>
       </select>&nbsp;
      </td>
     <td>
      <input type="submit" name="search"      value="<?php _e('Search') ?>" class="inputButton" />
      <input type="submit" name="resetSearch" value="<?php _e('Reset') ?>" class="inputButton" /><br />
     </td>
    </tr>
   </table>

  </td>
  <td align="right">
   <table border="0" cellspacing="0" cellpadding="1">
    <tr>
     <td class="lSearchText" align="center">
      <?php if (@$listDetails['keyword'] == ''): ?>
        <?php printf(__('Total Records: %s'), $listDetails['totalRecords']) ?>
      <?php else: ?>
        <?php printf(__('Matched: %s of %s'), $listDetails['totalMatches'], $listDetails['totalRecords']) ?>
      <?php endif ?>
     </td>
    </tr>
    <tr>
     <td align="center"  class="lSearchText">
     <?php
       // This field is renamed to "page" when changed by user
       $pageNumFieldHTML = "<input type='text' size='4' class='lSearchBox' name='unused' value='{$listDetails['page']}' onchange='this.name=\"page\";' />";
       printf(__('Page %s of %s'), $pageNumFieldHTML, $listDetails['totalPages']);
     ?>

     </td>
    </tr>
    <tr><td class="lSearchText noBreak" align="center">
     <a href="?menu=<?php echo htmlspecialchars($menu) ?>&amp;action=list&amp;page=<?php echo $listDetails['prevPage']?>&amp;perPage=<?php echo $listDetails['perPage']?>&amp;keyword=<?php echo urlencode(@$listDetails['keyword']) ?>"><?php _e('&lt;&lt; Prev Page') ?></a> |
     <a href="?menu=<?php echo htmlspecialchars($menu) ?>&amp;action=list&amp;page=<?php echo $listDetails['nextPage']?>&amp;perPage=<?php echo $listDetails['perPage']?>&amp;keyword=<?php echo urlencode(@$listDetails['keyword']) ?>"><?php _e('Next Page &gt;&gt;') ?></a><br />
    </td></tr>
   </table>

  </td>
 </tr>
</table>

<div class="divider_line"></div>

<!-- list column headings -->
<table border="0" cellspacing="1" cellpadding="0" width="690" id="listTable">
 <tr class="nodrag nodrop">
 <?php displayColumnHeaders($listFields); ?>
 </tr>

<?php displayListRows($listFields, $listRecords); ?>

<?php if (count($listRecords) == 0): ?>
  <tr>
   <td class="listRowOdd" colspan="<?php print count($listFields) + 2 ?>">
   <?php if (@$listDetails['keyword'] == ''): ?>  <?php _e('Sorry, no records were found!') ?>  <?php endif ?>
   <?php if (@$listDetails['keyword'] != ''): ?>  <?php _e('Sorry, the <b>search</b> returned no results!') ?> <?php endif ?>
   </td>
  </tr>
<?php endif ?>

</table>

<div class="divider_line"></div>

<table border="0" cellspacing="0" cellpadding="0" width="690">
 <tr>
  <td align="left">
  </td>
  <td align="right">
   <?php if (!@$schema['_disableAdd']): ?>
     <input type="submit" name="action=add"  value="<?php _e('Create') ?>" class="inputButton" />
   <?php endif ?>

   <?php if (@$schema['_listPage']): ?>
     <input type="button" name="" value="<?php _e('Preview') ?>" class="inputButton" onclick="document.forms.preview.submit();"/>
   <?php endif ?>
  </td>
 </tr>
</table>

</form>

<script type="text/javascript"><!-- // language strings
  lang_confirm_erase_record = '<?php echo addslashes(__("Delete this record? Are you sure?")) ?>';
//--></script>
<script type="text/javascript" src="lib/jquery1.2.js"></script>
<script type="text/javascript" src="lib/jquery.tablednd.js"></script>
<script type="text/javascript" src="lib/menus/default/list_functions.js"></script>

<?php showFooter(); ?>
