Skip to content

Commit

Permalink
Merge branch 'oml-2419-dev-al-trasferir-alertar-si-no-ha-guardado-con…
Browse files Browse the repository at this point in the history
…tacto' into 'develop'

[SAMU #5] Alertar al Agente durante transferencias a Campaña Entrante, si...

See merge request omnileads/ominicontacto!1232
  • Loading branch information
SrMoreno committed Jul 28, 2023
2 parents 14c39f8 + 358be2d commit f0a753b
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 5 deletions.
8 changes: 8 additions & 0 deletions notification_app/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class AgentNotifier:

TYPE_UNPAUSE = 'unpause'
TYPE_PAUSE = 'pause'
TYPE_CONTACT_SAVED = 'contact_saved'

def get_group_name(self, user_id=None):
if user_id is not None:
Expand Down Expand Up @@ -55,6 +56,13 @@ def notify_dispositioned(self, user_id, call_id, dispositioned):
}
self.send_message(self.TYPE_UNPAUSE, message, user_id=user_id)

def notify_contact_saved(self, user_id, call_id, contact_id):
message = {
"id": call_id,
"contact_id": contact_id
}
self.send_message(self.TYPE_CONTACT_SAVED, message, user_id=user_id)

def send_message(self, type, message, user_id=None):
# si user_id=None se envia mensaje a todos los agentes conectados
async_to_sync(get_channel_layer().group_send)(self.get_group_name(user_id), {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class NotificationSocket
this.eventsCallbacks = {
onNotificationForzarDespausa: $.Callbacks(),
onNotificationForzarPausa: $.Callbacks(),
onNotificationPhoneJsLogout: $.Callbacks()
onNotificationPhoneJsLogout: $.Callbacks(),
onNotificationContactSaved: $.Callbacks()
};
}

Expand All @@ -45,7 +46,8 @@ class NotificationSocket
self.eventsCallbacks.onNotificationForzarDespausa.fire(data.args);
if (data.type == 'logout')
self.eventsCallbacks.onNotificationPhoneJsLogout.fire();

if (data.type == 'contact_saved')
self.eventsCallbacks.onNotificationContactSaved.fire(data.args);
});

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,23 @@ class PhoneJSController {
alert(gettext('Seleccione una opción válida'));
}
else {
self.phone_fsm.dialTransfer();
self.phone.dialTransfer(transfer);
$('#numberToTransfer').val('');
if (self.phone.session_data.remote_call.id_contacto == '-1') {
$('#modalAlertContactSaved').modal('show');
$('#buttonContinueTransfer').click(function(){
$('#modalAlertContactSaved').modal('hide');
self.phone_fsm.dialTransfer();
self.phone.dialTransfer(transfer);
$('#numberToTransfer').val('');
});
$('#buttonCancelTransfer').click(function(){
$('#modalTransfer').modal('hide');
});
}
else {
self.phone_fsm.dialTransfer();
self.phone.dialTransfer(transfer);
$('#numberToTransfer').val('');
}
}
});

Expand Down Expand Up @@ -641,6 +655,11 @@ class PhoneJSController {
alert(message);

});
this.notification_agent.eventsCallbacks.onNotificationContactSaved.add(function(args){
if(self.phone.session_data){
self.phone.session_data.remote_call.id_contacto=args['contact_id'];
}
});

}

Expand Down
17 changes: 17 additions & 0 deletions ominicontacto_app/templates/agente/base_agente.html
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,23 @@ <h1 class="modal-title">
</div>
</div> <!-- fin modal info -->

<div id="modalAlertContactSaved" class="modal fade bs-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm" style="max-width:400px">
<div class="modal-content">
<div class="modal-body">
<h2 class="modal-title">{% trans 'Los datos del contacto que está por transferir no han sido guardados. ¿Desea continuar?' %}</h2>
</div>
<div class="modal-footer">
<button type="button" id="buttonCancelTransfer" class="btn btn-primary" data-dismiss="modal">
{% trans 'No' %}
</button>
<button type="button" id="buttonContinueTransfer" class="btn btn-default">
{% trans 'Si' %}
</button>
</div>
</div>
</div>
</div>
<!-- Contendio -->
<div class="wrapper-main">
<nav id="navBar">
Expand Down
3 changes: 3 additions & 0 deletions ominicontacto_app/views_calificacion_cliente.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
from configuracion_telefonia_app.models import DestinoEntrante

from reportes_app.models import LlamadaLog
from notification_app.notification import AgentNotifier


logger = logging_.getLogger(__name__)
Expand Down Expand Up @@ -473,6 +474,8 @@ def form_valid(self, contacto_form, calificacion_form=None):
llamadalog = LlamadaLog.objects.filter(callid=self.call_data['call_id'])
if llamadalog:
llamadalog.update(contacto_id=self.contacto.id)
AgentNotifier().notify_contact_saved(
self.agente.user_id, self.call_data['call_id'], self.contacto.id)

# TODO: Pasar esto dentro de _calificar_form() ?
if not calificacion_form or not calificacion_form.instance.es_gestion():
Expand Down

0 comments on commit f0a753b

Please sign in to comment.