<?php
class ModelSalerapnet extends Model {
	public function addrapnet($data) {
		$this->db->query("INSERT INTO " . DB_PREFIX . "rapnet_default SET  lowclarity = '" . $this->db->escape($data['lowclarity']) . "',highclarity = '" . $this->db->escape($data['highclarity']) . "',lowcolour = '" . $this->db->escape($data['lowcolour']) . "',highcolour = '" . $this->db->escape($data['highcolour']) . "',lowweight = '" . $this->db->escape($data['lowweight']) . "',highweight = '" . $this->db->escape($data['highweight']) . "',variation = '" . $this->db->escape($data['variation']) . "',colour_default = '" . $this->db->escape($data['colour_default']) . "',clarity_default = '" . $this->db->escape($data['clarity_default']) . "',shape = '" . $this->db->escape($data['shape']) . "'");
	}
	 
	public function editrapnet($rapnet_id, $data) {
		$this->db->query("UPDATE " . DB_PREFIX . "rapnet_default SET  lowclarity = '" . $this->db->escape($data['lowclarity']) . "',highclarity = '" . $this->db->escape($data['highclarity']) . "',lowcolour = '" . $this->db->escape($data['lowcolour']) . "',highcolour = '" . $this->db->escape($data['highcolour']) . "',lowweight = '" . $this->db->escape($data['lowweight']) . "',highweight = '" . $this->db->escape($data['highweight']) . "',variation = '" . $this->db->escape($data['variation']) . "',colour_default = '" . $this->db->escape($data['colour_default']) . "',clarity_default = '" . $this->db->escape($data['clarity_default']) . "',shape = '" . $this->db->escape($data['shape']) . "' WHERE rapnet_id = '" . (int)$rapnet_id . "'");
	}
	
	public function deleterapnet($rapnet_id) {
		$this->db->query("DELETE FROM " . DB_PREFIX . "rapnet_default WHERE rapnet_id = '" . (int)$rapnet_id . "'");
	//	$this->db->query("DELETE FROM " . DB_PREFIX . "product_discount WHERE gemstoneprice_id = '" . (int)$gemstoneprice_id . "'");
	}
	
	public function getGemStoneInfo($rapnet_id) {
		$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "rapnet_default WHERE rapnet_id = '" . (int)$rapnet_id . "'");
		
		return $query->row;
	}
	
	public function getGemStonePrices($data = array()) {
	//	$sql = "SELECT a.*,b.gemname  FROM " . DB_PREFIX . "rapnet_default a,gemstone b where a.gemstone_id=b.gemstone_id";
		$sql = "SELECT * FROM " . DB_PREFIX . "rapnet_default";
		
	/*	$sql .= " ORDER BY  code";	
			
		if (isset($data['order']) && ($data['order'] == 'DESC')) {
			$sql .= " DESC";
		} else {
			$sql .= " ASC";
		}
		
		if (isset($data['start']) || isset($data['limit'])) {
			if ($data['start'] < 0) {
				$data['start'] = 0;
			}			

			if ($data['limit'] < 1) {
				$data['limit'] = 20;
			}	
			
			$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
		} */
			
		$query = $this->db->query($sql);
		
		return $query->rows;
	}
	
	public function getTotalCustomerGroups() {
		$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "rapnet_default");
		
		return $query->row['total'];
	}
}
?>