<?php
	/*
	* Модуль почты для JohnCMS 3.2.2 v2.6
	* Copyright © 2010-2011 UPcoder.RU Group All Rights Reserved.
	* Coding by Krite 2010-2011
	*/
	defined('_IN_JOHNCMS') or die('Error: restricted access');
	$textl = 'Системные сообщения';
	$headmod = 'pochta';
	require_once('../incfiles/head.php');
	
	echo '<div class="phdr"><h3>Системные сообщения</h3></div>';
		$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `mail_msg` WHERE `id_kont`='" . $user_id . "' AND `sys`=2 AND `delete`!='" . $user_id . "'"), 0);
		if($total > 0) {
			$req = mysql_query("SELECT * FROM `mail_msg` WHERE `id_kont`='" . $user_id . "' AND `sys`=2 AND `delete`!='" . $user_id . "' ORDER BY `time` DESC LIMIT $start, $kmess");
			while($row = mysql_fetch_assoc($req)) {
				echo ($i % 2) ? '<div class="list2">':'<div class="list1">';
				if($row['read']==1)	{
					mysql_query("UPDATE `mail_msg` SET `read` = '2' WHERE `id`='" . $row['id'] . "' AND `id_kont` = '" . $user_id . "' AND `sys`='2' LIMIT 1");
				}
				echo '[' . date('d.m.o в H:i',$row['time']) . ']<br />';
				echo checkout($row['tema'],1,1) . '<br />';
				if($row['read']==1) echo 'Не прочитано!<br />';
				echo '<a href="'.$home.'/pochta/index.php?act=read&amp;id='.$row['id'].'">Читать</a> | <a href="'.$home.'/pochta/index.php?act=del&amp;id='.$row['id'].'">Удалить</a>';
				echo '</div>';
				++$i;
			}
			echo '<div class="phdr">Всего: ' . $total . '</div>';
			if ($total > $kmess) {
				echo '<div class="menu">' . pagenav($home.'/pochta/index.php?act=systems&amp;', $start, $total, $kmess);
				echo '<form action="" method="post"><p><input type="text" name="page" size="2"/><input type="submit" value="Перейти"/></p></form></div>';
			}
		}
		else {
			echo '<div class="rmenu">Системных сообщений нет!</div>';
		}
		echo '<div class="menu"><a href="'.$home.'/index.php?act=cab">Кабинет</a></div>';
?>