<?php
if ( ! defined( 'DATALIFEENGINE' ) ) {
    die( "Hacking attempt!" );
}

function showStatus( $statusId ) {
	$statusId = intval( $statusId );
    switch ( $statusId ) {
		case "0":
       		$status = "<font color=\"#FF8000\">Ожидается</font>";
        break;

		case "1":
            $status = "<font color=\"#0000FF\">Принято</font>";
		break;

		case "2":
			$status = "<font color=\"#FF0000\">Отклонено</font>";
		break;

		case "3":
			$status = "<font color=\"#008000\">Выполнено</font>";
		break;
	}
	return $status;
}

$toporders = $cache->open( "toporders", $config['skin'] );
if( ! $toporders ) {
	$db->query( "SELECT id, runame, enname, status FROM " . PREFIX . "_table ORDER BY date DESC LIMIT 0,10");
	
	while ( $row = $db->get_row() ) {
            if ( $row['runame'] ){ $name = $row['runame']; }
            elseif ( $row['enname'] ){ $name = $row['enname']; }

			if( strlen( $name ) > 15 ) $name = stripslashes( substr( $name, 0, 15 ) ) . "...";
				else $name = stripslashes( $name );

            $tblid = intval($row['id']);
			$status = showStatus( $row['status'] );

			$id = ++$i-3;

		$toporders .= "<a href=\"/orders/".$tblid."/\">" . $name . "</a><div style=\"float:right\">" . $status . "</div><br />";

	}
	$toporders .= "<hr><center><a href=\"/orders\">Стол заказов</a></center>";
	$db->free();
    $cache->save( "toporders", $toporders, $config['skin'] );
}
?>