menu(); UI::dol(); } function menu() { $usrLogin = User::getLogin(); ?> tableRowMsgs($idTable, $idRow); } catch (Exception $e) { UI::alert('danger', $e->getMessage() . ' #' . $e->getLine()); } UI::dol(); } 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); if ($createdId > 0) { $args['to'] = ''; $args['msg'] = ''; } } catch(Exception $e) { $arrorsList[] = $e->getMessage(); } } $msgsList = $this->getMsgs('inbox', $tableName, $idRow); $totalReadMsgs = 0; $totalUnreadMsgs = 0; foreach ($msgsList as $ind => $msg) { if ($msg['_read']) { $totalReadMsgs++; } else { $totalUnreadMsgs++; } } $sentMsgsList = $this->getMsgs('sent', $tableName, $idRow); $removedMsgsList = $this->getMsgs('removed', $tableName, $idRow); ?>

Wiadomości powiązane z rekordem nr
Edytuj rekord

0) : ?>
_printTableMsgsList('inbox', $msgsList, $idTable, $idRow); ?>
_printTableMsgsList('sent', $sentMsgsList, $idTable, $idRow); ?>
_printTableMsgsList('removed', $removedMsgsList, $idTable, $idRow); ?>
Wyślij nową wiadomość
_printMsgForm($args); ?>
msgs = $this->getMsgs($listType, $tableName, $idRow, $lastMsgId); $resultData->keysOrder = array_keys($resultData->msgs); echo json_encode($resultData); } function _printTableMsgsList($listType, $msgsList, $idTable, $idRow) { $msgsTotal = count($msgsList); $listLimit = $this->_listLimit; $lastMsgId = 0; $actionTask = ($listType == 'inbox')? 'read' : 'view'; ?> $msg) : $i++; if ($i > $listLimit) break; $lastMsgId = $idMsg; ?> ID; $msgLink .= "&idTable={$idTable}&idRow={$idRow}"; if ('read' == $actionTask || 'view' == $actionTask) { $msgLink .= '&_task=' . $actionTask; } else { $msgLink = null; } if ($msgLink) { $jsOnClick = "window.location.href='{$msgLink}'"; $onClick = 'onclick="' . $jsOnClick . '"'; } ?> class="tblMsgsListItem "> $listLimit) : ?>
# wiadomość data
Brak wiadomości
ID; ?>
od A_RECORD_CREATE_AUTHOR; ?> do userTargetType) { echo "wszystkich"; } else if ('user' == $msg['_raw']->userTargetType) { echo "{$msg['_raw']->userTargetName}"; } else if ('group' == $msg['_raw']->userTargetType) { echo "grupy {$msg['_raw']->userTargetName}"; } ?>
A_RECORD_CREATE_DATE; ?>
nieodczytana
0) { $sqlWhereAddFilter .= "\n and m.`ID`<{$lastMsgId}"; } $sqlLimit = $this->_listLimit + 1; $rawMsgs = DB::getPDO()->fetchAllByKey(" select m.* from `CRM_UI_MSGS` m where m.`uiTargetType` = 'default_db_table_record' and m.`uiTargetName` = :feature_id {$sqlWhereAddFilter} order by m.`ID` DESC limit {$sqlLimit} ", 'ID', [ ':feature_id' => "{$tableName}.{$idRow}" ]); return array_map(function ($msg) { return [ 'message' => $msg['msg'], 'type' => $msg['msgType'], '_raw' => (object)$msg, '_read' => ('WAITING' != $msg['A_STATUS']), '_readDate' => $msg['actionExecutedTime'], ]; }, $rawMsgs); } 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"); } } function _create($args, $tableName, $idRow) { $toType = V::get('to_type', '', $args); $to = V::get('to', '', $args); $msg = V::get('msg', '', $args); return DB::getPDO()->insert('CRM_UI_MSGS', [ 'uiTargetType' => 'default_db_table_record', 'uiTargetName' => "{$tableName}.{$idRow}", 'userTargetType' => $toType, 'userTargetName' => $to, 'msg' => $msg, 'A_RECORD_CREATE_DATE' => "NOW()", 'A_RECORD_CREATE_AUTHOR' => User::getLogin(), 'A_STATUS' => 'WAITING', 'app_className' => 'TableMsgs', ]); } 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 : ''; ?>
showFormItem($tblID = -1, $fldName, $selectedGroupId, $fldParams); ?>
showFormItem($tblID = -1, $fldName, $selectedLogin, $fldParams); ?>
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); } 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); } function readAction() { $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); UI::gora(); UI::menu(); try { $msg = $this->_getMsg($idMsg, $idTable, $idRow); $this->_markAsRead($msg); $this->viewMsg($msg); } catch (Exception $e) { UI::alert('danger', $e->getMessage() . ' #' . $e->getLine()); } UI::dol(); } function viewAction() { $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); UI::gora(); UI::menu(); try { $msg = $this->_getMsg($idMsg, $idTable, $idRow); $this->viewMsg($msg); } catch (Exception $e) { UI::alert('danger', $e->getMessage() . ' #' . $e->getLine()); } UI::dol(); } function _getMsg($idMsg, $idTable, $idRow) { $msgsRoute = Router::getRoute('Msgs'); $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['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]; 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; } function _markAsRead($msg) { if ($msg['_read']) return; DB::getPDO()->execSql(" update CRM_UI_MSGS set A_STATUS = 'NORMAL' , A_RECORD_UPDATE_AUTHOR = :login , A_RECORD_UPDATE_DATE = NOW() , actionExecutedTime = NOW() where ID = :id and A_STATUS = 'WAITING' and A_RECORD_UPDATE_AUTHOR = '' and A_RECORD_UPDATE_DATE is null and ( ( :login != A_RECORD_CREATE_AUTHOR ) or ( :login = A_RECORD_CREATE_AUTHOR and 'user' = userTargetType and :login = userTargetName ) ) ", [ ':id' => $msg['_raw']->ID, ':login' => User::getLogin(), ]); } function viewMsg($msg) { $usrLogin = User::getLogin(); $idTable = 0; if (!empty($msg['tblName'])) { $tblName = $msg['tblName']; $idTable = (!empty($msg['idTable']))? $msg['idTable'] : ProcesHelper::getZasobTableID($tblName); if (!$idTable) throw new Exception("Nie udało się odnaleźć nr tabeli '{$tblName}'"); $idRow = $msg['idRow']; if (!$idRow) throw new Exception("Brak numeru powiązanego rekordu!"); $usrAcl = User::getAcl(); $tblAcl = $usrAcl->getTableAcl($idTable); } $userMsgsRoute = Router::getRoute('UserMsgs'); $linkBase = "index.php?_route=TableMsgs"; $linkBase .= "&idTable={$idTable}&idRow={$idRow}"; //$rmMsgLink = "{$linkBase}&_task=removeMsg&id={$msg['_raw']->ID}"; $backLink = "{$linkBase}&_task=tableRow"; ?>

Wiadomości powiązane z rekordem nr » Wiadomość nr ID; ?> 0) : ?> Edytuj rekord z tabeli getRawLabel(); ?>

printWidgetViewMsg($msg); ?> _getMsg($idMsg, $idTable, $idRow); $msgsRoute = Router::getRoute('Msgs'); $msgsRoute->removeTableRecordMsg($idMsg); } catch (Exception $e) { UI::alert('danger', $e->getMessage() . ' #' . $e->getLine()); UI::dol(); exit; } ?>
Wiadomość została usunięta wróć