function t_cpl($r, $wrap = true, $emp = true)
{
    return currencies_span(round2(empty($r['lead']) ? 0 : $r['price'] / $r['lead']), $wrap);
}
}
foreach ($data as $r) {
    // Округление
    $r['price'] = round($r['price'], 2);
    $r['income'] = round($r['income'], 2);
    $epc = currencies_span(round2($r['income'] / $r['cnt']));
    $profit = $r['income'] - $r['price'];
    $roi = round($profit / $r['price'] * 100, 1);
    $conversion = round2($r['sale'] / $r['cnt'] * 100);
    $conversion_l = round2($r['lead'] / $r['cnt'] * 100);
    $follow = round($r['out'] / $r['cnt'] * 100, 1);
    $srch = round($r['income'] / $r['sale'], 2);
    $cps = round($r['price'] / $r['sale'], 2);
    $cpl = round($r['price'] / $r['lead'], 2);
    $price = currencies_span($r['price']);
    $profit = currencies_span($profit);
    $repeated = $r['cnt'] - $r['unique'];
    if ($repeated < 0) {
        $repeated = 0;
    }
    $repeated = round($repeated / $r['cnt'] * 100, 1);
    $group_link = $subtype == 'out_id' ? 'source_name' : 'out_id';
    $name = empty($r['name']) ? $group_types[$group_by][1] : $r['name'];
    if (empty($limited_to)) {
        $name = '<a href="?act=reports&type=' . _e($type) . '&subtype=' . _e($main_type) . '&limited_to=' . $r['id'] . '&group_by=' . $group_link . '">' . $name . '</a>';
    }
    echo '<tr><td nowrap="">' . $name . '</td><td>' . intval($r['cnt']) . '</td><td>' . $repeated . '%</td><td class="col_s">' . $r['sale'] . '</td><td class="col_s">' . $conversion . '%</td><td>' . $price . '</td><td class="col_s">' . $profit . '</td><td class="col_s">' . $epc . '</td><td class="col_s">' . $roi . '%</td><td class="col_l">' . $r['lead'] . '</td><td class="col_l">' . $conversion_l . '%</td><td class="col_l">' . $cpl . '</td></tr>';
}
?>
			</tbody>
		</table>