How to get selected options' ids in multiple pages in SugarCRM?

I am using SugarCRM 6.5.x CE version. Currently I am trying to get the ids of all selected records in listview in "Calls" module in CRM across multiple pages.

Suppose if I have 100 records and if I select only 50 out of them, then I should get ids of all selected 50 records.

I am referring this link to achieve the same: sugarcrm custom module select all across multiple page

This is the code I am using:

$mass = new MassUpdate();$mass->setSugarBean($bean);     
$mass
->generateSearchWhere('Calls', $_REQUEST['current_query_by_page']);
$seed = BeanFactory::getBean('Calls');
$query = $seed->create_new_list_query('name ASC', $mass->where_clauses);
$result = $db->query($query, true);

But the $query I am getting in above code and as mentioned in above link, it is for getting ids of all records in listview irrespective of its selection or not.

I just want to get the ids of only selected records. So whether it is only 1 or 99 out of 100. Kindly guide me here.