differentiate customers, drivers, reps in support system #2720 - option to make calls

This commit is contained in:
Daniel Camargo 2014-04-09 15:57:34 -03:00
parent 8d327c3de4
commit b25fbbffe7
11 changed files with 128 additions and 38 deletions

View File

@ -19,6 +19,11 @@ class Controller_Support extends Crunchbutton_Controller_Account {
c::view()->display('support/new-chat');
break;
case 'make-call':
c::view()->layout('layout/ajax');
c::view()->display('support/make-call');
break;
case 'new':
if ( !Crunchbutton_Support::adminHasCreatePermission() ) {

View File

@ -4,7 +4,6 @@ class Controller_Support_Phone_Connect extends Crunchbutton_Controller_Account {
public function init() {
switch (c::getPagePiece(3)) {
case 'restaurant':
$callerId = c::config()->twilio->live->outgoingRestaurant;
@ -14,11 +13,10 @@ class Controller_Support_Phone_Connect extends Crunchbutton_Controller_Account {
break;
case 'customer':
default:
$callerId = c::config()->twilio->live->outgoingcustomer;
$callerId = c::config()->twilio->live->outgoingCustomer;
break;
}
$num = c::admin()->phone;
$host = 'dev.crunchr.co';
//c::config()->host_callback
@ -29,17 +27,8 @@ class Controller_Support_Phone_Connect extends Crunchbutton_Controller_Account {
'+1'.$num,
'http://'.$host.'/api/twilio/outgoing/'.c::getPagePiece(3).'?PhoneNumber='.$_REQUEST['phone']
);
die('pick up your phone...');
exit;
}
}

View File

@ -431,7 +431,9 @@ class Crunchbutton_Community_Shift extends Cana_Table {
$twilio = new Twilio( c::config()->twilio->{$env}->sid, c::config()->twilio->{$env}->token );
if( count( $communitiesWithoutShift ) > 0 ){
// removed this sms for while
if( false && count( $communitiesWithoutShift ) > 0 ){
$message = "The following communities doesn't have shifts for the current week: " . join( ', ', $communitiesWithoutShift );

View File

@ -33,6 +33,9 @@
<i class="icon-eye-open"></i> View ticket
</a>
</li>
<li>
<a href="javascript:makeCall.direct( 'customer', '<?php echo $this->support->phone; ?>' );" target="_blank"><i class="icon-phone"></i> Call Customer</a>
</li>
</ul>
</li>
</ul>

View File

@ -11,7 +11,7 @@
<div class="table-header">
<div class="row-fluid">
<div class="span2">
<br/>
<div class="btn-group">
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">Status: <?php echo $this->status; ?> <span class="caret"></span></button>
@ -21,9 +21,8 @@
<li><a href="#" onclick="load('/support/content?autoRefresh=<?php echo $this->autoRefresh; ?>&type=<?php echo $this->type; ?>&status=closed')">Closed</a></li>
</ul>
</div>
</div>
<div class="span2">
<br/>
&nbsp;&nbsp;&nbsp;
<div class="btn-group">
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">Type: <?php echo $this->type; ?> <span class="caret"></span></button>
<ul class="dropdown-menu">
@ -33,13 +32,8 @@
<li><a href="#" onclick="load('/support/content?autoRefresh=<?php echo $this->autoRefresh; ?>&status=<?php echo $this->status; ?>&type=warning')">Warning</a></li>
</ul>
</div>
</div>
<div class="span2">
<br/>
<button class="send-sms-button btn btn-green"><i class="icon-mobile-phone"></i>&nbsp;Send SMS</button>
</div>
<div class="span2">
<br/>
&nbsp;&nbsp;&nbsp;
<div class="btn-group">
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">Auto refresh: <?php echo $this->autoRefresh; ?> <span class="caret"></span></button>
<ul class="dropdown-menu">
@ -47,18 +41,20 @@
<li><a href="#" onclick="load('/support/content?type=<?php echo $this->type; ?>&autoRefresh=off&status=open')">Off</a></li>
</ul>
</div>
</div>
<div class="span2">
<br/>
&nbsp;&nbsp;&nbsp;
<button onclick="load('/support/content?autoRefresh=<?php echo $this->autoRefresh; ?>&type=<?php echo $this->type ?>&status=<?php echo $this->status ?>&page=<?php echo $this->page; ?>')" class="btn btn-default"><i class="icon-refresh"></i> Refresh</button>
</div>
<div class="span2" style="text-align:right;">
<br/>
<div style="height:25px">
<span id="warning-loaded" style="display:none;" class="label label-blue"><i class="icon-ok-sign"></i> Loaded</span>
</div>
&nbsp;&nbsp;&nbsp;
<button class="send-sms-button btn btn-blue"><i class="icon-comment-alt"></i>&nbsp;Send SMS</button>
&nbsp;&nbsp;&nbsp;
<button class="make-call-button btn btn-green"><i class="icon-phone"></i>&nbsp;Make a call</button>
&nbsp;&nbsp;&nbsp;
<span id="auto-refresh-timer" style="display:none;" ><i class="icon-clock"></i> Refresh in <span id="auto-refresh-timer-counter"></span></span>
</div>
&nbsp;&nbsp;&nbsp;
<span id="warning-loaded" style="display:none;" class="label label-blue"><i class="icon-ok-sign"></i> Loaded</span>
</div>
</div>
<?php
@ -229,6 +225,16 @@ $( document ).ready( function(){
e.preventDefault();
var url = '/support/new-chat';
$.get( url, function( data ) {
$( '#modal-sms-title' ).html( 'Send SMS' );
$( '#modal-sms' ).modal();
$( '#modal-sms-body' ).html( data );
} );
} );
$( '.make-call-button' ).click( function(e) {
e.preventDefault();
var url = '/support/make-call';
$.get( url, function( data ) {
$( '#modal-sms-title' ).html( 'Make a call' );
$( '#modal-sms' ).modal();
$( '#modal-sms-body' ).html( data );
} );

View File

@ -10,6 +10,9 @@
<textarea name="text-conversation-reply" id="text-conversation-reply" placeholder="Reply to customer" class="span12"></textarea>
<br/>
<button class="btn btn-blue btn-conversation-reply"><i class="icon-mobile-phone"></i> Reply to Customer</button>
&nbsp;&nbsp;&nbsp;&nbsp;
<button onclick="makeCall.direct( 'customer', '<?php echo $this->support->phone; ?>' );" target="_blank" class="btn btn-green"><i class="icon-phone"></i> Call Customer <?php echo Crunchbutton_Util::format_phone( $this->support->phone ); ?></button>
</div>
<?php } ?>
</div>

View File

@ -45,7 +45,7 @@
<div class="modal hide fade" id="modal-sms" style="display: none;">
<div class="modal-header">
<button class="close" data-dismiss="modal" type="button">×</button>
<h6>Send SMS</h6>
<h6 id="modal-sms-title"></h6>
</div>
<div class="modal-body" id="modal-sms-body"></div>
<div class="modal-footer">

View File

@ -0,0 +1,45 @@
<div class="row-fluid">
<div class="container-fluid">
<div class="row-fluid">
<div class="span12">
<form>
<div class="row-fluid">
<div class="span12">
<div class="span3">
<strong>Phone</strong>
</div>
<div class="span7">
<input type="text" name="form-make-call-phone" id="form-make-call-phone"/>
<br/><br/>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<div class="span3">
<strong>Are you calling to</strong>
</div>
<div class="span7">
<select id="form-make-call-to" name="form-make-call-to">
<option value="customer">customer</option>
<option value="driver">driver</option>
<option value="restaurant">restaurant</option>
</select>
<br/><br/>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span12">
<div class="span3"></div>
<div class="span7">
<i class="icon-spinner icon-spin form-make-call-spin" style="display:none;"></i>
<button type="button" onclick="makeCall.start();" class="form-make-call-button btn btn-green"><i class="icon-phone"></i>&nbsp;Call </button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>

View File

@ -41,7 +41,7 @@
<div class="span3"></div>
<div class="span7">
<i class="icon-spinner icon-spin form-start-chat-spin" style="display:none;"></i>
<button type="button" onclick="startChat.send();" class="form-start-chat-button btn btn-green"><i class="icon-mobile-phone"></i>&nbsp;Send </button>
<button type="button" onclick="startChat.send();" class="form-start-chat-button btn btn-blue"><i class="icon-mobile-phone"></i>&nbsp;Send </button>
</div>
</div>
</div>

View File

@ -337,4 +337,5 @@ function linkOrder(){
background: #F5F5F5;
border: 1px solid #CCC;
}
</style>
</style>
<script type="text/javascript" src="/assets/js/admin.support.js?v=<?php echo Cana_Util::gitVersion()?>"></script>

View File

@ -277,6 +277,42 @@ startChat.send = function(){
$( '#modal-sms' ).modal( 'hide' );
alert( 'Oops, error! ' + data.error );
}
} );
} );
}
var makeCall = {};
makeCall.start = function(){
var phone = $( '#form-make-call-phone' ).val();
if( $.trim( phone ) == '' ){
alert( 'Please type a phone!' );
$( '#form-make-call-phone' ).focus();
return;
}
if( !App.phone.validate( phone ) ){
alert( 'Please type a valid phone!' );
$( '#form-make-call-phone' ).focus();
return;
}
var callto = $( '#form-make-call-to' ).val();
$( '.form-make-call-spin' ).show();
$( '.form-make-call-button' ).hide();
$.ajax( {
url: '/support/phone/connect/' + callto + '?phone=' + phone
} ).done( function( data ) {
alert( data );
$( '#modal-sms' ).modal( 'hide' );
} );
}
makeCall.direct = function( callto, phone ){
$.ajax( {
url: '/support/phone/connect/' + callto + '?phone=' + phone
} ).done( function( data ) {
alert( data );
} );
}