} // 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; } // insert cdr record to database $DB->Execute("INSERT INTO\n\t\t\t\t\t\t\t\t\t voip_cdr (caller, callee, call_start_time, time_start_to_end, time_answer_to_end, price, status, type, voipaccountid)\n\t\t\t\t\t\t\t\t VALUES\n\t\t\t\t\t\t\t\t\t (?, ?, ?, ?, ?, ?, ?, ?, ?);", array($options['caller'], $options['callee'], $options['startcall'], $options['totaltime'], $options['calltime'], $price, strtolower($options['status']), $call_type, $customer['voipaccountid'])); } else { $fh = isset($options['file']) ? fopen($options['file'], 'r') : fopen('php://stdin', 'r'); $customer_list = getCustomerList(); $error = array(); $i = 0; while ($f_line = fgets($fh)) { // increment file line counter ++$i; // change line to associative array $cdr = parseRow($f_line); // check values of cdr array $cdr_error = validCDR($cdr); if ($cdr_error === TRUE) { $tariff_id = $customer_list[$cdr['caller']]['tariffid']; //include customer tariff if (!isset($tariffs[$tariff_id])) { include_tariff($tariff_id); if (!isset($tariffs[$tariff_id])) {
$rsp['error'] = SL_WRONG_KEY; respond($rsp); } if (!empty($_REQUEST['action'])) { // Connect to db $db = @mysql_connect(DB_SERVER, DB_USER, DB_PASSWORD); if (!$db || !@mysql_select_db(DB_NAME, $db)) { $rsp['error'] = SL_DB_FAILURE; $rsp['info'] = mysql_error(); respond($rsp); } error_log("salesApi: action " . $_REQUEST['action']); $_silent = isset($_REQUEST['silent']) && $_REQUEST['silent'] == 'true' ? true : false; switch ($_REQUEST['action']) { case 'getCustomerList': return getCustomerList(); case 'getPaymentList': return getPaymentList(); case 'getCustomerNames': return getCustomerNames(); case 'getCustomer': return getCustomer(); case 'getPaymentDetails': return getPaymentDetails(); case 'getPaymentHistory': return getPaymentHistory(); case 'getLastPayment': return getLastPayment(); case 'newInstance': return newInstance($_silent); case 'updateInstanceData':