%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/ugotscom/www/Mantra/application/modules/api/controllers/
Upload File :
Create Path :
Current File : /home/ugotscom/www/Mantra/application/modules/api/controllers/Api.php

<?php
class Api extends CI_Controller {
    public function __construct() {
        parent::__construct();
        $this->load->model('common_model', 'obj_common', TRUE);
    }
// code for login api//
    public function login() {  
        $res['status'] = 'error';
        $api_key = $this->input->post_get('api_key');
        if($api_key==$this->config->item('api_key')){
        $username = $this->input->post_get('username');
        $pass = $this->input->post_get('password');
       
        if($username!='' && $pass!=''){      
        $pass = md5($pass);
        $field = 'user_id,name,phone';
        $condition = array('username' => $username,
            'password' => $pass);
        $result = $this->obj_common->get_all('users', $condition, $field);
        if ($result) {   
            $res['status'] = 'success';
            $res['data'] = $result ;
        }else{
            $conditions = array('username' => $username);
           
              $result = $this->obj_common->get_all('users', $conditions, $field);
        if ($result) { 
             $res['message'] = 'Invalid Password or username';
        }else{
             $res['message'] = 'User not exist';
        }
             $res['status'] = 'error';
            
        }
        }
        }else{
            $res['message'] = 'Invalid api key';
        }
        echo json_encode($res);
    }
   public function enqiry(){ 
                $res['status'] = 'error';
              
        $api_key = $this->input->post_get('api_key');
        if($api_key==$this->config->item('api_key')){
                $this->load->helper(array('form', 'url'));
                $this->load->library('form_validation');
//                $this->form_validation->set_rules('enquiry_source', 'enquiry_source', 'xss_clean|trim');              
//                $this->form_validation->set_rules('customer_name', 'customer_name', 'xss_clean|trim');
////                $this->form_validation->set_rules('enquiry_source', 'product_price', 'xss_clean|trim');              
////                $this->form_validation->set_rules('alt_mobile_no', 'alt_mobile_no', 'xss_clean|trim');
////                $this->form_validation->set_rules('landline_no', 'landline_no', 'xss_clean|trim');              
////                $this->form_validation->set_rules('email', 'email', 'valid_email|xss_clean|trim');
////                $this->form_validation->set_rules('location', 'location', 'xss_clean|trim');              
////                $this->form_validation->set_rules('gender', 'gender', 'xss_clean|trim');
////                $this->form_validation->set_rules('dob', 'dob', 'xss_clean|trim');              
////                $this->form_validation->set_rules('aadhar_no', 'aadhar_no', 'xss_clean|trim');   
////                $this->form_validation->set_rules('product_category_id', 'product_category_id', 'xss_clean|trim');              
////                $this->form_validation->set_rules('lead_type_id', 'lead_type_id', 'xss_clean|trim'); 
//////                $this->form_validation->set_rules('followup_date', 'followup_date', 'xss_clean|trim');    
//                if ($this->form_validation->run() == FALSE)
//                {
//                         $res['status'] = 'error';
//                }
//                else
//                {
               
                $c_date=date('Y-m-d') ;
                $lead_array = array(
                'enquiry_source' => $this->input->post_get('enquiry_source'),
                'customer_name' => $this->input->post_get('customer_name'),
                    'product_price' => $this->input->post_get('product_price'),
                    'mobile_no' => $this->input->post_get('mobile_no'),
                    'alt_mobile_no' => $this->input->post_get('alt_mobile_no'),
                    'landline_no' => $this->input->post_get('landline_no'),
                    'email' => $this->input->post_get('email'),
                    'location' => $this->input->post_get('location'),
                    'gender' => $this->input->post_get('gender'),
                    'dob' => $this->input->post_get('dob'),
                    'aadhar_no' => $this->input->post_get('aadhar_no'),
                    'product_category_id' => $this->input->post_get('product_category_id'),
                    'lead_type_id' => $this->input->post_get('lead_type_id'),
                    'added_by' => $this->input->post_get('added_by'),
                    'added_date' => $c_date,
                    'followup_date'=>$this->input->post_get('followup_date'),
                    'branch_id'=>$this->input->post_get('branch_id')
                );
              
                $enq_id =$this->obj_common->add('leads', $lead_array);
                $res['enq_id'] = $enq_id;
                $res['status'] = 'success';
                
             
                   }else{
           $res['message'] = 'Invalid api key';
        }             // }
                echo json_encode($res);
   }
   public function get_leads($lead_type,$row=0){ 
        $lead_type_array = $this->obj_common->get_all('lead_type');
        foreach($lead_type_array  as $resarray){
            $res_array[$resarray['lead_type_id']]= $resarray['Lead_type'];
        }
        $res['status'] = 'error';
        $api_key = $this->input->post_get('api_key');
        if($api_key==$this->config->item('api_key')){          
        $limit = '10';
        $this->load->library('pagination');
        $config['base_url'] = site_url('admin/common/search');
        $config['full_tag_open'] = '<li>';
        $config['full_tag_close'] = '</li>';
        $config['uri_segment'] = 4;
        $condition=array('lead_type_id'=>$lead_type);
        $total_rows = $this->obj_common->countrows('leads',$condition);
        $config['total_rows'] = $total_rows;
        $data['total_rows'] = $total_rows;
        $config['per_page'] = $limit;
        $this->pagination->initialize($config);
        $data['links'] = $this->pagination->create_links();
        $res_data = $this->obj_common->get_all_entries('leads',$row, $limit, $condition, 'lead_id', 'desc');
        $data['row'] = $row;
        $data['page_active'] = 2;      
        $data['per_page'] = $limit;
        $i=0;
        foreach ( $res_data as $results) {
             $res_data[$i]['lead_type_id']=$res_array[$results['lead_type_id']];
            $i++;
        }
        if($i>0){
            $res['status'] = 'success';
            $res['data']=$res_data;
        }
     }else{
            $res['message'] = 'Invalid api key';
        }             // }
       echo json_encode($res);
        }
    public function lead_type(){ 
        $condition=array();
        $res['status'] = 'error';
        $result = $this->obj_common->get_all('lead_type', $condition);
        if ($res) { 
            $res['status'] = 'success';
            $res['data']=$result;            
        }
        echo json_encode($res);
   }
     public function enquiry_source(){ 
         
        $condition=array();
        $res['status'] = 'error';
        $result = $this->obj_common->get_all('enquiry_source', $condition);
        if ($res) { 
            $res['status'] = 'success';
            $res['data']=$result;            
        }
        echo json_encode($res);       
   }
      public function dashboard(){ 
     
        $res['status'] = 'error';
        $api_key = $this->input->post_get('api_key');
        if($api_key==$this->config->item('api_key')){
            $res_data['total_enquiry'] = 8;
            $res_data['closed'] = 2;
            $res_data['hot'] = 4;
            $res_data['warm'] = 9;
            $res_data['cold'] = 5;
            $res_data['today_followup'] = 1;
            $res_data['total_pending'] = 6;            
            $res['status'] = 'success';
            $res['data']=$res_data;
        
     }else{
            $res['message'] = 'Invalid api key';
        }             // }
       echo json_encode($res);
        }
   
   

}
//http://www.ugotechnologies.com/sterren/api/dashboard/?api_key=43a11e2c74bc458f9938e7a32bdedcd3275456c3
 //http://www.ugotechnologies.com/sterren/api/get_leads/2?api_key=43a11e2c74bc458f9938e7a32bdedcd3275456c3
//http://www.ugotechnologies.com/sterren/api/lead_type
//http://www.ugotechnologies.com/sterren/api/enquiry_source
 //http://www.ugotechnologies.com/sterren/api/enqiry?api_key=43a11e2c74bc458f9938e7a32bdedcd3275456c3&enquiry_source=enquiry_source&customer_name=customer_name&product_price=100&mobile_no=11111&alt_mobile_no=alt_mobile_no&landline_no=landline_no&email=email&location=location&gender=gender&dob=2019-09-05&aadhar_no=aadhar_no&product_category_id=1&lead_type_id=2&added_by=3&followup_date=2019-09-05 
 //http://www.ugotechnologies.com/sterren/api/login?api_key=43a11e2c74bc458f9938e7a32bdedcd3275456c3&username=shitha&password=12345 
    
?>

Zerion Mini Shell 1.0