<?php
class ModelPaymentPayu extends Model {
  	public function getMethod($address, $total) {
		$this->load->language('payment/payu');

		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "zone_to_geo_zone WHERE geo_zone_id = '" . (int)$this->config->get('payu_geo_zone_id') . "' AND country_id = '" . (int)$address['country_id'] . "' AND (zone_id = '" . (int)$address['zone_id'] . "' OR zone_id = '0')");

		if ($this->config->get('payu_total') > $total) {
			$status = false;
		} elseif (!$this->config->get('payu_geo_zone_id')) {
			$status = true;
		} elseif ($query->num_rows) {
			$status = true;
		} else {
			$status = false;
		}

    if (ftr_geral::isIsset($this->config->get('payu_display')) && (!ftr_geral::exibeMuduloLayout($this->config->get('payu_display')))){
      $status = false;
    }

		$method_data = array();

		if ($status) {
      		$method_data = array(
        		'code'       => 'payu',
        		'title'      => ($this->config->get('payu_title')) ? :$this->language->get('text_title'),
						'sort_order' => $this->config->get('payu_sort_order')
      		);
    	}
			if (ftr_geral::isIsset($this->config->get('payu_client_teste')) && (strlen($this->config->get('payu_client_teste'))>0)){
		    if ($this->customer->getId() == $this->config->get('payu_client_teste')){
		        return $method_data;
		    }
			}else{
				return $method_data;
			}
  }
}
