Skip to content

Commit 2488a5e

Browse files
committed
2 parents 7eb78f6 + dc5f9d3 commit 2488a5e

File tree

11 files changed

+769
-721
lines changed

11 files changed

+769
-721
lines changed

Block/Adminhtml/Chat/Edit/Tab/Customer.php

Lines changed: 47 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
<?php
22
/**
33
* Venustheme
4-
*
4+
*
55
* NOTICE OF LICENSE
6-
*
6+
*
77
* This source file is subject to the Venustheme.com license that is
88
* available through the world-wide-web at this URL:
99
* http://www.venustheme.com/license-agreement.html
10-
*
10+
*
1111
* DISCLAIMER
12-
*
12+
*
1313
* Do not edit or add to this file if you wish to upgrade this extension to newer
1414
* version in the future.
15-
*
15+
*
1616
* @category Venustheme
1717
* @package Lof_ChatSystem
1818
* @copyright Copyright (c) 2018 Venustheme (http://www.venustheme.com/)
1919
* @license http://www.venustheme.com/LICENSE-1.0.html
2020
*/
21+
2122
namespace Lof\ChatSystem\Block\Adminhtml\Chat\Edit\Tab;
2223

2324

2425
use Magento\Framework\UrlInterface;
26+
2527
/**
2628
* @SuppressWarnings(PHPMD.DepthOfInheritance)
2729
*/
@@ -37,14 +39,15 @@ class Customer extends \Magento\Backend\Block\Widget\Form\Generic implements
3739
protected $order;
3840

3941
protected $orderRepository;
42+
4043
/**
41-
* @param \Magento\Backend\Block\Template\Context $context
42-
* @param \Magento\Framework\Registry $registry
43-
* @param \Magento\Framework\Data\FormFactory $formFactory
44-
* @param \Magento\Theme\Model\Layout\Source\Layout $pageLayout
45-
* @param \Magento\Framework\View\Customer Information\Theme\LabelFactory $labelFactory
46-
* @param \Magento\Framework\View\Model\PageLayout\Config\BuilderInterface $pageLayoutBuilder
47-
* @param array $data
44+
* @param \Magento\Backend\Block\Template\Context $context
45+
* @param \Magento\Framework\Registry $registry
46+
* @param \Magento\Framework\Data\FormFactory $formFactory
47+
* @param \Magento\Theme\Model\Layout\Source\Layout $pageLayout
48+
* @param \Magento\Framework\View\Customer Information\Theme\LabelFactory $labelFactory
49+
* @param \Magento\Framework\View\Model\PageLayout\Config\BuilderInterface $pageLayoutBuilder
50+
* @param array $data
4851
*/
4952
public function __construct(
5053
\Magento\Backend\Block\Template\Context $context,
@@ -93,40 +96,43 @@ protected function _prepareForm()
9396
'base_fieldset',
9497
['legend' => __('Customer Information'), 'class' => 'fieldset-wide', 'disabled' => $isElementDisabled]
9598
);
96-
$fieldset->addField(
97-
'customer_name',
98-
'note',
99-
[
100-
'name' => 'customer_name',
101-
'label' => __('Customer Name'),
102-
'title' => __('Customer Name'),
103-
'text' => $model->getCustomerName()
104-
]
99+
$fieldset->addField(
100+
'customer_name',
101+
'note',
102+
[
103+
'name' => 'customer_name',
104+
'label' => __('Customer Name'),
105+
'title' => __('Customer Name'),
106+
'text' => $model->getCustomerName() ?: __('Guest')
107+
]
105108
);
106-
$fieldset->addField(
107-
'customer_email',
108-
'note',
109-
[
110-
'name' => 'customer_email',
111-
'label' => __('Customer Email'),
112-
'title' => __('Customer Email'),
113-
'text' => "<a href='".$this->urlBuilder->getUrl('customer/index/edit', ['id' => $model->getCustomerId()])."' target='blank' title='".__('View Customer')."'>".$model->getCustomerEmail().'</a>'
114-
]
109+
$fieldset->addField(
110+
'customer_email',
111+
'note',
112+
[
113+
'name' => 'customer_email',
114+
'label' => __('Customer Email'),
115+
'title' => __('Customer Email'),
116+
'text' => $model->getCustomerEmail() ? "<a href='" . $this->urlBuilder->getUrl('customer/index/edit',
117+
['id' => $model->getCustomerId()]) . "' target='blank' title='" . __('View Customer') . "'>" . $model->getCustomerEmail() . '</a>' : __('Guest')
118+
]
115119
);
116-
117-
$order_id = $this->order->getCollection()->addFieldToFilter('customer_id',$model->getCustomerId())->getLastItem()->getId();
118-
if($order_id) {
120+
121+
$order_id = $this->order->getCollection()->addFieldToFilter('customer_id',
122+
$model->getCustomerId())->getLastItem()->getId();
123+
if ($order_id) {
119124
$order = $this->orderRepository->get($order_id);
120125
$orderIncrementId = $order->getIncrementId();
121126
$fieldset->addField(
122-
'last_order',
123-
'note',
124-
[
125-
'name' => 'last_order',
126-
'label' => __('Last Order'),
127-
'title' => __('Last Order'),
128-
'text' => "<a href='".$this->urlBuilder->getUrl('sales/order/view/order_id', ['id' => $order_id])."' target='blank' title='".__('View Order')."'>".$orderIncrementId.'</a>'
129-
]
127+
'last_order',
128+
'note',
129+
[
130+
'name' => 'last_order',
131+
'label' => __('Last Order'),
132+
'title' => __('Last Order'),
133+
'text' => "<a href='" . $this->urlBuilder->getUrl('sales/order/view/order_id',
134+
['id' => $order_id]) . "' target='blank' title='" . __('View Order') . "'>" . $orderIncrementId . '</a>'
135+
]
130136
);
131137
}
132138
$form->setValues($model->getData());
Lines changed: 94 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,79 +1,94 @@
1-
<?php
2-
$this->isRead();
3-
$helper = $this->helper("Lof\ChatSystem\Helper\Data");
4-
$current_url = $this->getCurrentChat()->getData('current_url');
5-
?>
6-
<p><?php echo __('Chat message sent on').' '.($current_url?('<a href="'.$current_url.'" target="_BLANK">'.$current_url.'</a>'):"");?></p>
7-
<input type="hidden" name="chat_id" value="<?php echo $this->getCurrentChat()->getData('chat_id');?>">
8-
<div class="main-chat" id="main-chat">
9-
</div>
10-
<div class="box-chat">
11-
<form method="post" id="formSendMsg" onsubmit="return false;">
12-
<input type="hidden" name="form_key" value="<?php echo $this->getFormKey(); ?>">
13-
<input type="hidden" name="chat_id" value="<?php echo $this->getCurrentChat()->getData('chat_id');?>">
14-
<input type="hidden" name="user_id" value="<?php echo $this->getUser()->getData('user_id');?>">
15-
<input type="hidden" name="customer_id" value="<?php echo $this->getCurrentChat()->getData('customer_id');?>">
16-
<input type="hidden" name="user_name" value="<?php echo $this->getUser()->getData('firstname').' '.$this->getUser()->getData('lastname');?>">
17-
<input type="hidden" name="customer_name" value="<?php echo $this->getCurrentChat()->getData('customer_name');?>">
18-
<input type="hidden" name="customer_email" value="<?php echo $this->getCurrentChat()->getData('customer_email');?>">
19-
<input type="text" name="body_msg" placeholder="<?php echo __('Please enter a message'); ?> ...">
20-
</form>
21-
</div>
22-
23-
<script type="text/javascript">
24-
require([
25-
'jquery'
26-
], function($){
27-
28-
function sendMsg() {
29-
$body_msg = $('#formSendMsg input[name="body_msg"]').val();
30-
$chat_id = $('#formSendMsg input[name="chat_id"]').val();
31-
$customer_id = $('#formSendMsg input[name="customer_id"]').val();
32-
$user_id = $('#formSendMsg input[name="user_id"]').val();
33-
$user_name = $('#formSendMsg input[name="user_name"]').val();
34-
$customer_name = $('#formSendMsg input[name="customer_name"]').val();
35-
$customer_email = $('#formSendMsg input[name="customer_email"]').val();
36-
if($.trim($body_msg)) {
37-
$('#formSendMsg input[type="text"]').val('');
38-
$('.main-chat').append('<div class="msg-user"><p>'+$body_msg+'</p><div class="info-msg-user"><?php echo __("You");?></div></div>');
39-
$.ajax({
40-
url : '<?php echo $this->getUrl('lofchatsystem/chat/sendmsg'); ?>',
41-
type : 'post',
42-
dataType: 'json',
43-
data : {
44-
body_msg : $body_msg,
45-
chat_id : $chat_id,
46-
customer_id : $customer_id,
47-
user_id : $user_id,
48-
customer_name : $customer_name,
49-
customer_email : $customer_email,
50-
user_name: $user_name
51-
52-
}, success : function() {
53-
$('#formSendMsg input[type="text"]').val('');
54-
var div = document.getElementById('main-chat')
55-
div.scrollTop = div.scrollHeight - div.clientHeight;
56-
57-
}
58-
});
59-
}
60-
}
61-
62-
$('#formSendMsg input[type="text"]').keypress(function() {
63-
var keycode = (event.keyCode ? event.keyCode : event.which);
64-
if (keycode == '13') {
65-
sendMsg();
66-
var div = document.getElementById('main-chat')
67-
div.scrollTop = div.scrollHeight - div.clientHeight;
68-
}
69-
});
70-
71-
$('#formSendMsg input[type="text"]').click(function(e) {
72-
var div = document.getElementById('main-chat')
73-
div.scrollTop = div.scrollHeight - div.clientHeight;
74-
});
75-
$('.main-chat').load('<?php echo $this->getUrl('lofchatsystem/chat/msglog/chat_id/'.$this->getCurrentChat()->getData('chat_id')); ?>');
76-
$.ajaxSetup({cache:false});
77-
setInterval(function() {$('.main-chat').load('<?php echo $this->getUrl('lofchatsystem/chat/msglog/chat_id/'.$this->getCurrentChat()->getData('chat_id')); ?>'); }, 5000);
78-
});
79-
</script>
1+
<?php
2+
/**
3+
* @var $block \Lof\ChatSystem\Block\Adminhtml\Chat\Edit\Tab\Main
4+
*/
5+
$this->isRead();
6+
$helper = $this->helper("Lof\ChatSystem\Helper\Data");
7+
$current_url = $block->escapeUrl($this->getCurrentChat()->getData('current_url'));
8+
?>
9+
<p><?= __('Chat message sent on') . ' ' . ($current_url ? ('<a href="' . $current_url . '" target="_BLANK">' . $current_url . '</a>') : ""); ?></p>
10+
<input type="hidden" name="chat_id" value="<?= $this->getCurrentChat()->getData('chat_id'); ?>">
11+
<div class="main-chat" id="main-chat">
12+
</div>
13+
<div class="box-chat">
14+
<form method="post" id="formSendMsg" onsubmit="return false;">
15+
<input type="hidden" name="form_key" value="<?= $block->escapeHtmlAttr($this->getFormKey()); ?>">
16+
<input type="hidden" name="chat_id" value="<?= $block->escapeHtmlAttr($this->getCurrentChat()->getData('chat_id')); ?>">
17+
<input type="hidden" name="user_id" value="<?= $block->escapeHtmlAttr($this->getUser()->getData('user_id')); ?>">
18+
<input type="hidden" name="customer_id" value="<?= $block->escapeHtmlAttr($this->getCurrentChat()->getData('customer_id')); ?>">
19+
<input type="hidden" name="user_name"
20+
value="<?= $block->escapeHtmlAttr($this->getUser()->getData('firstname') . ' ' . $this->getUser()->getData('lastname')); ?>">
21+
<input type="hidden" name="customer_name" value="<?= $block->escapeHtmlAttr($this->getCurrentChat()->getData('customer_name')); ?>">
22+
<input type="hidden" name="customer_email" value="<?= $block->escapeHtmlAttr($this->getCurrentChat()->getData('customer_email')); ?>">
23+
<input type="text" name="body_msg" placeholder="<?= __('Please enter a message'); ?> ...">
24+
</form>
25+
</div>
26+
27+
<script type="text/javascript">
28+
require([
29+
'jquery'
30+
], function ($) {
31+
32+
function sendMsg() {
33+
$body_msg = lofescapeHtml($('#formSendMsg input[name="body_msg"]').val());
34+
$chat_id = lofescapeHtml($('#formSendMsg input[name="chat_id"]').val());
35+
$customer_id = lofescapeHtml($('#formSendMsg input[name="customer_id"]').val());
36+
$user_id = lofescapeHtml($('#formSendMsg input[name="user_id"]').val());
37+
$user_name = lofescapeHtml($('#formSendMsg input[name="user_name"]').val());
38+
$customer_name = lofescapeHtml($('#formSendMsg input[name="customer_name"]').val());
39+
$customer_email = lofescapeHtml($('#formSendMsg input[name="customer_email"]').val());
40+
if ($.trim($body_msg)) {
41+
$('#formSendMsg input[type="text"]').val('');
42+
$('.main-chat').append('<div class="msg-user"><p>' + $body_msg + '</p><div class="info-msg-user"><?= __("You");?></div></div>');
43+
$.ajax({
44+
url: '<?= $this->getUrl('lofchatsystem/chat/sendmsg'); ?>',
45+
type: 'post',
46+
dataType: 'json',
47+
data: {
48+
body_msg: $body_msg,
49+
chat_id: $chat_id,
50+
customer_id: $customer_id,
51+
user_id: $user_id,
52+
customer_name: $customer_name,
53+
customer_email: $customer_email,
54+
user_name: $user_name
55+
56+
}, success: function () {
57+
$('#formSendMsg input[type="text"]').val('');
58+
var div = document.getElementById('main-chat')
59+
div.scrollTop = div.scrollHeight - div.clientHeight;
60+
}
61+
});
62+
}
63+
}
64+
65+
function lofescapeHtml(unsafe) {
66+
return unsafe
67+
.replace(/&/g, "&amp;")
68+
.replace(/</g, "&lt;")
69+
.replace(/>/g, "&gt;")
70+
.replace(/"/g, "&quot;")
71+
.replace(/'/g, "&#039;");
72+
}
73+
74+
$('#formSendMsg input[type="text"]').keypress(function () {
75+
var keycode = (event.keyCode ? event.keyCode : event.which);
76+
if (keycode == '13') {
77+
sendMsg();
78+
var div = document.getElementById('main-chat')
79+
div.scrollTop = div.scrollHeight - div.clientHeight;
80+
}
81+
});
82+
83+
$('#formSendMsg input[type="text"]').click(function (e) {
84+
var div = document.getElementById('main-chat')
85+
div.scrollTop = div.scrollHeight - div.clientHeight;
86+
});
87+
88+
$('.main-chat').load('<?= $this->getUrl('lofchatsystem/chat/msglog/chat_id/' . $this->getCurrentChat()->getData('chat_id')); ?>');
89+
$.ajaxSetup({cache: false});
90+
setInterval(function () {
91+
$('.main-chat').load('<?= $this->getUrl('lofchatsystem/chat/msglog/chat_id/' . $this->getCurrentChat()->getData('chat_id')); ?>');
92+
}, 5000);
93+
});
94+
</script>
Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
<?php
2-
/**
3-
* Landofcoder
4-
*
5-
* NOTICE OF LICENSE
6-
*
7-
* This source file is subject to the Landofcoder EULA that is bundled with
8-
* this package in the file LICENSE.txt.
9-
* It is also available through the world-wide-web at this URL:
10-
* http://www.landofcoder.com/LICENSE-1.0.html
11-
*
12-
* DISCLAIMER
13-
*
14-
* Do not edit or add to this file if you wish to upgrade the extension
15-
* to newer versions in the future. If you wish to customize the extension
16-
* for your needs please refer to http://www.landofcoder.com/ for more information
17-
*
18-
* @category Lof
19-
* @package Lof_ChatSystem
20-
* @copyright Copyright (c) 2016 Landofcoder (http://www.landofcoder.com/)
21-
* @license http://www.landofcoder.com/LICENSE-1.0.html
22-
*/
23-
24-
/**
25-
* Form Builder extension
26-
*
27-
* @category Lof
28-
* @package Lof_ChatSystem
29-
* @author Landofcoder Dev Team <landofcoder@gmail.com>
30-
*/
31-
?>
32-
<div class="landofcoder-fue-menu">
33-
<div class="actions dropdown closable">
34-
<button type="button" class="admin__action-dropdown" data-mage-init='{"dropdown":{}}' data-toggle="dropdown" aria-haspopup="true">
35-
<span class="admin__action-dropdown-text"><?php echo $block->getCurrentItem()['title'] ?></span>
36-
</button>
37-
<ul class="dropdown-menu">
38-
<?php foreach ($block->getMenuItems() as $index => $item): ?>
39-
<li class="<?php if ($block->isCurrent($index)): ?>current<?php endif; ?> <?php if (isset($item['separator'])): ?>separator<?php endif; ?>" >
40-
<a <?php if(isset($item['item'])){ echo 'class="lof-dropdown"'; } ?> href="<?php echo $item['url'] ?>" <?php echo $block->renderAttributes($item) ?>><?php echo $item['title'] ?><?php if(isset($item['item'])){ echo '<span class="opener" ></span>'; } ?></a>
41-
</li>
42-
<?php endforeach; ?>
43-
</ul>
44-
</div>
45-
</div>
1+
<?php
2+
/**
3+
* Landofcoder
4+
*
5+
* NOTICE OF LICENSE
6+
*
7+
* This source file is subject to the Landofcoder EULA that is bundled with
8+
* this package in the file LICENSE.txt.
9+
* It is also available through the world-wide-web at this URL:
10+
* http://www.landofcoder.com/LICENSE-1.0.html
11+
*
12+
* DISCLAIMER
13+
*
14+
* Do not edit or add to this file if you wish to upgrade the extension
15+
* to newer versions in the future. If you wish to customize the extension
16+
* for your needs please refer to http://www.landofcoder.com/ for more information
17+
*
18+
* @category Lof
19+
* @package Lof_ChatSystem
20+
* @copyright Copyright (c) 2016 Landofcoder (http://www.landofcoder.com/)
21+
* @license http://www.landofcoder.com/LICENSE-1.0.html
22+
*/
23+
24+
/**
25+
* Form Builder extension
26+
*
27+
* @category Lof
28+
* @package Lof_ChatSystem
29+
* @author Landofcoder Dev Team <landofcoder@gmail.com>
30+
*/
31+
?>
32+
<div class="landofcoder-fue-menu">
33+
<div class="actions dropdown closable">
34+
<button type="button" class="admin__action-dropdown" data-mage-init='{"dropdown":{}}' data-toggle="dropdown" aria-haspopup="true">
35+
<span class="admin__action-dropdown-text"><?= $block->getCurrentItem()['title'] ?></span>
36+
</button>
37+
<ul class="dropdown-menu">
38+
<?php foreach ($block->getMenuItems() as $index => $item): ?>
39+
<li class="<?php if ($block->isCurrent($index)): ?>current<?php endif; ?> <?php if (isset($item['separator'])): ?>separator<?php endif; ?>" >
40+
<a <?php if(isset($item['item'])){ echo 'class="lof-dropdown"'; } ?> href="<?= $item['url'] ?>" <?= $block->renderAttributes($item) ?>><?= $item['title'] ?><?php if(isset($item['item'])){ echo '<span class="opener" ></span>'; } ?></a>
41+
</li>
42+
<?php endforeach; ?>
43+
</ul>
44+
</div>
45+
</div>

0 commit comments

Comments
 (0)