|
|
@@ -1,6 +1,9 @@
|
|
|
<?php
|
|
|
|
|
|
+Lib::loadClass('Router');
|
|
|
Lib::loadClass('RouteBase');
|
|
|
+Lib::loadClass('TypespecialVariable');
|
|
|
+Lib::loadClass('ProcesHelper');
|
|
|
|
|
|
class Route_TableMsgs extends RouteBase {
|
|
|
|
|
|
@@ -37,17 +40,455 @@ class Route_TableMsgs extends RouteBase {
|
|
|
SE_Layout::gora();
|
|
|
SE_Layout::menu();
|
|
|
|
|
|
- $this->tableRowMsgs();
|
|
|
+ try {
|
|
|
+ $this->tableRowMsgs($idTable, $idRow);
|
|
|
+ } catch (Exception $e) {
|
|
|
+ SE_Layout::alert('danger', $e->getMessage() . ' #' . $e->getLine());
|
|
|
+ }
|
|
|
|
|
|
SE_Layout::dol();
|
|
|
}
|
|
|
|
|
|
public function tableRowMsgs($idTable, $idRow) {
|
|
|
+ $tblAcl = User::getAcl()->getTableAcl($idTable);
|
|
|
+ $tableName = $tblAcl->getName();
|
|
|
+ $record = $tblAcl->getItem($idRow);
|
|
|
+ $args = array();
|
|
|
+ $args['to_type'] = V::get('to_type', '', $_POST);
|
|
|
+ $args['to'] = V::get("to-{$args['to_type']}", '', $_POST);
|
|
|
+ $args['msg'] = V::get('msg', '', $_POST);
|
|
|
+ $arrorsList = array();
|
|
|
+ $createdId = 0;
|
|
|
+ if (!empty($_POST)) {
|
|
|
+ try {
|
|
|
+ $this->_validate($args);
|
|
|
+ $createdId = $this->_create($args, $tableName, $idRow);
|
|
|
+ } catch(Exception $e) {
|
|
|
+ $arrorsList[] = $e->getMessage();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $msgsList = $this->_getMsgs($tableName, $idRow);
|
|
|
+ $totalReadMsgs = 0;
|
|
|
+ $totalUnreadMsgs = 0;
|
|
|
+ foreach ($msgsList as $ind => $msg) {
|
|
|
+ if ($msg['_read']) {
|
|
|
+ $totalReadMsgs++;
|
|
|
+ } else {
|
|
|
+ $totalUnreadMsgs++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $sentMsgsList = $this->_getSentMsgs($tableName, $idRow);
|
|
|
+ ?>
|
|
|
+<style type="text/css">
|
|
|
+.tblMsgsListItem { cursor:pointer; }
|
|
|
+</style>
|
|
|
+<div class="container">
|
|
|
+ <h3><i class="glyphicon glyphicon-envelope"></i> Wiadomości powiązane z rekordem nr <code><?php echo $idRow; ?></code>
|
|
|
+ <br><small>z tabeli <a href="index.php?MENU_INIT=VIEWTABLE_AJAX&ZASOB_ID=<?php echo $idTable; ?>"><?php echo $tblAcl->getLabel(); ?></a></small>
|
|
|
+ </h3>
|
|
|
+ <?php if ($createdId > 0) : ?>
|
|
|
+ <?php echo SE_Layout::alert('info', "Wysłano wiadomość nr '{$createdId}'"); ?>
|
|
|
+ <?php endif; ?>
|
|
|
+
|
|
|
+ <div>
|
|
|
+ <ul class="nav nav-tabs" role="tablist">
|
|
|
+ <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>
|
|
|
+ </ul>
|
|
|
+ <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;">
|
|
|
+ <?php $this->_printTableMsgsList($msgsList, 'read'); ?>
|
|
|
+ </div>
|
|
|
+ <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'); ?>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="panel panel-default">
|
|
|
+ <div class="panel-heading">Wyślij nową wiadomość</div>
|
|
|
+ <div class="panel-body">
|
|
|
+ <?php if (!empty($arrorsList)) : ?>
|
|
|
+ <?php foreach ($arrorsList as $errMsg) : ?>
|
|
|
+ <div class="alert alert-danger"><?php echo $errMsg; ?></div>
|
|
|
+ <?php endforeach; ?>
|
|
|
+ <?php endif; ?>
|
|
|
+ <?php $this->_printMsgForm($args); ?>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+</div>
|
|
|
+<?php
|
|
|
+ //DBG::_(true, true, "_POST", $_POST, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
+ //DBG::_(true, true, "tblAcl", $tblAcl, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
+ //DBG::_(true, true, "record", $record, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
+ //DBG::_(true, true, "msgsList", $msgsList, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
+ //throw new Exception("TODO: ...");
|
|
|
+ }
|
|
|
+
|
|
|
+ public function _printTableMsgsList($msgsList, $actionTask = null) {
|
|
|
+ $msgsTotal = count($msgsList);
|
|
|
+ ?>
|
|
|
+ <table class="tblMsgsList table table-hovered" style="margin-bottom:0; table-layout:fixed;">
|
|
|
+ <thead>
|
|
|
+ <tr>
|
|
|
+ <th style="width:60px">#</th>
|
|
|
+ <th>wiadomość</th>
|
|
|
+ <th style="width:130px">data</th>
|
|
|
+ </tr>
|
|
|
+ </thead>
|
|
|
+ <tbody>
|
|
|
+ <?php if ($msgsTotal <= 0) : ?>
|
|
|
+ <tr>
|
|
|
+ <td colspan="3"><em class="text-muted" style="padding-left:60px;">Brak wiadomości</em></td>
|
|
|
+ </tr>
|
|
|
+ <?php else : ?>
|
|
|
+ <?php foreach ($msgsList as $msg) : ?>
|
|
|
+ <?php
|
|
|
+ $onClick = '';
|
|
|
+ $msgLink = Request::getPathUri() . 'index.php?_route=TableMsgs&id=' . $msg['_raw']->ID;
|
|
|
+ if ('read' == $actionTask || 'view' == $actionTask) {
|
|
|
+ $msgLink .= '&_task=' . $actionTask;
|
|
|
+ } else {
|
|
|
+ $msgLink = null;
|
|
|
+ }
|
|
|
+ if ($msgLink) {
|
|
|
+ $jsOnClick = "window.location.href='{$msgLink}'";
|
|
|
+ $onClick = 'onclick="' . $jsOnClick . '"';
|
|
|
+ }
|
|
|
+ ?>
|
|
|
+ <tr <?php echo $onClick; ?>
|
|
|
+ class="tblMsgsListItem <?php echo ($msg['_read'])? 'active' : ''; ?>">
|
|
|
+ <td><?php echo $msg['_raw']->ID; ?></td>
|
|
|
+ <td>
|
|
|
+ <div style="overflow:hidden; white-space:nowrap; text-overflow:ellipsis;"><?php echo htmlspecialchars($msg['message']); ?></div>
|
|
|
+ <div class="text-muted" style="font-style:italic;">
|
|
|
+ od <?php echo $msg['_raw']->A_RECORD_CREATE_AUTHOR; ?> do <?php
|
|
|
+ if ('everyone' == $msg['_raw']->userTargetType) {
|
|
|
+ echo "wszystkich";
|
|
|
+ } else if ('user' == $msg['_raw']->userTargetType) {
|
|
|
+ echo "{$msg['_raw']->userTargetName}";
|
|
|
+ } else if ('group' == $msg['_raw']->userTargetType) {
|
|
|
+ echo "grupy {$msg['_raw']->userTargetName}";
|
|
|
+ }
|
|
|
+ ?>
|
|
|
+ </div>
|
|
|
+ </td>
|
|
|
+ <td style="white-space:nowrap;"><?php echo $msg['_raw']->A_RECORD_CREATE_DATE; ?></td>
|
|
|
+ </tr>
|
|
|
+ <?php endforeach; ?>
|
|
|
+ <?php endif; ?>
|
|
|
+ </tbody>
|
|
|
+ </table>
|
|
|
+<?php
|
|
|
+ }
|
|
|
+
|
|
|
+ public function _getMsgs($tableName, $idRow) {
|
|
|
+ $msgsRoute = Router::getRoute('Msgs');
|
|
|
+ $msgsList = $msgsRoute->getMessagesForTableRecord($tableName, $idRow);
|
|
|
+ foreach ($msgsList as $ind => $msg) {
|
|
|
+ $msgsList[$ind]['_read'] = ('WAITING' != $msg['_raw']->A_STATUS);
|
|
|
+ }
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ return $msgsList;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function _validate($args) {
|
|
|
+ $toType = V::get('to_type', '', $args);
|
|
|
+ $to = V::get('to', '', $args);
|
|
|
+ $msg = V::get('msg', '', $args);
|
|
|
+ if (!in_array($toType, array('everyone', 'user', 'group'))) {
|
|
|
+ throw new Exception("Niedozwolony typ odbiorcy");
|
|
|
+ }
|
|
|
+ if (empty($to) && 'everyone' != $toType) {
|
|
|
+ throw new Exception("Proszę podać odbiorcę wiadomości");
|
|
|
+ }
|
|
|
+ if (empty($msg)) {
|
|
|
+ throw new Exception("Proszę podać treść wiadomości");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public function _create($args, $tableName, $idRow) {
|
|
|
+ $toType = V::get('to_type', '', $args);
|
|
|
+ $to = V::get('to', '', $args);
|
|
|
+ $msg = V::get('msg', '', $args);
|
|
|
+ $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()));
|
|
|
+ $item = array();
|
|
|
+ $item['`uiTargetType`'] = "'default_db_table_record'";
|
|
|
+ $item['`uiTargetName`'] = "'{$tableName}.{$idRow}'";
|
|
|
+ $item['`userTargetType`'] = "'{$toType}'";
|
|
|
+ $item['`userTargetName`'] = "'{$to}'";
|
|
|
+ $item['`msg`'] = "'" . $db->_($msg) . "'";
|
|
|
+ $item['`A_RECORD_CREATE_DATE`'] = "NOW()";
|
|
|
+ $item['`A_RECORD_CREATE_AUTHOR`'] = "'{$usrLogin}'";
|
|
|
+ $item['`A_STATUS`'] = "'WAITING'";
|
|
|
+ $item['`app_className`'] = "'TableMsgs'";
|
|
|
+ $sql = "insert into `CRM_UI_MSGS` (" . implode(",", array_keys($item)) . ")
|
|
|
+ values (" . implode(",", array_values($item)) . ")
|
|
|
+ ";
|
|
|
+ $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()));
|
|
|
+ $createdId = $db->insert_id();
|
|
|
+ if ($createdId <= 0) throw new Exception("Nie udało się zapisać wiadomości.");
|
|
|
+ return $createdId;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function _printMsgForm($args) {
|
|
|
+ $toType = V::get('to_type', '', $args);
|
|
|
+ $to = V::get('to', '', $args);
|
|
|
+ $msg = V::get('msg', '', $args);
|
|
|
+ $listTo = array();
|
|
|
+ $listTo['everyone'] = 'Wszyscy';
|
|
|
+ $listTo['user'] = 'Użytkownik';
|
|
|
+ //$listTo['group'] = 'Grupa';
|
|
|
+ $toType = (array_key_exists($toType, $listTo))? $toType : 'everyone';
|
|
|
+ $typeSpecialGroupId = TypespecialVariable::getInstance(-1, '__ZASOB');
|
|
|
+ $typeSpecialUserLogin = TypespecialVariable::getInstance(-1, '__USER_LOGIN');
|
|
|
+ $selectedLogin = ('user' == $toType)? $to : '';
|
|
|
+ $selectedGroupId = ('group' == $toType)? $to : '';
|
|
|
+ ?>
|
|
|
+ <form class="form-horizontal" action="" method="post">
|
|
|
+ <div class="form-group">
|
|
|
+ <label class="col-sm-2 control-label" for="to">Do:</label>
|
|
|
+ <div class="col-sm-3">
|
|
|
+ <select name="to_type" class="form-control" onChange="return selectTblMsgsToType(this);">
|
|
|
+ <?php foreach ($listTo as $type => $typeLabel) : ?>
|
|
|
+ <option <?php echo ($type == $toType)? 'selected' : ''; ?>
|
|
|
+ value="<?php echo $type; ?>"><?php echo $typeLabel; ?></option>
|
|
|
+ <?php endforeach; ?>
|
|
|
+ </select>
|
|
|
+ </div>
|
|
|
+ <div class="col-sm-7">
|
|
|
+ <div id="tblMsgsTo-everyone" style="<?php echo ('everyone' == $toType)? '' : 'display:none'; ?>">
|
|
|
+ <input name="to-everyone" type="text" class="form-control" disabled>
|
|
|
+ </div>
|
|
|
+ <div id="tblMsgsTo-group" style="<?php echo ('group' == $toType)? '' : 'display:none'; ?>">
|
|
|
+ <?php if ($typeSpecialGroupId) : ?>
|
|
|
+ <?php
|
|
|
+ $fldName = 'to-group';
|
|
|
+ $fldParams = array();
|
|
|
+ $fldParams['allowCreate'] = false;
|
|
|
+ $fldParams['ajaxDataUrlBase'] = "index.php?_route=TableMsgs&_task=typeSpecialGroupId";
|
|
|
+ $fldParams['placeholder'] = 'Grupa...';
|
|
|
+ //$fldParams['ajaxDataUrlBase'] .= "&DBG_TS=3";
|
|
|
+ echo $typeSpecialUserLogin->showFormItem($tblID = -1, $fldName, $selectedGroupId, $fldParams);
|
|
|
+ ?>
|
|
|
+ <?php else : ?>
|
|
|
+ <input name="to-group" type="text" class="form-control" placeholder="Grupa">
|
|
|
+ <?php endif; ?>
|
|
|
+ </div>
|
|
|
+ <div id="tblMsgsTo-user" style="<?php echo ('user' == $toType)? '' : 'display:none'; ?>">
|
|
|
+ <?php if ($typeSpecialUserLogin) : ?>
|
|
|
+ <?php
|
|
|
+ $fldName = 'to-user';
|
|
|
+ $fldParams = array();
|
|
|
+ $fldParams['allowCreate'] = false;
|
|
|
+ $fldParams['ajaxDataUrlBase'] = "index.php?_route=TableMsgs&_task=typeSpecialUserLogin";
|
|
|
+ $fldParams['placeholder'] = 'Użytkownik...';
|
|
|
+ //$fldParams['ajaxDataUrlBase'] .= "&DBG_TS=3";
|
|
|
+ echo $typeSpecialUserLogin->showFormItem($tblID = -1, $fldName, $selectedLogin, $fldParams);
|
|
|
+ ?>
|
|
|
+ <?php else : ?>
|
|
|
+ <input name="to-user" type="text" class="form-control" placeholder="Użytkownik">
|
|
|
+ <?php endif; ?>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <label for="to" class="col-sm-2 control-label">Wiadomość:</label>
|
|
|
+ <div class="col-sm-10">
|
|
|
+ <textarea name="msg" class="form-control"><?php echo htmlspecialchars($msg); ?></textarea>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="form-group">
|
|
|
+ <div class="col-sm-10 col-sm-offset-2">
|
|
|
+ <input class="btn btn-primary" type="submit" value="Wyślij">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </form>
|
|
|
+<script>
|
|
|
+ function selectTblMsgsToType(n) {
|
|
|
+ var toTypes = <?php echo json_encode(array_keys($listTo)); ?>,
|
|
|
+ selectedType = n.value
|
|
|
+ ;
|
|
|
+ if (-1 !== toTypes.indexOf(n.value)) {
|
|
|
+ toTypes.forEach(function(type) {
|
|
|
+ if (type == selectedType) {
|
|
|
+ document.getElementById('tblMsgsTo-' + type).style.display = 'block';
|
|
|
+ } else {
|
|
|
+ document.getElementById('tblMsgsTo-' + type).style.display = 'none';
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|
|
|
+<?php
|
|
|
+ }
|
|
|
+
|
|
|
+ public function typeSpecialUserLoginAction() {
|
|
|
+ header("Content-type: application/json");
|
|
|
+ $typeSpecialUserId = TypespecialVariable::getInstance(-1, '__USER_LOGIN');
|
|
|
+ if (!$typeSpecialUserId) {
|
|
|
+ $jsonData = new stdClass();
|
|
|
+ $jsonData->message = "TypeSpecial '__USER_LOGIN' not exists";
|
|
|
+ echo json_encode($jsonData);
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+
|
|
|
+ $query = V::get('q', '', $_REQUEST);
|
|
|
+ $rawRows = null;
|
|
|
+ $jsonData = array();
|
|
|
+ $queryParams = array();
|
|
|
+ $rows = $typeSpecialUserId->getValuesWithExports($query, $queryParams);
|
|
|
+ foreach ($rows as $kID => $vItem) {
|
|
|
+ $itemJson = new stdClass();
|
|
|
+ $itemJson->id = $vItem->id;
|
|
|
+ $itemJson->name = $vItem->param_out;
|
|
|
+ if (!empty($vItem->exports)) {
|
|
|
+ $itemJson->exports = $vItem->exports;
|
|
|
+ }
|
|
|
+ $jsonData[] = $itemJson;
|
|
|
+ }
|
|
|
+ echo json_encode($jsonData);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function typeSpecialGroupIdAction() {
|
|
|
+ header("Content-type: application/json");
|
|
|
+ Lib::loadClass('TypespecialVariable');
|
|
|
+ $typeSpecialZasob = TypespecialVariable::getInstance(-1, '__ZASOB');
|
|
|
+ if (!$typeSpecialZasob) {
|
|
|
+ $jsonData = new stdClass();
|
|
|
+ $jsonData->message = "TypeSpecial '__ZASOB' not exists";
|
|
|
+ echo json_encode($jsonData);
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+
|
|
|
+ $query = V::get('q', '', $_REQUEST);
|
|
|
+ $rawRows = null;
|
|
|
+ $jsonData = array();
|
|
|
+ $queryParams = array();
|
|
|
+ $queryParams['zasob_type_in'] = array('STANOWISKO', 'PODMIOT', 'DZIAL');
|
|
|
+ $rows = $typeSpecialZasob->getValuesWithExports($query, $queryParams);
|
|
|
+ DBG::_('DBG_TS', '>1', "rows({$query})", $rows, __CLASS__, __FUNCTION__, __LINE__);
|
|
|
+ foreach ($rows as $kID => $vItem) {
|
|
|
+ $itemJson = new stdClass();
|
|
|
+ $itemJson->id = $vItem->id;
|
|
|
+ $itemJson->name = $vItem->param_out;
|
|
|
+ if (!empty($vItem->exports)) {
|
|
|
+ $itemJson->exports = $vItem->exports;
|
|
|
+ }
|
|
|
+ $jsonData[] = $itemJson;
|
|
|
+ }
|
|
|
+ echo json_encode($jsonData);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function readAction() {
|
|
|
+ $msgId = V::get('id', 0, $_GET, 'int');
|
|
|
+ if ($msgId <= 0) throw new HttpException("Wiadomość nie istnieje!", 404);
|
|
|
+
|
|
|
+ SE_Layout::gora();
|
|
|
+ SE_Layout::menu();
|
|
|
+
|
|
|
+ try {
|
|
|
+ $msg = $this->_getMsg($msgId);
|
|
|
+ $this->_markAsRead($msg);
|
|
|
+ $this->tableRowMsg($msg);
|
|
|
+ } catch (Exception $e) {
|
|
|
+ SE_Layout::alert('danger', $e->getMessage() . ' #' . $e->getLine());
|
|
|
+ }
|
|
|
+
|
|
|
+ SE_Layout::dol();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function viewAction() {
|
|
|
+ $msgId = V::get('id', 0, $_GET, 'int');
|
|
|
+ if ($msgId <= 0) throw new HttpException("Wiadomość nie istnieje!", 404);
|
|
|
+
|
|
|
+ SE_Layout::gora();
|
|
|
+ SE_Layout::menu();
|
|
|
+
|
|
|
+ try {
|
|
|
+ $msg = $this->_getMsg($msgId);
|
|
|
+ $this->tableRowMsg($msg);
|
|
|
+ } catch (Exception $e) {
|
|
|
+ SE_Layout::alert('danger', $e->getMessage() . ' #' . $e->getLine());
|
|
|
+ }
|
|
|
+
|
|
|
+ SE_Layout::dol();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function _getMsg($msgId) {
|
|
|
+ $msgsRoute = Router::getRoute('Msgs');
|
|
|
+ $msg['_raw'] = $msgsRoute->getMessage($msgId);
|
|
|
+ $msg['message'] = $msg['_raw']->msg;
|
|
|
+ $msg['type'] = $msg['_raw']->msgType;
|
|
|
+ $msg['_read'] = ('WAITING' != $msg['_raw']->A_STATUS);
|
|
|
+
|
|
|
+ // $msg['_raw']->uiTargetType => default_db_table_record
|
|
|
+ // $msg['_raw']->uiTargetName => TEST_PERMS.31
|
|
|
+ if ('default_db_table_record' !== $msg['_raw']->uiTargetType) {
|
|
|
+ throw new Exception("Parse message target type error!");
|
|
|
+ }
|
|
|
+ $parts = explode('.', $msg['_raw']->uiTargetName);
|
|
|
+ if (2 !== count($parts)) throw new Exception("Parse message target type error!");
|
|
|
+ $msg['tblName'] = $parts[0];
|
|
|
+ $msg['idRow'] = $parts[1];
|
|
|
+ if (!is_numeric($msg['idRow'])) throw new Exception("Parse message target type - id row error!");
|
|
|
+ return $msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function _markAsRead($msg) {
|
|
|
+ if ($msg['_read']) return;
|
|
|
+
|
|
|
+ $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()));
|
|
|
+ $sql = "update `CRM_UI_MSGS`
|
|
|
+ set `A_STATUS`='NORMAL'
|
|
|
+ , `A_RECORD_UPDATE_AUTHOR`='{$usrLogin}'
|
|
|
+ , `A_RECORD_UPDATE_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()));
|
|
|
+ }
|
|
|
+
|
|
|
+ public function tableRowMsg($msg) {
|
|
|
+ $idTable = ProcesHelper::getZasobTableID($msg['tblName']);
|
|
|
+ $usrAcl = User::getAcl();
|
|
|
+ $tblAcl = $usrAcl->getTableAcl($idTable);
|
|
|
+ $idRow = $msg['idRow'];
|
|
|
+
|
|
|
?>
|
|
|
<div class="container">
|
|
|
- <h3>Wiadomości powiązane z rekordem [<?php echo $idRow; ?>] z tabeli [<?php echo $idTable; ?>]</h3>
|
|
|
+ <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>
|
|
|
+ » 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>
|
|
|
+ </h3>
|
|
|
+ <div class="panel panel-<?php echo $msg['type']; ?>">
|
|
|
+ <div class="panel-heading">
|
|
|
+ <h3 class="panel-title">Wiadomość wysłana przez <?php echo $msg['_raw']->A_RECORD_CREATE_AUTHOR; ?>
|
|
|
+ <span class="pull-right"><?php echo $msg['_raw']->A_RECORD_CREATE_DATE; ?></span></h3>
|
|
|
+ </div>
|
|
|
+ <div class="panel-body">
|
|
|
+ <?php echo htmlspecialchars($msg['message']); ?>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
<?php
|
|
|
+ // TODO: odpisz
|
|
|
}
|
|
|
|
|
|
}
|