<?php
  /**
   * Copyright 2011 Zazavi - http://www.zazavi.com
   * Zazavi is free software released under the terms of the GNU General Public License.
   * You should have received a copy of the license.  If not, see <http://www.gnu.org/licenses/>.
   */
  if (!defined("_VALID_PHP"))
      die('Direct access to this location is not allowed.');
	  
  if(!$user->getAcl("Logs")): print $core->msgAlert(_CG_ONLYADMIN, false); return; endif;
?>
<h1><img src="images/log-sml.png" alt="" /><?php echo _LG_TITLE1;?></h1>
<p class="info"><span><?php echo $core->langIcon();?></span><?php echo _LG_INFO1;?></p>
<h2><span><a href="javascript:void(0)" class=" delete button-alt-sml"><?php echo _LG_EMPTY;?></a></span><?php echo _LG_SUBTITLE1;?></h2>
<table cellpadding="0" cellspacing="0" class="display">
  <thead>
    <tr>
      <th class="left"><?php echo _LG_WHEN;?></th>
      <th class="left"><?php echo _LG_USER;?></th>
      <th class="left"><?php echo _LG_IP;?></th>
      <th class="left"><?php echo _LG_TYPE;?></th>
      <th class="left"><?php echo _LG_MESSAGE;?></th>
    </tr>
  </thead>
  <tbody>
    <?php foreach ($zazavisec->getLogs() as $row):?>
    <?php $message = cleanOut($row['message']);?>
    <tr>
      <td><?php echo $row['added'];?></td>
      <td><?php echo $row['user_id'];?></td>
      <td><?php echo $row['ip'];?></td>
      <td><?php echo $row['type'];?></td>
      <td><?php echo $message;?></td>
    </tr>
    <?php endforeach;?>
    <?php unset($row);?>
    <?php if($pager->items_total >= $pager->items_per_page):?>
    <tr style="background-color:transparent">
      <td colspan="5"><div style="float:left"><?php echo $pager->items_per_page();?> </div>
        <div style="float:right">
          <div class="pagination"><span class="inner"><?php echo $pager->display_pages();?></span></div>
        </div>
        <div class="clear"></div></td>
    </tr>
    <?php endif;?>
  </tbody>
</table>
<div id="dialog-confirm" style="display:none;" title="<?php echo _LG_EMPTY_LOGS;?>">
  <p><span class="ui-icon ui-icon-alert" style="float:left; margin:0 7px 20px 0;"></span><?php echo _DEL_CONFIRM;?></p>
</div>
<script type="text/javascript"> 
// <![CDATA[
$(document).ready(function () {
    $('a.delete').live('click', function () {
        $("#dialog-confirm").dialog('open');
        return false;
    });
    $("#dialog-confirm").dialog({
        resizable: false,
        bgiframe: true,
        autoOpen: false,
        width: 400,
        height: "auto",
        zindex: 9998,
        modal: false,
        buttons: {
            '<?php echo _DELETE;?>': function () {

                $.ajax({
                    type: 'post',
                    url: "ajax.php",
                    data: 'deleteLogs=1',
                    success: function (msg) {
						$("#msgholder").html(msg);
                    }
                });

                $(this).dialog('close');
            },
            '<?php echo _CANCEL;?>': function () {
                $(this).dialog('close');
            }
        }
    });
});
// ]]>
</script>