mirror of
https://git.yylx.win/https://github.com/strangerstudios/PMProFreescout.git
synced 2025-10-03 18:01:27 +08:00
AJAX load the PMPro module when creating a new conversation.
This commit is contained in:
parent
9f22753b2f
commit
0eb31fb154
2 changed files with 27 additions and 4 deletions
|
@ -103,9 +103,9 @@ class PmproFreescoutServiceProvider extends ServiceProvider
|
|||
"error" => []
|
||||
];
|
||||
|
||||
$customer_email = $customer->getMainEmail();
|
||||
|
||||
if (!$customer_email) {
|
||||
// Get the customer email from the customer or conversation object.
|
||||
$customer_email = $customer->getMainEmail() ?? $conversation->mailbox->email;
|
||||
if ( empty( $customer_email ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,28 @@ function initPMPro(customer_email, load) {
|
|||
pmproLoadOrders();
|
||||
}
|
||||
|
||||
// If the $to is changed, let's try display things?
|
||||
$("#to").on('change', function(e) {
|
||||
|
||||
// Hook into the default customer AJAX event from freescout to squeeze it in.
|
||||
fsAjax({
|
||||
action: 'load_customer_info',
|
||||
customer_email: $(this).val(),
|
||||
mailbox_id: getGlobalAttr('mailbox_id'),
|
||||
conversation_id: getGlobalAttr('conversation_id')
|
||||
}, laroute.route('conversations.ajax'), function(response) {
|
||||
if (isAjaxSuccess(response) && typeof(response.html) != "undefined") {
|
||||
// Create an empty div now, generate the content, then move it later.
|
||||
$('.footer').append('<div id="pmpro-temp-customer-info" style="display:none;"><div id="pmpro-orders" class="pmpro-orders"></div></div>');
|
||||
pmproLoadOrders();
|
||||
$('#pmpro-temp-customer-info').insertAfter($('.conv-sidebar-block').last()).removeAttr('style');
|
||||
|
||||
}
|
||||
}, true, function() {
|
||||
// Do nothing
|
||||
});
|
||||
});
|
||||
|
||||
$('.pmpro-refresh').click(function(e) {
|
||||
pmproLoadOrders();
|
||||
e.preventDefault();
|
||||
|
@ -23,7 +45,7 @@ function initPMPro(customer_email, load) {
|
|||
function pmproLoadOrders()
|
||||
{
|
||||
$('#pmpro-orders').addClass('pmpro-loading');
|
||||
|
||||
|
||||
fsAjax({
|
||||
action: 'orders',
|
||||
customer_email: pmpro_customer_email,
|
||||
|
@ -31,6 +53,7 @@ function initPMPro(customer_email, load) {
|
|||
},
|
||||
laroute.route('pmpro.ajax'),
|
||||
function(response) {
|
||||
|
||||
if (typeof(response.status) != "undefined" && response.status == 'success'
|
||||
&& typeof(response.html) != "undefined" && response.html
|
||||
) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue