Skip to content
Permalink
Browse files

affiliate code changes

  • Loading branch information...
danielkerr committed Jul 8, 2015
1 parent 0a42c05 commit a0ff7c6a072751358f67289f387632ce39811a26
@@ -1135,20 +1135,6 @@ public function transaction() {
$this->load->model('marketing/affiliate');
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->user->hasPermission('modify', 'marketing/affiliate')) {
$this->model_marketing_affiliate->addTransaction($this->request->get['affiliate_id'], $this->request->post['description'], $this->request->post['amount']);
$data['success'] = $this->language->get('text_success');
} else {
$data['success'] = '';
}
if (($this->request->server['REQUEST_METHOD'] == 'POST') && !$this->user->hasPermission('modify', 'marketing/affiliate')) {
$data['error_warning'] = $this->language->get('error_permission');
} else {
$data['error_warning'] = '';
}
$data['text_no_results'] = $this->language->get('text_no_results');
$data['text_balance'] = $this->language->get('text_balance');
@@ -1191,6 +1177,25 @@ public function transaction() {
$this->response->setOutput($this->load->view('marketing/affiliate_transaction.tpl', $data));
}
public function addTransaction() {
$this->load->language('marketing/affiliate');
$json = array();
if (!$this->user->hasPermission('modify', 'marketing/affiliate')) {
$json['error'] = $this->language->get('error_permission');
} else {
$this->load->model('marketing/affiliate');
$this->model_marketing_affiliate->addTransaction($this->request->get['affiliate_id'], $this->request->post['description'], $this->request->post['amount']);
$json['success'] = $this->language->get('text_success');
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
public function autocomplete() {
$affiliate_data = array();
@@ -387,23 +387,31 @@ $('#transaction').load('index.php?route=marketing/affiliate/transaction&token=<?
$('#button-transaction').on('click', function() {
$.ajax({
url: 'index.php?route=marketing/affiliate/transaction&token=<?php echo $token; ?>&affiliate_id=<?php echo $affiliate_id; ?>',
url: 'index.php?route=marketing/affiliate/addtransaction&token=<?php echo $token; ?>&affiliate_id=<?php echo $affiliate_id; ?>',
type: 'post',
dataType: 'html',
dataType: 'json',
data: 'description=' + encodeURIComponent($('#tab-transaction input[name=\'description\']').val()) + '&amount=' + encodeURIComponent($('#tab-transaction input[name=\'amount\']').val()),
beforeSend: function() {
$('#button-transaction').button('loading');
},
complete: function() {
$('#button-transaction').button('reset');
},
success: function(html) {
success: function(json) {
$('.alert').remove();
$('#transaction').html(html);
if (json['error']) {
$('#tab-transaction').prepend('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div></div>');
}
$('#tab-transaction input[name=\'amount\']').val('');
$('#tab-transaction input[name=\'description\']').val('');
if (json['success']) {
$('#tab-transaction').prepend('<div class="alert alert-success"><i class="fa fa-check-circle"></i> ' + json['success'] + ' <button type="button" class="close" data-dismiss="alert">&times;</button></div></div>');
$('#transaction').load('index.php?route=marketing/affiliate/transaction&token=<?php echo $token; ?>&affiliate_id=<?php echo $affiliate_id; ?>');
$('#tab-transaction input[name=\'amount\']').val('');
$('#tab-transaction input[name=\'description\']').val('');
}
}
});
});
@@ -1,13 +1,3 @@
<?php if ($error_warning) { ?>
<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> <?php echo $error_warning; ?>
<button type="button" class="close" data-dismiss="alert">&times;</button>
</div>
<?php } ?>
<?php if ($success) { ?>
<div class="alert alert-success"><i class="fa fa-check-circle"></i> <?php echo $success; ?>
<button type="button" class="close" data-dismiss="alert">&times;</button>
</div>
<?php } ?>
<div class="table-responsive">
<table class="table table-bordered table-hover">
<thead>

0 comments on commit a0ff7c6

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.