  <script type="text/javascript" src="calendar1.js"></script>

  <table border=1 cellspacing=1 cellpadding=2 width=760 style="border: 1px inset;">
  <form action="index.php?module=system&task=audit" method="post" name="filterform" id="filterform">
  <tr valign=top>
  <td valign=top width=200 class=listheader>User</td>
  <td valign=top width=280 class=listheader>Between</td>
  <td valign=top width=280 class=listheader>To</td>
  </tr>
  <tr valign=top>
  <td valign=top width=200 class=listcontent>
  <select name="userpkey" id="userpkey" style="width: 190px;">
  <? $objuserpkey=$filteruserpkey; ?>
  <? include_once('views/object-selectstaff.php'); ?>
  </select>
  </td>
  <td valign=top width=280 class=listcontent>
  <input name="startdate" type="text" id="startdate" value="<?=$filterstartdate;?>" size=12 maxlength=10 onkeypress="dateOnly();">
  <a href="javascript:cal1.popup();"><img src="images/icon/cal.gif" width="16" height="16" border="0" alt="Click to select date"></a>&nbsp;
  <input name="starttime" type="text" id="starttime" value="<?=$filterstarttime;?>" size=10 maxlength=5 onkeypress="timeOnly();">&nbsp;<i>(HH:mm)</i>
  </td>
  <td valign=top width=280 class=listcontent>
  <input name="stopdate" type="text" id="stopdate" value="<?=$filterstopdate;?>" size=12 maxlength=10 onkeypress="dateOnly();">
  <a href="javascript:cal2.popup();"><img src="images/icon/cal.gif" width="16" height="16" border="0" alt="Click to select date"></a>&nbsp;
  <input name="stoptime" type="text" id="stoptime" value="<?=$filterstoptime;?>" size=10 maxlength=5 onkeypress="timeOnly();">&nbsp;<i>(HH:mm)</i>
  </td>
  </tr> 
  <tr valign=top>
  <td valign=top width=760 colspan=3 class=listcontent><!-- style="text-align: right;">-->
  <input name="pageno" id="pageno" type="hidden" value="1">
  <button name="filter" id="filter" type="submit">&nbsp;<img src='gfx/options/b_find.png' class='actionbutton'>&nbsp;&nbsp;Search&nbsp;</button>&nbsp;
  <button name="showall" id="showall" onClick="unFilter();">&nbsp;<img src='gfx/options/b_clear.png' class='actionbutton'>&nbsp;&nbsp;Show All&nbsp;</button>&nbsp;
  </td>
  </tr> 
  </form>
  </table>

  <br>

  <table border=1 cellspacing=1 cellpadding=2 width=760 style="border: 1px inset;">
  <tr valign=top>
  <td valign=top width=30 class=listheader>No</td>
  <td valign=top width=150 class=listheader>Module</td>
  <td valign=top width=220 class=listheader>Action</td>
  <td valign=top width=120 class=listheader>User</td>
  <td valign=top width=160 class=listheader>Time</td>
  <td valign=top width=80 class=listheader>Options</td>
  </tr>

  <?
  $firstrec = (($pubpageno-1)*20)+1;
  $lastrec = $firstrec + 19;
  $pagecount = 1;

  include_once('models/systemModel.php');
  $mysystemModel=new systemModel;
  $audittrail_list = $mysystemModel->getlist_audittrail($filteruserpkey,$filterstartdate,$filterstarttime,$filterstopdate,$filterstoptime);
  ?>

  <? foreach ($audittrail_list as $myaudittrail) { ?>

    <? if (($myaudittrail['recordno']>=$firstrec)&&($myaudittrail['recordno']<=$lastrec)) { ?>

      <tr valign=top>
      <td valign=top width=30 class=listnumber><?=$myaudittrail['recordno'];?></td>
      <td valign=top width=150 class=listcontent><?=$myaudittrail['audit_module'];?></td>
      <td valign=top width=220 class=listcontent><?=$myaudittrail['audit_transaction'];?></td>
      <td valign=top width=120 class=listcontent><?=$myaudittrail['user_name'];?></td>
      <td valign=top width=160 class=listcontent><?=unconverttounixfull($myaudittrail['audit_datetime']);?></td>
      <td valign=top width=80 class=listcontent>
      <a href="index.php?module=system&task=auditview&itemid=<?=$myaudittrail['audit_pkey'];?>"><img src="gfx/options/b_view.png" border=0 alt="View"></a>
      </td>
      </tr>

    <? } ?>

  <? } ?>

  <?
  $pagecount = intval($myaudittrail['recordno']/20) + 1;
  ?>

  </table>
  <br>

  <?
  echo "<b>Page </b>";
  for ($i=1;$i<=$pagecount;$i++) {
    if ($i==$pubpageno) {
      echo "<u>".$i."</u>&nbsp;-&nbsp;";
    } else {
      //echo "<a href='index.php?module=system&task=audit&pageno=".$i."'>".$i."</a>&nbsp;-&nbsp;";
      echo "<span style='cursor: hand;' onClick='switchPage(".$i.");'><b>".$i."</b></span>&nbsp;-&nbsp;";
    }
    if (($i % 25)==0) echo "<br>";
  }
  ?>

  <script type="text/javascript">
    var cal1 = new calendar1(document.forms['filterform'].elements['startdate']);
    cal1.year_scroll = true;
    cal1.time_comp = false;
    var cal2 = new calendar1(document.forms['filterform'].elements['stopdate']);
    cal2.year_scroll = true;
    cal2.time_comp = false;
  </script>

  <script type="text/javascript">

  function unFilter() {
    document.filterform.userpkey.value=0;
    document.filterform.startdate.value="";
    document.filterform.stopdate.value="";
    document.filterform.starttime.value="";
    document.filterform.stoptime.value="";
    document.filterform.submit();
  }

  function switchPage(pageno) {
    document.filterform.pageno.value=pageno;
    document.filterform.submit();
  }

  </script>
