This commit is contained in:
Daniel Camargo 2013-08-13 14:19:28 -03:00
parent 2c8c058d04
commit 166b6d3fa8
3 changed files with 27 additions and 7 deletions

View File

@ -148,6 +148,7 @@ class Controller_api_restaurant extends Crunchbutton_Controller_Rest {
if ($r->id_restaurant) {
$r->balanced_id = c::config()->balanced->sharedMerchant;
$r->save();
echo json_encode( [ 'success' => 'success' ] );
}
break;
@ -155,6 +156,7 @@ class Controller_api_restaurant extends Crunchbutton_Controller_Rest {
if ($r->id_restaurant) {
$r->balanced_id = null;
$r->save();
echo json_encode( [ 'success' => 'success' ] );
}
break;
@ -162,6 +164,7 @@ class Controller_api_restaurant extends Crunchbutton_Controller_Rest {
if ($r->id_restaurant) {
$r->balanced_bank = null;
$r->save();
echo json_encode( [ 'success' => 'success' ] );
}
break;

View File

@ -271,6 +271,7 @@ class Crunchbutton_Restaurant extends Cana_Table_Trackchange {
$info = $this->merchant()->addBankAccount($bank);
$this->balanced_bank = $bank->id;
$this->save();
echo json_encode( [ 'success' => 'success' ] );
} catch (Exception $e) {
print_r($e);
exit;

View File

@ -52,6 +52,7 @@
<td colspan="2">
<br />
<button type="submit" class="btn btn-blue restaurant-bank-info-button"><i class="icon-save"></i>&nbsp;&nbsp;&nbsp; Save </button>
&nbsp;&nbsp;&nbsp;<i class="restaurant-bank-info-button-loading icon-spinner icon-spin" style="display:none;"></i>
</td>
</tr>
</table>
@ -369,13 +370,28 @@
$('.restaurant-bank-info-button').click(function() {
var form = $(this).closest('form');
$.post('/api/restaurant/<?=$this->restaurant->id_restaurant?>/bankinfo', {
routing: form.find('[name="routing"]').val(),
account: form.find('[name="account"]').val(),
type: form.find('[name="type"]').val(),
name: form.find('[name="name"]').val()
}, function() {
location.href = location.href;
$( '.restaurant-bank-info-button-loading' ).show();
$.ajax({
type: 'POST',
url: '/api/restaurant/<?=$this->restaurant->id_restaurant?>/bankinfo',
data: {
routing: form.find('[name="routing"]').val(),
account: form.find('[name="account"]').val(),
type: form.find('[name="type"]').val(),
name: form.find('[name="name"]').val()
}
}).done(function( data ) {
if( data.success ){
location.href = location.href;
} else {
$( '.restaurant-bank-info-button-loading' ).hide();
alert( 'Error: see the console!' );
console.log('Err:', data );
}
}).fail(function(jqXHR, textStatus) {
$( '.restaurant-bank-info-button-loading' ).hide();
alert( 'Error: see the console!' );
console.log('Err:', jqXHR.responseText);
});
});