$this->language->load('sale/coupon');
$this->load->model('sale/coupon');
$this->data['text_no_results'] = $this->language->get('text_no_results');
$this->data['column_order_id'] = $this->language->get('column_order_id');
$this->data['column_customer'] = $this->language->get('column_customer');
$this->data['column_amount'] = $this->language->get('column_amount');
$this->data['column_date_added'] = $this->language->get('column_date_added');
if (isset($this->request->get['page'])) {
$page = $this->request->get['page'];
} else {
$page = 1;
}
$this->data['histories'] = array();
$results = $this->model_sale_coupon->getCouponHistories($this->request->get['coupon_id'], ($page - 1) * 10, 10);
foreach ($results as $result) {
$this->data['histories'][] = array(
'order_id' => $result['order_id'],
'customer' => $result['customer'],
'amount' => $result['amount'],
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added']))
);
}
$history_total = $this->model_sale_coupon->getTotalCouponHistories($this->request->get['coupon_id']);
$pagination = new Pagination();
$pagination->total = $history_total;
$pagination->page = $page;
$pagination->limit = 10;
$pagination->url = $this->url->link('sale/coupon/history', 'token=' . $this->session->data['token'] . '&coupon_id=' . $this->request->get['coupon_id'] . '&page={page}', 'SSL');
$this->data['pagination'] = $pagination->render();
$this->template = 'sale/coupon_history.tpl';
$this->response->setOutput($this->render());