Ta, vai precisar de mais coisas para funcionar.
Em
admin/controller/sale/customer.php procure por:
E adicione antes:
Código: Selecionar todos public function deleteTransaction() {
$this->language->load('sale/customer');
$this->load->model('sale/customer');
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->user->hasPermission('modify', 'sale/customer')) {
$this->model_sale_customer->trueDeleteTransaction($this->request->post['id']);
$this->data['success'] = $this->language->get('text_success');
} else {
$this->data['success'] = '';
}
if (($this->request->server['REQUEST_METHOD'] == 'POST') && !$this->user->hasPermission('modify', 'sale/customer')) {
$this->data['error_warning'] = $this->language->get('error_permission');
} else {
$this->data['error_warning'] = '';
}
$this->data['text_no_results'] = $this->language->get('text_no_results');
$this->data['text_balance'] = $this->language->get('text_balance');
$this->data['column_date_added'] = $this->language->get('column_date_added');
$this->data['column_description'] = $this->language->get('column_description');
$this->data['column_amount'] = $this->language->get('column_amount');
if (isset($this->request->get['page'])) {
$page = $this->request->get['page'];
} else {
$page = 1;
}
$this->data['transactions'] = array();
$results = $this->model_sale_customer->getTransactions($this->request->get['customer_id'], ($page - 1) * 10, 10);
foreach ($results as $result) {
$this->data['transactions'][] = array(
'id' => $result['customer_transaction_id'],
'amount' => $this->currency->format($result['amount'], $this->config->get('config_currency')),
'description' => $result['description'],
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added']))
);
}
$this->data['balance'] = $this->currency->format($this->model_sale_customer->getTransactionTotal($this->request->get['customer_id']), $this->config->get('config_currency'));
$transaction_total = $this->model_sale_customer->getTotalTransactions($this->request->get['customer_id']);
$pagination = new Pagination();
$pagination->total = $transaction_total;
$pagination->page = $page;
$pagination->limit = 10;
$pagination->text = $this->language->get('text_pagination');
$pagination->url = $this->url->link('sale/customer/transaction', 'token=' . $this->session->data['token'] . '&customer_id=' . $this->request->get['customer_id'] . '&page={page}', 'SSL');
$this->data['pagination'] = $pagination->render();
$this->template = 'sale/customer_transaction.tpl';
$this->response->setOutput($this->render());
}
Agora em
admin/view/template/sale/customer_form.tpl, procure por:
E adicione antes:
Código: Selecionar todos $('body').on('click', '.button-remove-transaction', function() {
var t_id = $(this).data('transaction');
$.ajax({
url: 'index.php?route=sale/customer/deleteTransaction&token=<?php echo $token; ?>&customer_id=<?php echo $customer_id; ?>',
type: 'post',
dataType: 'html',
data: 'id=' + t_id,
beforeSend: function() {
$('.success, .warning').remove();
$('.button-remove-transaction').attr('disabled', true);
$('#transaction').before('<div class="attention"><img src="view/image/loading.gif" alt="" /> <?php echo $text_wait; ?></div>');
},
complete: function() {
$('.button-remove-transaction').attr('disabled', false);
$('.attention').remove();
},
success: function(html) {
$('#transaction').html(html);
}
});
});
Agora em
admin/model/sale/customer.php, procure por:
E insira acima:
Código: Selecionar todos public function trueDeleteTransaction($order_id) {
$this->db->query("DELETE FROM " . DB_PREFIX . "customer_transaction WHERE customer_transaction_id = '" . (int)$order_id . "'");
}
Agora lá na view
admin/view/template/sale/customer_transaction.tp, altere aquele código do botão por esse:
Código: Selecionar todos<a class="button button-remove-transaction" onclick="deleteTransaction(<?php echo $transaction['id']; ?>);" data-transaction="<?php echo $transaction['id']; ?>"><span><?php echo "Deletar"; ?></a>
Agora sim deve funcionar...