소스 검색

Msgs: remove msg

Piotr Labudda 10 년 전
부모
커밋
5ce5fba4f1
2개의 변경된 파일168개의 추가작업 그리고 90개의 파일을 삭제
  1. 2 57
      SE/se-lib/Route/Msgs.php
  2. 166 33
      SE/se-lib/Route/TableMsgs.php

+ 2 - 57
SE/se-lib/Route/Msgs.php

@@ -242,6 +242,8 @@ SQL_QUERY;
 				, `A_RECORD_CREATE_AUTHOR` varchar(40) NOT NULL DEFAULT ''
 				, `A_RECORD_CREATE_AUTHOR` varchar(40) NOT NULL DEFAULT ''
 				, `A_RECORD_UPDATE_DATE` datetime DEFAULT NULL
 				, `A_RECORD_UPDATE_DATE` datetime DEFAULT NULL
 				, `A_RECORD_UPDATE_AUTHOR` varchar(40) NOT NULL DEFAULT ''
 				, `A_RECORD_UPDATE_AUTHOR` varchar(40) NOT NULL DEFAULT ''
+				, `A_RECORD_DELETE_DATE` datetime DEFAULT NULL
+				, `A_RECORD_DELETE_AUTHOR` varchar(40) NOT NULL DEFAULT ''
 				, PRIMARY KEY (`ID`)
 				, PRIMARY KEY (`ID`)
 				, KEY `app_className` (`app_className`)
 				, KEY `app_className` (`app_className`)
 			) ENGINE=MyISAM DEFAULT CHARSET=latin2
 			) ENGINE=MyISAM DEFAULT CHARSET=latin2
@@ -318,63 +320,6 @@ SQL_QUERY;
 		return $msgs;
 		return $msgs;
 	}
 	}
 
 
-	public function getMessagesForTableRecord($tblName, $id) {
-		$msgs = array();
-		if (empty($tblName)) return $msgs;
-		$db = DB::getDB();
-		$tblName = $db->_($tblName);
-
-		$usrLogin = User::getLogin();
-		$sql = "select m.*
-			from `CRM_UI_MSGS` m
-			where m.`uiTargetType`='default_db_table_record'
-				and m.`uiTargetName`='{$tblName}.{$id}'
-				and (m.`userTargetType` in('everyone')
-					or (m.`userTargetType`='user' and m.`userTargetName`='{$usrLogin}')
-					-- TODO: use group id
-				)
-				and m.`A_STATUS` not in('DELETED')
-			order by m.`ID` DESC
-		";
-		$db = DB::getDB();
-		$res = $db->query($sql);
-		while ($r = $db->fetch($res)) {
-			if ($msg = $this->parseMessage($r)) {
-				$msg['link'] = 'index.php?_route=Msgs&_task=run&_msgId=' . $r->ID;
-				$msg['linkType'] = 'ajax';
-				$msgs[$r->ID] = $msg;
-			}
-		}
-		return $msgs;
-	}
-
-	public function getSentMessagesForTableRecord($tblName, $id) {
-		$msgs = array();
-		if (empty($tblName)) return $msgs;
-		$db = DB::getDB();
-		$tblName = $db->_($tblName);
-
-		$usrLogin = User::getLogin();
-		$sql = "select m.*
-			from `CRM_UI_MSGS` m
-			where m.`uiTargetType`='default_db_table_record'
-				and m.`uiTargetName`='{$tblName}.{$id}'
-				and m.`A_RECORD_CREATE_AUTHOR`='{$usrLogin}'
-				and m.`A_STATUS` not in('DELETED')
-			order by m.`ID` DESC
-		";
-		$db = DB::getDB();
-		$res = $db->query($sql);
-		while ($r = $db->fetch($res)) {
-			if ($msg = $this->parseMessage($r)) {
-				$msg['link'] = 'index.php?_route=Msgs&_task=run&_msgId=' . $r->ID;
-				$msg['linkType'] = 'ajax';
-				$msgs[$r->ID] = $msg;
-			}
-		}
-		return $msgs;
-	}
-
 	public function parseMessage($r) {
 	public function parseMessage($r) {
 		$msg = null;// ['type'=>'info', 'message'=>'...']
 		$msg = null;// ['type'=>'info', 'message'=>'...']
 		// $r->app_className - for automatic msgs to search for msg text
 		// $r->app_className - for automatic msgs to search for msg text

+ 166 - 33
SE/se-lib/Route/TableMsgs.php

@@ -3,7 +3,6 @@
 Lib::loadClass('Router');
 Lib::loadClass('Router');
 Lib::loadClass('RouteBase');
 Lib::loadClass('RouteBase');
 Lib::loadClass('TypespecialVariable');
 Lib::loadClass('TypespecialVariable');
-Lib::loadClass('ProcesHelper');
 
 
 class Route_TableMsgs extends RouteBase {
 class Route_TableMsgs extends RouteBase {
 
 
@@ -67,7 +66,7 @@ class Route_TableMsgs extends RouteBase {
 				$arrorsList[] = $e->getMessage();
 				$arrorsList[] = $e->getMessage();
 			}
 			}
 		}
 		}
-		$msgsList = $this->_getMsgs($tableName, $idRow);
+		$msgsList = $this->_getMsgs('inbox', $tableName, $idRow);
 		$totalReadMsgs = 0;
 		$totalReadMsgs = 0;
 		$totalUnreadMsgs = 0;
 		$totalUnreadMsgs = 0;
 		foreach ($msgsList as $ind => $msg) {
 		foreach ($msgsList as $ind => $msg) {
@@ -77,7 +76,8 @@ class Route_TableMsgs extends RouteBase {
 				$totalUnreadMsgs++;
 				$totalUnreadMsgs++;
 			}
 			}
 		}
 		}
-		$sentMsgsList = $this->_getSentMsgs($tableName, $idRow);
+		$sentMsgsList = $this->_getMsgs('sent', $tableName, $idRow);
+		$removedMsgsList = $this->_getMsgs('removed', $tableName, $idRow);
 		?>
 		?>
 <style type="text/css">
 <style type="text/css">
 .tblMsgsListItem { cursor:pointer; }
 .tblMsgsListItem { cursor:pointer; }
@@ -97,13 +97,17 @@ class Route_TableMsgs extends RouteBase {
 			</li>
 			</li>
 			<li role="presentation" class="active"><a href="#odebrane" aria-controls="odebrane" role="tab" data-toggle="tab">Odebrane <em>(<?php echo $totalUnreadMsgs; ?>)</em></a></li>
 			<li role="presentation" class="active"><a href="#odebrane" aria-controls="odebrane" role="tab" data-toggle="tab">Odebrane <em>(<?php echo $totalUnreadMsgs; ?>)</em></a></li>
 			<li role="presentation"><a href="#wyslane" aria-controls="wyslane" role="tab" data-toggle="tab">Wysłane</em></a></li>
 			<li role="presentation"><a href="#wyslane" aria-controls="wyslane" role="tab" data-toggle="tab">Wysłane</em></a></li>
+			<li role="presentation"><a href="#kosz" aria-controls="kosz" role="tab" data-toggle="tab">Kosz</em></a></li>
 		</ul>
 		</ul>
 		<div class="tab-content" style="margin-bottom:15px">
 		<div class="tab-content" style="margin-bottom:15px">
 			<div role="tabpanel" class="tab-pane active" id="odebrane" style="border-style:none solid solid solid; border-width:1px; border-color:#ddd;">
 			<div role="tabpanel" class="tab-pane active" id="odebrane" style="border-style:none solid solid solid; border-width:1px; border-color:#ddd;">
-				<?php $this->_printTableMsgsList($msgsList, 'read'); ?>
+				<?php $this->_printTableMsgsList($msgsList, $idTable, $idRow, 'read'); ?>
 			</div>
 			</div>
 			<div role="tabpanel" class="tab-pane" id="wyslane" style="border-style:none solid solid solid; border-width:1px; border-color:#ddd;">
 			<div role="tabpanel" class="tab-pane" id="wyslane" style="border-style:none solid solid solid; border-width:1px; border-color:#ddd;">
-				<?php $this->_printTableMsgsList($sentMsgsList, 'view'); ?>
+				<?php $this->_printTableMsgsList($sentMsgsList, $idTable, $idRow, 'view'); ?>
+			</div>
+			<div role="tabpanel" class="tab-pane" id="kosz" style="border-style:none solid solid solid; border-width:1px; border-color:#ddd;">
+				<?php $this->_printTableMsgsList($removedMsgsList, $idTable, $idRow, 'view'); ?>
 			</div>
 			</div>
 		</div>
 		</div>
 	</div>
 	</div>
@@ -128,7 +132,7 @@ class Route_TableMsgs extends RouteBase {
 		//throw new Exception("TODO: ...");
 		//throw new Exception("TODO: ...");
 	}
 	}
 
 
-	public function _printTableMsgsList($msgsList, $actionTask = null) {
+	public function _printTableMsgsList($msgsList, $idTable, $idRow, $actionTask = null) {
 		$msgsTotal = count($msgsList);
 		$msgsTotal = count($msgsList);
 		?>
 		?>
 	<table class="tblMsgsList table table-hovered" style="margin-bottom:0; table-layout:fixed;">
 	<table class="tblMsgsList table table-hovered" style="margin-bottom:0; table-layout:fixed;">
@@ -139,6 +143,13 @@ class Route_TableMsgs extends RouteBase {
 				<th style="width:130px">data</th>
 				<th style="width:130px">data</th>
 			</tr>
 			</tr>
 		</thead>
 		</thead>
+		<tfoot>
+			<?php if ($msgsTotal > 20) : ?>
+				<tr>
+					<td colspan="3"><em class="text-muted" style="padding-left:60px;">...</em></td>
+				</tr>
+			<?php endif; ?>
+		</tfoot>
 		<tbody>
 		<tbody>
 			<?php if ($msgsTotal <= 0) : ?>
 			<?php if ($msgsTotal <= 0) : ?>
 				<tr>
 				<tr>
@@ -149,6 +160,7 @@ class Route_TableMsgs extends RouteBase {
 					<?php
 					<?php
 						$onClick = '';
 						$onClick = '';
 						$msgLink = Request::getPathUri() . 'index.php?_route=TableMsgs&id=' . $msg['_raw']->ID;
 						$msgLink = Request::getPathUri() . 'index.php?_route=TableMsgs&id=' . $msg['_raw']->ID;
+						$msgLink .= "&idTable={$idTable}&idRow={$idRow}";
 						if ('read' == $actionTask || 'view' == $actionTask) {
 						if ('read' == $actionTask || 'view' == $actionTask) {
 							$msgLink .= '&_task=' . $actionTask;
 							$msgLink .= '&_task=' . $actionTask;
 						} else {
 						} else {
@@ -176,7 +188,12 @@ class Route_TableMsgs extends RouteBase {
 								?>
 								?>
 							</div>
 							</div>
 						</td>
 						</td>
-						<td style="white-space:nowrap;"><?php echo $msg['_raw']->A_RECORD_CREATE_DATE; ?></td>
+						<td style="white-space:nowrap;">
+							<?php echo $msg['_raw']->A_RECORD_CREATE_DATE; ?>
+							<?php if ($msg['_readDate']) : ?>
+								<div class="text-muted" style="font-style:italic" title="Przeczytano <?php echo $msg['_readDate']; ?>"><?php echo $msg['_readDate']; ?></div>
+							<?php endif; ?>
+						</td>
 					</tr>
 					</tr>
 				<?php endforeach; ?>
 				<?php endforeach; ?>
 			<?php endif; ?>
 			<?php endif; ?>
@@ -185,20 +202,62 @@ class Route_TableMsgs extends RouteBase {
 <?php
 <?php
 	}
 	}
 
 
-	public function _getMsgs($tableName, $idRow) {
+	public function _getMsgs($filterType, $tableName, $idRow) {
 		$msgsRoute = Router::getRoute('Msgs');
 		$msgsRoute = Router::getRoute('Msgs');
-		$msgsList = $msgsRoute->getMessagesForTableRecord($tableName, $idRow);
-		foreach ($msgsList as $ind => $msg) {
-			$msgsList[$ind]['_read'] = ('WAITING' != $msg['_raw']->A_STATUS);
+		//$msgsList = $msgsRoute->getMessagesForTableRecord($tableName, $idRow);
+		$msgsList = array();
+		if (empty($tableName)) throw new Exception("No table name!");
+		$sqlWhereAddFilter = "";
+		$usrLogin = User::getLogin();
+		switch ($filterType) {
+			case 'inbox':
+				$sqlWhereAddFilter = "
+					and (m.`userTargetType` in('everyone')
+						or (m.`userTargetType`='user' and m.`userTargetName`='{$usrLogin}')
+						-- TODO: use group id
+					)
+					and m.`A_STATUS` not in('DELETED')
+				";
+				break;
+			case 'sent':
+				$sqlWhereAddFilter = "
+					and m.`A_RECORD_CREATE_AUTHOR`='{$usrLogin}'
+					and m.`A_STATUS` not in('DELETED')
+				";
+				break;
+			case 'removed':
+				$sqlWhereAddFilter = "
+					and (m.`A_RECORD_CREATE_AUTHOR`='{$usrLogin}'
+						or (m.`userTargetType` in('everyone')
+						or (m.`userTargetType`='user' and m.`userTargetName`='{$usrLogin}')
+						-- TODO: use group id
+					)
+				)
+					and m.`A_STATUS` in('DELETED')
+				";
+				break;
+			default: throw new Exception("Unknown filter type");
 		}
 		}
-		return $msgsList;
-	}
-
-	public function _getSentMsgs($tableName, $idRow) {
-		$msgsRoute = Router::getRoute('Msgs');
-		$msgsList = $msgsRoute->getSentMessagesForTableRecord($tableName, $idRow);
-		foreach ($msgsList as $ind => $msg) {
-			$msgsList[$ind]['_read'] = ('WAITING' != $msg['_raw']->A_STATUS);
+		$db = DB::getDB();
+		$tableName = $db->_($tableName);
+
+		$sql = "select m.*
+			from `CRM_UI_MSGS` m
+			where m.`uiTargetType`='default_db_table_record'
+				and m.`uiTargetName`='{$tableName}.{$idRow}'
+				{$sqlWhereAddFilter}
+			order by m.`ID` DESC
+			limit 21
+		";
+		$db = DB::getDB();
+		$res = $db->query($sql);
+		while ($r = $db->fetch($res)) {
+			$msg['message'] = $r->msg;
+			$msg['type'] = $r->msgType;
+			$msg['_raw'] = $r;
+			$msg['_read'] = ('WAITING' != $r->A_STATUS);
+			$msg['_readDate'] = $r->actionExecutedTime;
+			$msgsList[$r->ID] = $msg;
 		}
 		}
 		return $msgsList;
 		return $msgsList;
 	}
 	}
@@ -397,14 +456,18 @@ class Route_TableMsgs extends RouteBase {
 	}
 	}
 
 
 	public function readAction() {
 	public function readAction() {
-		$msgId = V::get('id', 0, $_GET, 'int');
-		if ($msgId <= 0) throw new HttpException("Wiadomość nie istnieje!", 404);
+		$idMsg = V::get('id', 0, $_GET, 'int');
+		$idTable = V::get('idTable', 0, $_REQUEST, 'int');
+		$idRow = V::get('idRow', 0, $_REQUEST, 'int');
+		if ($idMsg <= 0) throw new HttpException("Wiadomość nie istnieje!", 404);
+		if ($idTable <= 0) throw new HttpException("Błęny numer tabeli", 400);
+		if ($idRow <= 0) throw new HttpException("Błęny numer tabeli", 400);
 
 
 		SE_Layout::gora();
 		SE_Layout::gora();
 		SE_Layout::menu();
 		SE_Layout::menu();
 
 
 		try {
 		try {
-			$msg = $this->_getMsg($msgId);
+			$msg = $this->_getMsg($idMsg, $idTable, $idRow);
 			$this->_markAsRead($msg);
 			$this->_markAsRead($msg);
 			$this->tableRowMsg($msg);
 			$this->tableRowMsg($msg);
 		} catch (Exception $e) {
 		} catch (Exception $e) {
@@ -415,14 +478,18 @@ class Route_TableMsgs extends RouteBase {
 	}
 	}
 
 
 	public function viewAction() {
 	public function viewAction() {
-		$msgId = V::get('id', 0, $_GET, 'int');
-		if ($msgId <= 0) throw new HttpException("Wiadomość nie istnieje!", 404);
+		$idMsg = V::get('id', 0, $_GET, 'int');
+		$idTable = V::get('idTable', 0, $_REQUEST, 'int');
+		$idRow = V::get('idRow', 0, $_REQUEST, 'int');
+		if ($idMsg <= 0) throw new HttpException("Wiadomość nie istnieje!", 404);
+		if ($idTable <= 0) throw new HttpException("Błęny numer tabeli", 400);
+		if ($idRow <= 0) throw new HttpException("Błęny numer tabeli", 400);
 
 
 		SE_Layout::gora();
 		SE_Layout::gora();
 		SE_Layout::menu();
 		SE_Layout::menu();
 
 
 		try {
 		try {
-			$msg = $this->_getMsg($msgId);
+			$msg = $this->_getMsg($idMsg, $idTable, $idRow);
 			$this->tableRowMsg($msg);
 			$this->tableRowMsg($msg);
 		} catch (Exception $e) {
 		} catch (Exception $e) {
 			SE_Layout::alert('danger', $e->getMessage() . ' #' . $e->getLine());
 			SE_Layout::alert('danger', $e->getMessage() . ' #' . $e->getLine());
@@ -431,9 +498,12 @@ class Route_TableMsgs extends RouteBase {
 		SE_Layout::dol();
 		SE_Layout::dol();
 	}
 	}
 
 
-	public function _getMsg($msgId) {
+	public function _getMsg($idMsg, $idTable, $idRow) {
 		$msgsRoute = Router::getRoute('Msgs');
 		$msgsRoute = Router::getRoute('Msgs');
-		$msg['_raw'] = $msgsRoute->getMessage($msgId);
+		$msg['_raw'] = $msgsRoute->getMessage($idMsg);
+		if (!$msg['_raw']) throw new HttpException("Wiadomość nie istnieje!", 404);
+		$msg['idTable'] = $idTable;
+		$msg['idRow'] = $idRow;
 		$msg['message'] = $msg['_raw']->msg;
 		$msg['message'] = $msg['_raw']->msg;
 		$msg['type'] = $msg['_raw']->msgType;
 		$msg['type'] = $msg['_raw']->msgType;
 		$msg['_read'] = ('WAITING' != $msg['_raw']->A_STATUS);
 		$msg['_read'] = ('WAITING' != $msg['_raw']->A_STATUS);
@@ -446,8 +516,8 @@ class Route_TableMsgs extends RouteBase {
 		$parts = explode('.', $msg['_raw']->uiTargetName);
 		$parts = explode('.', $msg['_raw']->uiTargetName);
 		if (2 !== count($parts)) throw new Exception("Parse message target type error!");
 		if (2 !== count($parts)) throw new Exception("Parse message target type error!");
 		$msg['tblName'] = $parts[0];
 		$msg['tblName'] = $parts[0];
-		$msg['idRow'] = $parts[1];
-		if (!is_numeric($msg['idRow'])) throw new Exception("Parse message target type - id row error!");
+		if (!is_numeric($msg['idRow'])) throw new Exception("Parse message target type - id row type error!");
+		if ($msg['idRow'] != $parts[1]) throw new Exception("Parse message target type - id row value error!");
 		return $msg;
 		return $msg;
 	}
 	}
 
 
@@ -462,6 +532,7 @@ class Route_TableMsgs extends RouteBase {
 			set `A_STATUS`='NORMAL'
 			set `A_STATUS`='NORMAL'
 				, `A_RECORD_UPDATE_AUTHOR`='{$usrLogin}'
 				, `A_RECORD_UPDATE_AUTHOR`='{$usrLogin}'
 				, `A_RECORD_UPDATE_DATE`=NOW()
 				, `A_RECORD_UPDATE_DATE`=NOW()
+				, `actionExecutedTime`=NOW()
 			where `ID`='{$msg['_raw']->ID}'
 			where `ID`='{$msg['_raw']->ID}'
 		";
 		";
 		$res = $db->query($sql);
 		$res = $db->query($sql);
@@ -469,14 +540,19 @@ class Route_TableMsgs extends RouteBase {
 	}
 	}
 
 
 	public function tableRowMsg($msg) {
 	public function tableRowMsg($msg) {
-		$idTable = ProcesHelper::getZasobTableID($msg['tblName']);
+		$idTable = $msg['idTable'];
+		$idRow = $msg['idRow'];
 		$usrAcl = User::getAcl();
 		$usrAcl = User::getAcl();
 		$tblAcl = $usrAcl->getTableAcl($idTable);
 		$tblAcl = $usrAcl->getTableAcl($idTable);
-		$idRow = $msg['idRow'];
 
 
+		$linkBase = "index.php?_route=TableMsgs";
+		$linkBase .= "&idTable={$msg['idTable']}";
+		$linkBase .= "&idRow={$msg['idRow']}";
+		$rmMsgLink = "{$linkBase}&_task=removeMsg&id={$msg['_raw']->ID}";
+		$backLink = "{$linkBase}&_task=tableRow";
 		?>
 		?>
 <div class="container">
 <div class="container">
-	<h3><i class="glyphicon glyphicon-envelope"></i> <a href="index.php?_route=TableMsgs&_task=tableRow&idTable=<?php echo $idTable; ?>&idRow=<?php echo $idRow; ?>">Wiadomości powiązane z rekordem nr <?php echo $idRow; ?></a>
+	<h3><i class="glyphicon glyphicon-envelope"></i> <a href="<?php echo $backLink; ?>">Wiadomości powiązane z rekordem nr <?php echo $idRow; ?></a>
 		&raquo; Wiadomość nr <code><?php echo $msg['_raw']->ID; ?></code>
 		&raquo; Wiadomość nr <code><?php echo $msg['_raw']->ID; ?></code>
 		<br><small>z tabeli <a href="index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=13051">Test permy</a></small>
 		<br><small>z tabeli <a href="index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=13051">Test permy</a></small>
 	</h3>
 	</h3>
@@ -488,11 +564,68 @@ class Route_TableMsgs extends RouteBase {
 		<div class="panel-body">
 		<div class="panel-body">
 			<?php echo htmlspecialchars($msg['message']); ?>
 			<?php echo htmlspecialchars($msg['message']); ?>
 		</div>
 		</div>
+		<div class="panel-footer" style="overflow:hidden">
+			<?php if (!empty($msg['_raw']->A_RECORD_UPDATE_DATE) && !empty($msg['_raw']->A_RECORD_UPDATE_AUTHOR)) : ?>
+				<em style="margin-left:20px" class="text-muted">odczytana <?php echo $msg['_raw']->A_RECORD_UPDATE_DATE; ?> przez <?php echo $msg['_raw']->A_RECORD_UPDATE_AUTHOR; ?></em>
+			<?php endif; ?>
+			<?php if (!empty($msg['_raw']->A_RECORD_DELETE_DATE) && !empty($msg['_raw']->A_RECORD_DELETE_AUTHOR)) : ?>
+				<em style="margin-left:20px" class="text-muted">usunięta <?php echo $msg['_raw']->A_RECORD_DELETE_DATE; ?> przez <?php echo $msg['_raw']->A_RECORD_DELETE_AUTHOR; ?></em>
+			<?php endif; ?>
+			<?php if ('DELETED' != $msg['_raw']->A_STATUS) : ?>
+				<a href="<?php echo $rmMsgLink; ?>" class="btn btn-xs btn-default pull-right" title="usuń wiadomość" onclick="return confirm('Czy jesteś pewien że chcesz usunąć wiadomość?');"><i class="glyphicon glyphicon-remove"></i> Usuń</a>
+			<?php endif; ?>
+		</div>
 	</div>
 	</div>
 </div>
 </div>
 <?php
 <?php
 		// TODO: odpisz
 		// TODO: odpisz
-		// TODO: do kosza - add trigger to insert into `CRM_UI_MSGS__TRASH` after DELETE on `CRM_UI_MSGS`
+	}
+
+	public function removeMsgAction() {
+		$idMsg = V::get('id', 0, $_GET, 'int');
+		$idTable = V::get('idTable', 0, $_REQUEST, 'int');
+		$idRow = V::get('idRow', 0, $_REQUEST, 'int');
+		if ($idMsg <= 0) throw new HttpException("Wiadomość nie istnieje!", 404);
+		if ($idTable <= 0) throw new HttpException("Błęny numer tabeli", 400);
+		if ($idRow <= 0) throw new HttpException("Błęny numer tabeli", 400);
+
+		SE_Layout::gora();
+		SE_Layout::menu();
+
+		try {
+			$msg = $this->_getMsg($idMsg, $idTable, $idRow);
+			$this->_removeRowMsg($msg);
+		} catch (Exception $e) {
+			SE_Layout::alert('danger', $e->getMessage() . ' #' . $e->getLine());
+			SE_Layout::dol();
+			exit;
+		}
+		?>
+<div class="container">
+	<div class="alert alert-success">
+		Wiadomość została usunięta - <a href="index.php?_route=TableMsgs&_task=tableRow&idTable=<?php echo $idTable; ?>&idRow=<?php echo $idRow; ?>">wróć</a>
+	</div>
+</div>
+<?php
+		SE_Layout::dol();
+	}
+
+	public function _removeRowMsg($msg) {
+		// IDEA: do kosza - add trigger to insert into `CRM_UI_MSGS__TRASH` after DELETE on `CRM_UI_MSGS`
+		if (empty($msg['_raw']) || empty($msg['_raw']->ID)) throw new Exception("Brak wiadomości!");
+		$usrLogin = User::getLogin();
+		$db = DB::getDB();
+		if (!$db) throw new Exception("Brak dazy danych!");
+		if ($db->has_errors()) throw new Exception("DB Errors: " . implode("\n<br>", $db->get_errors()));
+		$sqlTODO = "delete `CRM_UI_MSGS` where `ID`='{$msg['_raw']->ID}' ";
+		$sql = "update `CRM_UI_MSGS`
+			set `A_STATUS`='DELETED'
+				, `A_RECORD_DELETE_AUTHOR`='{$usrLogin}'
+				, `A_RECORD_DELETE_DATE`=NOW()
+			where `ID`='{$msg['_raw']->ID}'
+		";
+		$res = $db->query($sql);
+		if (!$res || $db->has_errors()) throw new Exception("Wystąpiły błędy podczas próby zapisu wiadomości: " . implode("\n<br>", $db->get_errors()));
 	}
 	}
 
 
 }
 }