<?php

class ControllerEredeLogsView extends Controller
{
	public function index()
	{
		$this->language->load('payment/erede');
		$this->document->setTitle('e-Rede Logs');
		$this->load->model('erede/logs_view');

		$idLog = (int)$this->request->get['id_log'];
		$log = array();
		$log = $this->model_erede_logs_view->getLog($idLog);

		$this->data['erede_logo'] = $this->language->get('erede_logo');
		$this->data['log'] = $log;

    	$this->data['status'] = $this->language->get($log['status']);
    	$this->data['forma_pagamento'] = $this->language->get($log['forma_pagamento']);
    	//echo $log['message']."<br>";
    	if ($log['message'] == "Erro na transação")
    	{
    		$this->data['message'] = $this->language->get('erro_transacao');
    	}
    	else if ($log['message'] == "Transação Aprovada na Análise de Risco")
    	{
    		$this->data['message'] = $this->language->get('sucesso_analise');
    	}
    	else if (strrpos($log['message'], "token") > 0)
    	{
    		$this->data['message'] = $this->language->get('erro_webservice');
    	}
    	else if (strrpos($log['message'], "Risco") > 0)
    	{
    		$this->data['message'] = $this->language->get('erro_risco_produto');
    	}
    	else
    	{
    		$this->data['message'] = $log['message'];
    	}

		$this->data['txt_id_log'] = $this->language->get('txt_id_log');
		$this->data['txt_id_order'] = $this->language->get('txt_id_order');
		$this->data['txt_date'] = $this->language->get('txt_date');
		$this->data['txt_status'] = $this->language->get('txt_status');
		$this->data['txt_message'] = $this->language->get('txt_message');
		$this->data['txt_action'] = $this->language->get('txt_action');
		$this->data['txt_view'] = $this->language->get('txt_view');
		$this->data['txt_info'] = $this->language->get('txt_info');
		$this->data['txt_order_status'] = $this->language->get('txt_order_status');
		$this->data['txt_transaction_response'] = $this->language->get('txt_transaction_response');
		$this->data['txt_erede_status'] = $this->language->get('txt_erede_status');
		$this->data['txt_erede_token'] = $this->language->get('txt_erede_token');
		$this->data['txt_payment_method'] = $this->language->get('txt_payment_method');
		$this->data['txt_card_scheme'] = $this->language->get('txt_card_scheme');
		$this->data['txt_amount_parcels'] = $this->language->get('txt_amount_parcels');
		$this->data['txt_prompt_payment'] = $this->language->get('txt_prompt_payment');
		$this->data['txt_gateway_reference'] = $this->language->get('txt_gateway_reference');
		$this->data['txt_auth_host'] = $this->language->get('txt_auth_host');
		$this->data['txt_auth_code'] = $this->language->get('txt_auth_code');
		$this->data['token'] = $this->session->data['token'];
		$this->data['back'] = $this->url->link('erede/logs', 'token=' . $this->session->data['token'], 'SSL');
		$this->data['button_back'] = $this->language->get('button_back');

		$this->_createBreadcrumbs();

		$this->template = 'erede/logs_view.tpl';
		$this->children = array(
			'common/header',
			'common/footer'
		);

		$this->response->setOutput($this->render());
	}

	private function _createBreadcrumbs()
	{

		$this->data['breadcrumbs'] = array();

		$this->data['breadcrumbs'][] = array(
			'text'		 => $this->language->get('text_home'),
			'href'		 => $this->url->link('common/home', 'token=' . $this->session->data['token'], 'SSL'),
			'separator'	 => false
		);

		$this->data['breadcrumbs'][] = array(
			'text'		 => $this->language->get('text_payment'),
			'href'		 => $this->url->link('extension/payment', 'token=' . $this->session->data['token'], 'SSL'),
			'separator'	 => ' :: '
		);

		$this->data['breadcrumbs'][] = array(
			'text'		 => $this->language->get('heading_title'),
			'href'		 => $this->url->link('payment/erede', 'token=' . $this->session->data['token'], 'SSL'),
			'separator'	 => ' :: '
		);

		$this->data['breadcrumbs'][] = array(
			'text'		 => 'Logs',
			'href'		 => $this->url->link('erede/logs', 'token=' . $this->session->data['token'], 'SSL'),
			'separator'	 => ' :: '
		);
	}
}
?>