function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
vishal yadav 62vishal yadav 62 

function

Hi folks,

i want write php due to apex with @RemoteAction ..getting error .
code is below --2 code for refernce 
please help me out asap
1st--
public function setExShowroomPrice ()
    {
        $manufacturer = $this->input->post('old_car_manufacturer');
        $model = $this->input->post('old_car_model');
        $variant = explode('@@', $this->input->post('old_car_modeltype'));
           $model_type = $variant[0];
           $fuel_type = $variant[1];
        $result = $this->cardata_model->get_used_car_det($manufacturer,$model,$model_type,$fuel_type,$_SESSION['dlrid']);
        
        if (is_array($result))
        {
            $_SESSION['old_ex_showroom_price'] = $result['ex_showroom_price'];
            $var_price = array("ex_showroom_price"=>$result['ex_showroom_price'],"fuel_type"=>$result['fuel_type']);
            echo json_encode($var_price);
        }
    }
    
    ---------------------
2nd---
function get_used_car_det($manufacturer,$model,$model_type,$fuel_type,$dealer_id)
    {
        $conditions = array(
            'manufacturer' => $manufacturer,
            'model' => $model,        
            'model_type' => $model_type,
            'fuel_type'=>$fuel_type,
            'city'=>$_SESSION['dlr_city']
        );
        $this->db->select('*');
        $this->db->where($conditions);
        $query = $this->db->get('old_cars');
        //echo $this->db->last_query();
        if ($query->num_rows() > 0) return $query->row_array();
        else return false; 
       
    }

===================
this is mine code 
global with sharing class ExchangeRemoter {

    public static string manufacturer {get; set;}
   //public static jud_old_car {get;set;}
   public static list<jud_old_cars__c> oldCar {get; set;}
   public Map<String, String> showrooms {get; set;}
    
    
    public ExchangeRemoter() {
        
    }
    
    @RemoteAction
    global static list<Map<string, string>> get_car_manufacturer(){
        list<Map<string, string>> oldCarList = new list<Map<String, String>>();
        AggregateResult[] groupedResults = [Select manufacturer__c from jud_old_cars__c group by manufacturer__c];
        system.debug(groupedResults);
        
        for(AggregateResult ar : groupedResults){
                
           oldCarList.add(new Map<String, String> { 
                                                     'value'=>String.valueof(ar.get('manufacturer__c')),
                                                     'label'=>String.valueof(ar.get('manufacturer__c'))
                                                 });  
     
        }   
      
        return oldCarList;
    }
    
    @RemoteAction
    global  static list<Map<string, string>> get_model(String manufac){
        list<Map<string, string>> carmodels = new list<Map<String, String>>();    
        AggregateResult[] groupedResult = [Select model__c from jud_old_cars__c where manufacturer__c =: manufac group by model__c];
        for(AggregateResult cm : groupedResult){
            carmodels.add(new Map<String, String> { 
                                                     'value'=>String.valueof(cm.get('model__c')),
                                                     'label'=>String.valueof(cm.get('model__c'))
                                                 });   
        }
        return carmodels;
    }
    
    @RemoteAction
    global static list<Map<string, string>> get_variant(string model){
      
        list<Map<string, string>> oldVariantList = new list<Map<String, String>>();
        AggregateResult[] groupedResults = [Select model_type__c, fuel_type__c
                                            from jud_old_cars__c
                                            where model__c=: model
                                            group by model_type__c, fuel_type__c];
        
        for(AggregateResult ar : groupedResults){
                
           oldVariantList.add(new Map<String, String> { 
                                                     'value'=>String.valueof(ar.get('model_type__c'))+ '@@'+ String.valueof(ar.get('fuel_type__c')),
                                                     'label'=>String.valueof(ar.get('model_type__c'))+ ' ' + String.valueof(ar.get('fuel_type__c'))
                                                 });  
     
        }   
      
        return oldVariantList;
    }
  
    @RemoteAction
     global static list<Map<string, string>> setExShowroomPrice(Map<String, String> showrooms){
       list<Map<string, string>> carmodelsprice = new list<Map<String, String>>(); 
       List<String> models = new List<String>(); 
        
        String Exshoroom;
        Integer showroompri = Integer.valueOf(showrooms.get('showroompri'));
        String manufacturer = showrooms.get('manufacturer');
        String mode = showrooms.get('model');
        String  variant = showrooms.get('variant');
         
         AggregateResult[] groupedResults = [Select manufacturer__c,model__c,fuel_type__c from jud_old_cars__c]
        list<Map<string, string>> oldVariantList = new list<Map<String, String>>();
                 
        for(AggregateResult sesp : groupedResults){
        
                carmodelsprice.add(new Map<String, String>{
            
                }
    }
        ExShowroomPriceList.add(new Map<String, String> {  
                                                    'manufacturer'=>oldCarList.manufacturer__c,
                                                    'model'=>carmodelsprice.model__c,                                                                   
                                                    'variant'=>carmodelsprice.variant__c,
                                                    'model_type'=>carmodelsprice.model_type__C,
                                                    'fuel_type'=>carmodelsprice.fuel_type__c,
                                                                                                                                                           
                                                  });
              }
    
    return carmodelsprice;
}
}
.help me out friend
Prakash NawalePrakash Nawale
Hi vishal yadav 62,

Can you please add more details about issue and what are you trying to implement with complete scenario.