<?php
class CalculateDiscount extends Calculate {
	function __construct(&$locator) {
		$this->cart     =& $locator->get('cart');
		$this->config   =& $locator->get('config');
		$this->currency =& $locator->get('currency');
		$this->language =& $locator->get('language');

    	$this->language->load('extension/calculate/discount.php');
    	$this->database =& $locator->get('database');
    	$this->customer  =& $locator->get('customer');	   
    	$this->payment   =& $locator->get('payment');
    	$this->session   =& $locator->get('session');
    	
  	}
	
	function calculate() {
		
		$discount_data = array();
        $customer_row=$this->database->getRow("select vip_rank from customer where customer_id='".(int)$this->customer->getId()."'");
	    $vip_row=$this->database->getRow("select discount from vip where vip_rank='".$customer_row['vip_rank']."'"); 
	  	$discount_data[] = array(
								'title' => $customer_row['vip_rank'].":", 
								'text'  => '- '.$vip_row['discount']." off",
								'value' => $vip_row['discount']
				                );
		return $discount_data;
  	}

	function getSortOrder() {
		return 1;
	}	
}
?>
