MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: /home/cafsindia/crm_cafsindia_com/application/controllers/Happy_calling_DNR.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
require_once("Secure_Controller.php");
class Happy_calling extends Secure_Controller{

  public function __construct(){
      parent::__construct('Happy_calling');
       $this->load->model('Happy_model');
       $this->load->model('all_leads_model');
  }

  public function index(){
      if(!$this->Appconfig->isAppvalid()){
              redirect('config');
      }
      $data['table_headers'] = $this->xss_clean(get_hc_table_headers());
     // $data = "";
      $this->load->view('happy_calling/manage',$data);
  }

  public function search(){
		$search = $this->input->get('search');
		$limit = $this->input->get('limit');
		$offset = $this->input->get('offset');
		$sort = $this->input->get('sort');
		$order = $this->input->get('order');
    $filters = array('start_date' => $this->input->get('start_date'),
            'end_date' => $this->input->get('end_date'),
            'General_Insurance' => FALSE,
            'Portfolio' => FALSE,
            'Health_Insurance' => FALSE,
            'Mutual_Funds' => FALSE,
            'Term_Plan' => FALSE);

    $filledup = array_fill_keys($this->input->get('filters'), TRUE);
    $filters = array_merge($filters, $filledup);

		$all_leads = $this->Happy_model->search($search, $filters, $limit, $offset, $sort, $order);

		$total_rows = $this->Happy_model->get_found_rows($search, $filters);

		$data_rows = array();
		foreach($all_leads->result() as $leads)
		{

			$data_rows[] = $this->xss_clean(get_hc_data_row($leads, $this));
		}

		echo json_encode(array('total' => $total_rows, 'rows' => $data_rows));
	}

  public function view($lead_id = -1){
    $data['lead_info'] = $this->Happy_model->get_info($lead_id);
    $data['product_list'] = $this->Happy_model->get_product_list($lead_id);
    
    $fund_name[""] = "---- Select Fund Name ----";
    foreach($this->Happy_model->get_fund_name_list() as $row){
      $fund_name[$this->xss_clean($row->fund_id)] = $this->xss_clean($row->fund_name);
    }
    $data['fund_name'] = $fund_name;

    $amc[""] = "---- Select AMC ----";
    foreach($this->Happy_model->get_amc() as $row){
      $amc[$this->xss_clean($row->id)] = $this->xss_clean($row->amc);
    }
    $data['amc'] = $amc;

    $this->load->view("mis/form", $data);
  }
  public function get_amc($fund_id){
    $amc = $this->Happy_model->get_amc($fund_id);
    echo json_encode(array('status' =>"SUCCESS",'amc' => $amc));
  }
  /*
  public function save(){ 
    $lead_id    = $this->input->post('call_lead_id');
    $product_id = $this->input->post('call_product_id');
    $call_data = array(
      'call_lead_id'          => $this->input->post('call_lead_id'),
      'call_product_id'       => $this->input->post('call_product_id'),
      'login_date'            => date('Y-m-d',strtotime($this->input->post('login_date'))),
      'issuance_status'       => $this->input->post('issuance_status'),
      'policy_no'             => $this->input->post('policy_no'),
      'ltd'                   => $this->input->post('ltd'),
      'reason'                => $this->input->post('reason'),
      'issued_date'           => date('Y-m-d',strtotime($this->input->post('issued_date'))),
      'itl_status'            => $this->input->post('itl_status'),
      'document_issue_status' => $this->input->post('document_issue_status'),
      'confirmation'          => $this->input->post('confirmation'),
      'amc'                   => $this->input->post('amc'),
      'fund_name'             => $this->input->post('fund_name'),
      'value'                 => $this->input->post('value'),
      'investment_type'       => $this->input->post('investment_type'),
      'sip_date'              => date('Y-m-d',strtotime($this->input->post('sip_date'))),
      'folio_no'              => $this->input->post('folio_no'),
      'sip_registration'      => $this->input->post('sip_registration'),
      'purpose'               => $this->input->post('purpose'),
      'renewal_status'        => $this->input->post('renewal_status'),
      'hc_remarks'            => $this->input->post('hc_remarks'),
      'rm_comitted_status'    => $this->input->post('rm_comitted_status'),
      'surrender_redeem'      => $this->input->post('surrender_redeem'),
      'app_status'            => $this->input->post('app_status'),
      'hc_email'              => $this->input->post('hc_email'),
      'ecs_cancellation'      => $this->input->post('ecs_cancellation'),
      'other_status'          => $this->input->post('other_status'),
      'rm_remarks'            => $this->input->post('rm_remarks'),
      'created_by'            => $this->session->userdata('emp_id'),
      'created_date'          => date('Y-m-d h:i:s'),
    );

    if($this->Happy_model->save_call($call_data, $lead_id,$product_id)){
      echo json_encode(array('success' => TRUE, 'message' => "Happy Calling Added".' '. $call_data['call_lead_id'], 'id' => $call_data['call_lead_id']));
    }else{
      echo json_encode(array('success' => FALSE, 'message' => $this->lang->line('customers_error_adding_updating').' '.$call_data['call_lead_id']));
    }
  }

  public function get_product(){
    $call_lead_id    =  $this->input->post('call_lead_id');
    $call_product_id =  $this->input->post('call_product_id');
    $product_data = $this->Happy_model->get_product($call_lead_id,$call_product_id);
    echo json_encode(array('status' =>"SUCCESS",'product_edit' => $product_data));
  }
 
  public function update_completed(){
    $count        = $_REQUEST['count'];
    $product_id   = $_REQUEST['product_id'];
    $lead_info_id = $_REQUEST['lead_info_id'];   
    if($this->Happy_model->can_update($product_id)){
      $completed_data = $this->Happy_model->update_completed($count,$product_id,$lead_info_id);
      echo "Lead Completed !!!";
    }else{
      echo "Please update Status properly...";
    }
  }
  
  public function update_freelook(){
    $count        = $_REQUEST['count'];
    $product_id   = $_REQUEST['product_id'];
    $lead_info_id = $_REQUEST['lead_info_id'];   
      $completed_data = $this->Happy_model->update_freelook($count,$product_id,$lead_info_id);
    if($completed_data){
      echo "Lead Completed !!!";
    }else{
      echo "Lead Not Completed...";
    }
    
    
  }
  /*
  public function get_rm_name($person_id){
    $rm_name = $this->Happy_model->get_rm_name($person_id);
    echo $rm_name;
  }
  */
}
?>