How to simple calculate tariff

$new =new rate(1,1,’014415645465′);
print_r($new->getMyRate());

class rate
{
public $parent_id;
public $service_id;
public $prefix_field_value;

public function __construct($parent_id,$service_id,$prefix_field_value)
{
$this->parent_id = $parent_id;
$this->service_id = $service_id;
$this->prefix_field_value = $prefix_field_value;

}

public function getMyRate()
{
R::debug(true);
$rows=R::getAll(“SELECT *FROM uu_rate WHERE servicemodule_id=:service_id and parent_id=:parent_id”
,array(‘:service_id’=>$this->service_id,’:parent_id’=>$this->parent_id));

foreach($rows as $row)
{
$prefixes = explode(‘,’,$row[‘prefix’]);
foreach($prefixes as $prefix)
{
if(strncmp($prefix, $this->prefix_field_value, strlen( $prefix)) == 0){
$return = array($row[‘rate’],$row[‘comission’],$row[‘charge’]);
return $return;
break;
}
}

}
}

}

 

tariff table

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s