function getMaxCallTime($from, $to) { $customer = getCustomerByPhone($from); include_tariff($customer['tariffid']); $call_cost = getCost($from, $to, $customer['tariffid']); return floor($customer['balance'] / $call_cost['costPerUnit']) * $call_cost['unitSize']; }
die('Call start is not set. Please use --startcall [unix_timestamp].' . PHP_EOL); } if (empty($options['totaltime'])) { die('Time start to end of call is not set. Please use --totaltime [number_of_seconds].' . PHP_EOL); } if (empty($options['calltime'])) { die('Time answer to end of call is not set. Please use --calltime [number_of_seconds].' . PHP_EOL); } if (empty($options['type'])) { die('Call type is not set. Please use --type (incoming|outgoing).' . PHP_EOL); } if (empty($options['status'])) { die('Call status is not set. Please use --status (busy|answered|no answer).' . PHP_EOL); } // get customer and include tariff $customer = getCustomerByPhone($options['caller']); include_tariff($customer['tariffid']); // set call type $call_type = parseCallType($options['type']); if ($call_type === NULL) { die('Call type is not correct. Please use incoming or outgoing.' . PHP_EOL); } // no payments for incoming call else calculate cost for call $call_cost = getCost($options['caller'], $options['callee'], $customer['tariffid']); switch ($call_type) { case CALL_INCOMING: $price = 0; break; case CALL_OUTGOING: $price = round(ceil($options['calltime'] / $call_cost['unitSize']) * $call_cost['costPerUnit'], 5); break;