<?php
	require_once( $GLOBALS["site_root"] . "/includes/widgets/AdminAjaxTable.inc.php" );

	class AdminUserLogTable extends AdminAjaxTable {
		protected $iUserId = 0;
		protected $iHeight = 190;

		public function __construct( $id , $parent ) {
			parent::__construct( $id , $parent );
			$this->sTableName = "user_log";
			$this->sIdField = "user_log_id";
			$this->iPagesize = 100;
		}

		public function constructToolbarHeader() {}
		public function setHeight( $v ) { $this->iHeight = $v; }

		public function whereClause() {
			return sprintf( " where user_id=%d" , $this->iUserId );
		}

		public function limitClause() {
			return sprintf( " limit 25" );
		}

		public function orderClause() {
			return " order by user_log_id desc";
		}

		public function constructColumns() {
			$w = 525;
			$w_ctstamp = 120;$w-=$w_ctstamp;
			$w_ip = 100;$w-=$w_ip;
			$w_note = $w;

			$this->addColumn( "ctstamp" , __("log_Timestamp","attr") , false , array( "width" => $w_ctstamp ) );
			$this->addColumn( "user_log_ipaddress" , __("log_IPAddress","attr") , false , array( "width" => $w_ip ) );
			$this->addColumn( "user_log_note" , __("log_Note","attr") , false , array( "width" => $w_note ) );
		}

		public function constructField( $rownum , $row , $colname ) {
			$field = parent::constructField( $rownum , $row , $colname );
			$this->applyFieldColumnAttributes( $field , $this->aColumns[$colname] );

			$rd = $this->aData[$rownum];
			switch ($colname) {
			case "ctstamp":
				$field->setValue( fo3_format_tstamp_to_screen( $rd[$colname] ) );
				break;

			}
			return $field;
		}

		public function setUserId( $v ) { $this->iUserId = $v; }


		public function render() {
			if ($this->sRendered) return $this->sRendered;
			$this->setParam( "tbodyattrs" , sprintf( "style=\"height: %dpx;\"" , $this->iHeight ) );
			return parent::render();
		}
	}

?>
