OS Property support center

BUG: Agent sorting.. - SOLVED

  • PSeers
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
11 years 7 months ago - 11 years 7 months ago #19593 by PSeers
BUG: Agent sorting.. - SOLVED was created by PSeers
In the control panel there is the option to sort agents by order/name It is selected to order as seen in this picture



and order is selected and saved.

however on the site it is still sorted by name still as seen here



When the order should be as follows from the back end



can the sort for agents be fixed thank you

Philip
Awesome job keep up the good work
Attachments:
Last edit: 11 years 7 months ago by Mr. Dam.

Please Log in or Create an account to join the conversation.

More
11 years 7 months ago #19616 by Mr. Dam
Replied by Mr. Dam on topic Re: BUG: Agent sorting..
Hi Philip,
It's the bug and i have fixed it. Now i send you new code of the function that show the agent listing.
In the file components > com_osproperty > classes > agent.php

please replace function agentLayout from line 151 by new version of it bellow:

function agentLayout($option){
global $mainframe,$configClass;
$document = JFactory::getDocument();
$document->setTitle($configClass." - ".JText::_('OS_LIST_AGENTS'));
$db = JFactory::getDbo();
$limit = JRequest::getVar('limit',20);
$limitstart = JRequest::getVar('limitstart',0);
$state = JRequest::getVar('state',0);
$alphabet = JRequest::getVar('alphabet','');
$general_default_agents_sort = $configClass;
if($general_default_agents_sort == ""){
$general_default_agents_sort = "a.name";
}else{
$general_default_agents_sort = "a.".$general_default_agents_sort;
}
$general_default_agents_order = $configClass;
if($general_default_agents_order == ""){
$general_default_agents_order = " asc";
}
$query = "Select count(a.id) from #__osrs_agents as a inner join #__users as b on b.id = a.user_id where a.published = '1'";
if($alphabet != ""){
switch ($alphabet){
default:
$query .= " and (a.name like '".strtoupper($alphabet)."%' or a.name like '".strtolower($alphabet)."%')";
break;
case "0-9":
$query .= "and (";
for($i=0;$i<10;$i++){
$query .= " a.name like '".$alphabet."%' or";
}
$query = substr($query,0,strlen($query)-2);
$query .= ")";
break;
}
}
$db->setQuery($query);
$count = $db->loadResult();
$pageNav = new JPagination($count,$limitstart,$limit);
$query = "Select a.* from #__osrs_agents as a inner join #__users as b on b.id = a.user_id where a.published = '1'";
if($alphabet != ""){
switch ($alphabet){
default:
$query .= " and (a.name like '".strtoupper($alphabet)."%' or a.name like '".strtolower($alphabet)."%')";
break;
case "0-9":
$query .= "and (";
for($i=0;$i<10;$i++){
$query .= " a.name like '".$alphabet."%' or";
}
$query = substr($query,0,strlen($query)-2);
$query .= ")";
break;
}
}
$query .= " order by ".$general_default_agents_sort." ".$general_default_agents_order;
$db->setQuery($query,$pageNav->limitstart,$pageNav->limit);
$rows = $db->loadObjectList();

if(count($rows) > 0){
for($i=0;$i<count($rows);$i++){
$row = $rows[$i];
$db->setQuery("Select count(id) from #__osrs_properties where agent_id = '$row->id' and approved = '1'");
$countlisting = $db->loadResult();
$row->countlisting = intval($countlisting);

$db->setQuery("Select state_name from #__osrs_states where id = '$row->state'");
$row->state_name = $db->loadResult();
$db->setQuery("Select country_name from #__osrs_countries where id = '$row->country'");
$row->country_name = $db->loadResult();
}
}

$agent_id = JRequest::getVar('agent_id','');

if(HelperOspropertyCommon::checkCountry()){
$country_id = JRequest::getVar('country_id');
}else{
$country_id = intval(HelperOspropertyCommon::getDefaultCountry());
}

$state_id = JRequest::getVar('state_id',0);
$city = JRequest::getVar('city',0);
$address = JRequest::getVar('address','');
$distance = JRequest::getVar('distance',5);

if((($country_id > 0) and (HelperOspropertyCommon::checkCountry())) or ($state_id > 0) or ($city > 0) or ($address != "")){
if($address != ""){
$google_address_search = $address;
}
if($city > 0){
$city_name = HelperOspropertyCommon::loadCityName($city);
$google_address_search .= ", ".$city_name;
}
if(intval($state_id) > 0){
$db->setQuery("Select state_name from #__osrs_states where id = '$state_id'");
$state_name = $db->loadResult();
if($state_name != ""){
$google_address_search .= ", ".$state_name;
}
}

if(intval($country_id) > 0){
$db->setQuery("Select country_name from #__osrs_countries where id = '$country_id'");
$country_name = $db->loadResult();
if($country_name != ""){
$google_address_search .= ", ".$country_name;
}
}

if($address != ""){ //get lat long addresses
$google_address_search_encode = urldecode($google_address_search);
$return = HelperOspropertyGoogleMap::findAddress($option,'',$google_address_search_encode,1);
$search_lat = $return[0];
$search_long = $return[1];
$status = $return[2];
}

$count = "Select count(a.id) from #__osrs_agents as a";
$select = "Select a.*,b.state_name,c.city as city_name,d.country_name from #__osrs_agents as a"
." left join #__osrs_states as b on b.id = a.state"
." left join #__osrs_cities as c on c.id = a.city"
." inner join #__osrs_countries as d on d.id = a.country";

$where = " WHERE a.published = '1'";
if($address != ""){
$where .= " AND a.address like '%$address%'";
}
if($city > 0){
$where .= " AND a.city = '$city'";
}
if($state_id > 0){
$where .= " AND a.state = '$state_id'";
}
if($country_id > 0){
$where .= " AND a.country = '$country_id'";
}
if($address != ""){
if (($google_address_search != '') and ($radius_search != "")){
if ($status == "OK") {
$multiFactor = 3959;
// Search the rows in the table
$select .= sprintf(", ( %s * acos( cos( radians('%s') ) *
cos( radians( a.lat_add ) ) * cos( radians( a.long_add ) - radians('%s') ) +
sin( radians('%s') ) * sin( radians( a.lat_add ) ) ) )
AS distance",
$multiFactor,
doubleval($search_lat),
doubleval($search_long),
doubleval($search_lat)
);
$where .= sprintf(" HAVING distance < '%s'", doubleval($radius_search));
$Order_by = " ORDER BY distance ASC desc,a.name ";
$no_search = false;
}
}
}else{
$Order_by = " order by ".$general_default_agents_sort." ".$general_default_agents_order;
}


$db->setQuery($count.' '.$where);
$total = $db->loadResult();
if($total > 24){
$lists = 1;
$limit = " LIMIT 24";
}else{
$lists = 0;
$limit = "";
}
$db->setQuery($select.' '.$where.' '.$Order_by.' '.$limit);
$rows1 = $db->loadObjectList();
if(count($rows1) > 0){ //check the google lat long addresses and show them in the google map and num listing
for($i=0;$i<count($rows1);$i++){
$row = $rows1[$i];
$db->setQuery("Select count(id) from #__osrs_properties where agent_id = '$row->id' and approved = '1'");
$countlisting = $db->loadResult();
$row->countlisting = intval($countlisting);

$address = $row->address;
if($row->city != ""){
$address .= " ".$row->city;
}
if($row->state_name != ""){
$address .= " ".$state_name;
}
if($row->country_name != ""){
$address .= " ".$country_name;
}
$geocode = HelperOspropertyGoogleMap::getLatlongAdd($address);
$row->lat = $geocode[0]->lat;
$row->long = $geocode[0]->long;
}
}
}

$lists = HelperOspropertyCommon::makeCountryList($country_id,'country_id','onchange="change_country_company(this.value,'.$state_id.','.$city.')"',JText::_('OS_ANY'),'style="width:150px;"');

$lists = HelperOspropertyCommon::makeStateList($country_id,$state_id,'state_id','onchange="change_state(this.value,'.intval($city).')" class="inputbox"',JText::_('OS_ANY'),'');

//list city
$lists = HelperOspropertyCommon::loadCity(option,$state_id, $city);

$radius_arr = array(5,10,20,50,100,200);
$radiusArr = array();
$radiusArr[] = JHTML::_('select.option','',JText::_('OS_SELECT_RADIUS'));
foreach ($radius_arr as $radius) {
$radiusArr[] = JHtml::_('select.option',$radius, $radius. ' '. JText::_(OS_MILES));
}
$lists = JHtml::_('select.genericlist',$radiusArr,'distance','class="inputbox"', 'value', 'text',$distance);

HTML_OspropertyAgent::agentLayout($option,$rows,$pageNav,$alphabet,$rows1,$lists);
}

Good luck
Dam

Please Log in or Create an account to join the conversation.

  • PSeers
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
11 years 7 months ago #19642 by PSeers
Replied by PSeers on topic Re: BUG: Agent sorting..
Thank you for the Fix
Keep up the awesome work and support of this product!!

Philip

Please Log in or Create an account to join the conversation.

Moderators: Mr. DamNguyen Phu Quan