|
|
@@ -707,20 +707,34 @@ function tblMsgsLoadMoreRows(n) {
|
|
|
}
|
|
|
|
|
|
public function _testViewMsg($msg) {
|
|
|
+ $messageList = array();
|
|
|
$uiTargetName = $msg['_raw']->uiTargetName;
|
|
|
$uiTargetType = $msg['_raw']->uiTargetType;
|
|
|
$replyLink = "index.php?_route=UserMsgs&_task=reply&uiTargetName={$uiTargetName}&uiTargetType={$uiTargetType}";
|
|
|
$message = $this->_convertMessageToJson($msg['_raw']);
|
|
|
- $messageList = array($message);
|
|
|
+ if ($message->idThread > 0) {
|
|
|
+ $sqlLimit = 100;
|
|
|
+ $ds = DB::getDataSource();
|
|
|
+ $sql = "
|
|
|
+ select m.*
|
|
|
+ from `CRM_UI_MSGS` m
|
|
|
+ where (m.`idThread` = {$message->idThread} or m.`ID` = {$message->idThread})
|
|
|
+ and m.`ID` < {$message->id}
|
|
|
+ order by m.`ID` asc
|
|
|
+ limit {$sqlLimit}
|
|
|
+ ";
|
|
|
+ $moreMsgs = $ds->getListByQuery($sql);
|
|
|
+ foreach ($moreMsgs as $msg) $messageList[] = $this->_convertMessageToJson($msg);
|
|
|
+ }
|
|
|
+ $messageList[] = $message;
|
|
|
?>
|
|
|
<link rel="stylesheet" href="./stuff/widget-select.css">
|
|
|
<style type="text/css">
|
|
|
.user_avatar {
|
|
|
display:block;
|
|
|
- float:left;
|
|
|
width:40px;
|
|
|
height:40px;
|
|
|
- margin:0;
|
|
|
+ margin:0 auto 10px auto;
|
|
|
padding:0;
|
|
|
border:1px solid #ddd;
|
|
|
line-height: 38px;
|
|
|
@@ -730,16 +744,7 @@ function tblMsgsLoadMoreRows(n) {
|
|
|
color:#aaa;
|
|
|
}
|
|
|
</style>
|
|
|
-<div class="container">
|
|
|
- <div id="widget-msg-tree" class="col-md-10"></div>
|
|
|
-</div>
|
|
|
-<script>
|
|
|
-function frmTestSubmit(frm) {
|
|
|
- console.log('frmTestSubmit frm: ', frm);
|
|
|
- //console.log('frmTestSubmit "' + frm.fldNameMulti.value + '"');
|
|
|
- return false;
|
|
|
-}
|
|
|
-</script>
|
|
|
+<div id="widget-msg-tree" style="max-width:1000px; margin:0 auto;"></div>
|
|
|
<script src="stuff/vendors.js"></script>
|
|
|
<script src="stuff/bundle.se_route_user_msgs.js"></script>
|
|
|
<script>
|
|
|
@@ -756,7 +761,7 @@ function frmTestSubmit(frm) {
|
|
|
_msgsXhr = null;
|
|
|
}
|
|
|
_msgsXhr = $.ajax({
|
|
|
- url: 'index.php?_route=UserMsgs&_task=getMessagesById&id=<?php echo $message->id; ?>',
|
|
|
+ url: 'index.php?_route=UserMsgs&_task=getMessagesById&idThread=<?php echo $message->idThread; ?>',
|
|
|
data: reqData,
|
|
|
dataType: 'json'
|
|
|
});
|
|
|
@@ -911,17 +916,18 @@ function frmTestSubmit(frm) {
|
|
|
|
|
|
public function getMessagesByIdAction() {
|
|
|
try {
|
|
|
- $id = V::get('id', '', $_GET, 'int');
|
|
|
+ $idThread = V::get('idThread', '', $_GET, 'int');
|
|
|
$idLastMsg = V::get('idLastMsg', '', $_GET, 'int');
|
|
|
- if ($id <= 0) throw new Exception("Wrong param id!");
|
|
|
+ if ($idThread <= 0) throw new Exception("Wrong param id!");
|
|
|
|
|
|
$sqlLimit = 10;// TODO: 100?
|
|
|
$ds = DB::getDataSource();
|
|
|
$sql = "
|
|
|
select m.*
|
|
|
from `CRM_UI_MSGS` m
|
|
|
- where m.`idThread` = {$id}
|
|
|
+ where m.`idThread` = {$idThread}
|
|
|
and m.`ID` > {$idLastMsg}
|
|
|
+ order by m.`ID` asc
|
|
|
limit {$sqlLimit}
|
|
|
";
|
|
|
$moreMsgs = $ds->getListByQuery($sql);
|
|
|
@@ -982,7 +988,7 @@ function frmTestSubmit(frm) {
|
|
|
$response = new stdClass();
|
|
|
$response->msg = "Wysłano wiadomość";
|
|
|
$response->type = 'success';
|
|
|
- $response->record = $msgAdded;
|
|
|
+ $response->record = $this->_convertMessageToJson($msgAdded);
|
|
|
return $response;
|
|
|
}
|
|
|
|