//Service:Destinationsmenu

$mainframe = JFactory::getApplication();
$option = JRequest::getVar('option','com_jewebservices','','string');
$post = JRequest::get ('post');  
$uri = JURI::getInstance();
$url= $uri->root();
$this->_table_prefix = "#__jetour_";
 global $HTTP_RAW_POST_DATA;
//$post['parent_id'] = '101';
//$parent_id = $post['parent_id'];
   $post = json_decode($HTTP_RAW_POST_DATA, true);
$parent_id = $post['parent_id'];
//echo "<pre>";print_r($user_info);exit;
//$parent_id = "101";
$addquery = '';

if($parent_id=='101')
	$addquery = " AND parent_id=".$parent_id;
else
	$addquery = " AND menutype='theme-for-application'";


$sql="SELECT title,alias,params FROM #__menu WHERE published=1 ".$addquery; 
$db->setQuery($sql);
$destinationsmenus = $db->loadObjectList();
 
 
 
if(count($destinationsmenus)){
 $destinationsmenusary = array();
 for($d=0; $d<count($destinationsmenus); $d++){
  $destinationsmenusdata = array();
  
  $destinationsmenusdata['menu_title'] = $destinationsmenus[$d]->title;
  $destinationsmenusdata['menu_alias'] = $destinationsmenus[$d]->alias;
  $allparams = json_decode($destinationsmenus[$d]->params);
  
  if($parent_id=='101')
  $destinationsmenusdata['param_catid'] = @$allparams->catid;
  else
  $destinationsmenusdata['param_themeid'] = @$allparams->themeidbk;
 /* $destinationsmenusdata['param_package_id'] = @$allparams->package_id;
  $destinationsmenusdata['param_themeid'] = @$allparams->themeidbk;
  $destinationsmenusdata['param_country'] = @$allparams->countryidhome;
  $destinationsmenusdata['param_packagetype'] = @$allparams->packagetype;
  $destinationsmenusdata['param_cityidhome'] = @$allparams->cityidhome;*/
  
  
  $destinationsmenusdata['param_menu_icon'] = $url.$allparams->menu_image;
  
 
  
  $destinationsmenusary[] =$destinationsmenusdata; 
 }
 $arr = array('success' => 1, 'Menus' => $destinationsmenusary);
 echo json_encode($arr);exit;
}else{
 $arr = array('success' => 0, 'message' => "No Menus Found" ); 
 echo json_encode($arr);exit;
}