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/Mis.php
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
	require_once("Secure_Controller.php");
	class Mis extends Secure_Controller{
		public function __construct(){
			parent::__construct('mis');
			$this->load->model('Mis_model');
			$this->load->model('All_leads_model');
		}
		public function index(){
			if(!$this->Appconfig->isAppvalid()){
				redirect('config');
			}
			$data['table_headers'] = $this->xss_clean(get_mis_table_headers());
			// $data = "";
			$this->load->view('mis/manage',$data);
		}
		public function search() //to get table row, its going to helpers/table_helper
		{
			$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);
			
			$filters_mis = $this->input->get('filters_mis');

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

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

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

			$data_rows[] = get_mis_data_row($leads, $this);
			}

			echo json_encode(array('total' => $total_rows, 'rows' => $data_rows));
		}
		public function view($lead_id = -1){
			//MIS Start
			$info = $this->All_leads_model->get_info($lead_id);
			foreach(get_object_vars($info) as $property => $value)
			{
				$info->$property = $this->xss_clean($value);
			}
			$data['lead_info'] = $info;
			$data['family_info'] = $this->Mis_model->get_family_list($lead_id);
			$data['product_list'] = $this->Mis_model->get_product_list($lead_id);

			$met_info = $this->All_leads_model->get_met_log($lead_id);
			$data['met_info'] = $met_info;

			$type_info[""] = "---- Select Lead Type ----";
			foreach($this->All_leads_model->get_lead_type() as $row){
				$type_info[$this->xss_clean($row->lead_type_id)] = $this->xss_clean($row->lead_type);
			}
			$data['lead_type'] = $type_info;

			$bank_info[""] = "---- Select Bank Name ----";
			foreach($this->Mis_model->get_bank_info() as $row){
				$bank_info[$this->xss_clean($row->bank_id)] = $this->xss_clean($row->bank_name);
			}
			$data['bank_info'] = $bank_info;

			$status_info[""] = "---- Select Lead Status ----";
			foreach($this->All_leads_model->get_status() as $row){
				$status_info[$this->xss_clean($row->status_id)] = $this->xss_clean($row->statusname);
			}
			$data['lead_status'] = $status_info;

			$company_info[""] = "---- Select Company ----";
			foreach($this->Mis_model->get_company($lead_id)->result_array() as $row){

				$company_info[$this->xss_clean($row['vendor_id'])] = $this->xss_clean($row['vendorcompanyname']);
			}
			$data['company_info'] = $company_info;

			$product_info[""] = "---- Select Product ----";
			foreach($this->Mis_model->get_mis_product()->result_array() as $row){

				$product_info[$this->xss_clean($row['product_id'])] = $this->xss_clean($row['product_name']);
			}
			$data['product_info'] = $product_info;

			$prospect_info[""] = "---- Select Prospect----";
			foreach($this->All_leads_model->get_prospect()->result_array() as $row){

				$prospect_info[$this->xss_clean($row['prospect_id'])] = $this->xss_clean($row['prospect_name']);
			}
			$data['prospect'] = $prospect_info;

			$crm_info[""] = "---- Select CRM----";
			foreach($this->All_leads_model->get_crm()->result_array() as $row){

				$crm_info[$this->xss_clean($row['id'])] = $this->xss_clean($row['first_name']);
			}
			$data['crm_info'] = $crm_info;

			$rm_info[""] = "---- Select RM----";
			foreach($this->All_leads_model->get_rm()->result_array() as $row){

				$rm_info[$this->xss_clean($row['id'])] = $this->xss_clean($row['first_name']);
			}
			$data['rm_info'] = $rm_info;

			$login_info[""] = "---- Select Login Code ----";
			foreach($this->Mis_model->get_login_code()->result_array() as $row){

				$login_info[$this->xss_clean($row['code_id'])] = $this->xss_clean($row['company_code']);
			}
			$data['login_code'] = $login_info;

			$fund_name[""] = "---- Select Fund Name ----";
			foreach($this->Mis_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->Mis_model->get_amc() as $row){
				$amc[$this->xss_clean($row->id)] = $this->xss_clean($row->amc);
			}
			$data['amc'] = $amc;    
			//MIS End
		$this->load->view("mis/form", $data);
		}
		public function view_login($cust_id){
			$data['cust_info'] = $this->Mis_model->cust_info($cust_id);
			$data['family_info'] = $this->Mis_model->get_view_family($cust_id);
			$data['login_history'] = $this->Mis_model->view_login($cust_id);   

			$this->load->view("mis/form_login", $data);
		}
		public function get_amc($fund_id){
			$amc = $this->Mis_model->get_amc($fund_id);
			echo json_encode(array('status' =>"SUCCESS",'amc' => $amc));
		}

		public function get_company($id){
			$company = $this->Mis_model->get_company_list($id);
			echo json_encode(array('status' =>"SUCCESS",'company' => $company));
		}
		public function get_code($id){
			$code = $this->Mis_model->get_code_list($id);
			echo json_encode(array('status' =>"SUCCESS",'code' => $code));
		}

		public function get_company_product($id){
			$product = $this->Mis_model->get_company_product($id);
			echo json_encode(array('status' =>"SUCCESS",'product' => $product));
		}

		public function save_custinfo($leads_info = -1){
			$cust_id = $this->input->post('cust_id');
			$customer_data = array(
			'cust_name'    => $this->input->post('cust_name'),
			'dob'          => date('Y-m-d',strtotime($this->input->post('dob'))),
			'cust_mobile'  => $this->input->post('cust_mobile'),
			'alter_mobile' => $this->input->post('alter_mobile'),
			'cust_email'   => $this->input->post('cust_email'),
			'cust_address' => $this->input->post('cust_address'),
			'permanent_address'  => $this->input->post('permanent_address'),
			'pan_no'       => $this->input->post('pan_no'),
			'aadhaar_no'   => $this->input->post('aadhaar_no'),
			'income'       => $this->input->post('income'),
			'profile'      => $this->input->post('profile'),
			'office'       => $this->input->post('office'),
			'industry'     => $this->input->post('industry'),
			'designation'  => $this->input->post('designation'),
			'marrital'     => $this->input->post('marrital'),
			'id_proof'         => $this->input->post('hid_id_proof'),
			'address_proof'    => $this->input->post('hid_address_proof'),
			'income_proof'     => $this->input->post('hid_income_proof'),
			'bank_cheque'      => $this->input->post('hid_bank_cheque_proof'),
			'mf_pan'           => $this->input->post('hid_mf_pan_proof'),
			'updated_by'   => $this->session->userdata('emp_id'),
			'updated_date' => date('Y-m-d h:i:s'),
			);
			$cust_name = $this->input->post('cust_name');
			$cust_data = $this->Mis_model->lead_update_customer($customer_data, $cust_id);

			$cust_info = array(
			'cust_id'        => $this->input->post('cust_id'),
			'lead_id'        => $leads_info,
			'fam_name'       => $this->input->post('cust_name'),
			'fam_dob'        => date('Y-m-d',strtotime($this->input->post('dob'))),
			'fam_relation'   => "Self",
			'fam_profile'    => $this->input->post('profile'),
			'fam_sex'        => "Self",
			'created_by'     => $this->session->userdata('emp_id'),
			'created_date'   => date('Y-m-d h:i:s'),
			);
			$family_data = $this->Mis_model->update_customer_info($cust_info,$leads_info);
			echo json_encode(array('success' => TRUE, 'message' => "$cust_name Personal Information updated"));

		}
		public function save_family(){
			$cust_id = $this->input->post('cust_id');
			$lead_id = $this->input->post('lead_id');
			$family_id = $this->input->post('family_id');

			$family_data = array(
			'cust_id'        => $this->input->post('cust_id'),
			'lead_id'        => $this->input->post('lead_id'),
			'fam_name'       => $this->input->post('fam_name'),
			'fam_dob'        => date('Y-m-d',strtotime($this->input->post('fam_dob'))),
			'fam_relation'   => $this->input->post('fam_relation'),
			'fam_profile'    => $this->input->post('fam_profile'),
			'fam_sex'        => $this->input->post('fam_sex'),
			'created_by'     => $this->session->userdata('emp_id'),
			'created_date'   => date('Y-m-d h:i:s'),
			);
			$family_data = $this->Mis_model->lead_save_family($family_data,$lead_id,$family_id);
			echo json_encode(array('status' =>"SUCCESS",'family_data' => $family_data));
		}
		public function save_product($category){
			//$dbcategory = $this->input->post('product_cat');
			$login_date          = date('Y-m-d',strtotime($this->input->post('login_date')));
			$login_code          = $this->input->post('login_code');
			$company             = $this->input->post('vendorcompanyname');
			$customer_product_id = $this->input->post('customer_product_id');
			$nominee             = $this->input->post('nominee');
			$product             =  $this->input->post('form_product');

			if($category === "1"){
				$dbcategory = "3";
			}else
			if($category === "2"){
				$dbcategory = "2";
			}else
			if($category === "3"){
				$nominee    = $this->input->post('mf_nominee');
				$login_date = date('Y-m-d',strtotime($this->input->post('mf_login_date')));
				$login_code = $this->input->post('mf_login_code');
				$company    = $this->input->post('mf_vendorcompanyname');
				$product    =  $this->input->post('mf_investment');

				$dbcategory = "4";
			}else
			if($category === "4"){
				$dbcategory = "5";
			}
			$cust_id = $this->input->post('cust_id');
			$lead_id = $this->input->post('lead_id');
			$net_premium = $this->input->post('net_premium');
			$rider_net_premium   = $this->input->post('rider_net_premium');
			$total_premium       = $this->input->post('total_premium');
			$rider_total_premium = $this->input->post('rider_total_premium');
			$overall_net         = $net_premium + $rider_net_premium;
			$overall_tot         = $total_premium + $rider_total_premium;
			
			$product_data = array(
			'lead_info_id'          => $this->input->post('lead_type_id'),
			'product_category'      => $dbcategory,
			'login_date'            => $login_date,
			'login_code'            => $login_code,
			'company'               => $company,
			'product'               => $product,
			'proposer'              => $this->input->post('proposer'),
			'life_assured'          => implode(',',$this->input->post('life_assured')),
			'nominee'               => $nominee,
			'sum_assured'           => $this->input->post('sum_assured'),
			'mode'                  => $this->input->post('mode'),
			'net_premium'           => $net_premium,
			'gst'                   => $this->input->post('gst'),
			'total_premium'         => $this->input->post('total_premium'),
			'rider_net_premium'     => $this->input->post('rider_net_premium'),
			'rider_gst'             => $this->input->post('rider_gst'),
			'rider_total_premium'   => $this->input->post('rider_total_premium'),
			'overall_net_premium'   => $overall_net,
			'overall_total_premium' => $overall_tot,
			'rider_total_premium'   => $this->input->post('rider_total_premium'),
			'policy_term'           => $this->input->post('policy_term'),
			'paying_term'           => $this->input->post('paying_term'),
			'rider'                 => $this->input->post('rider'),
			'rider_name'            => $this->input->post('rider_name'),
			'ecs'                   => $this->input->post('ecs'),
			'ecs_date'              => date('Y-m-d',strtotime($this->input->post('ecs_date'))),
			'paid_by'               => $this->input->post('paid_by'),
			'age_band'              => $this->input->post('age_band'),
			'mf_contact'            => $this->input->post('mf_contact'),
			'mf_fund'               => $this->input->post('mf_fund'),
			'mf_amc'                => $this->input->post('mf_amc'),
			'mf_fund_name'          => $this->input->post('mf_fund_name'),
			'mf_fundtype'           => $this->input->post('mf_fundtype'),
			'mf_amount'             => $this->input->post('mf_amount'),
			'bank_name'             => $this->input->post('bank_name'),
			'bank_acc_no'           => $this->input->post('bank_acc_no'),
			'bank_ifsc'             => $this->input->post('bank_ifsc'),      
			'mf_investment'         => $this->input->post('mf_investment'),
			'sip_date'              => $this->input->post('sip_date'),
			'mf_kyc'                => $this->input->post('mf_kyc'),
			'mf_purpose'            => $this->input->post('mf_purpose'),
			'created_by'            => $this->session->userdata('emp_id'),
			'created_date'          => date('Y-m-d h:i:s'),
			);

			$product_data = $this->Mis_model->lead_save_product($product_data,$lead_id,$customer_product_id);

			echo json_encode(array('status' =>"SUCCESS",'product_data' => $product_data));
		}
		public function get_product($product_id){
			$product_data = $this->Mis_model->get_product($product_id);
			//print_r($product_data); die;
			echo json_encode(array('status' =>"SUCCESS",'product_edit' => $product_data));
		}

		public function update_happycalling(){
			$count        = $_REQUEST['count'];
			$product_id   = $_REQUEST['product_id'];
			$lead_info_id = $_REQUEST['lead_info_id'];
			$completed_data = $this->Mis_model->update_completed_status($count,$product_id,$lead_info_id);
			echo $completed_data;
		}
		public function get_family_person(){
			$family_id = $_REQUEST['family_id'];
			$person_data = $this->Mis_model->get_family_person($family_id);
			echo json_encode(array('status' =>"SUCCESS",'person_data' => $person_data));
		}
		public function remove_family_person(){
			$family_id = $_REQUEST['family_id'];
			$lead_id   = $_REQUEST['lead_id'];

			$family_data = array(
			'deleted'        => '1',
			'deleted_by'     => $this->session->userdata('emp_id'),
			'deleted_date'   => date('Y-m-d h:i:s'),
			);
			$this->Mis_model->remove_family_person($family_id,$family_data);
			$person_data = $this->Mis_model->get_family_list($lead_id);
			echo json_encode(array('status' =>"SUCCESS",'person_data' => $person_data));
		}
		public function refresh_family_person(){
			$lead_id   = $_REQUEST['lead_id'];
			$person_data = $this->Mis_model->get_family_list($lead_id);
			echo json_encode(array('status' =>"SUCCESS",'person_data' => $person_data));
		}
		public function delete_product(){
			$product_id = $_REQUEST['product_id'];
			$lead_id    = $_REQUEST['lead_id'];

			$product_data = array(
			'status'        => '0',
			'deleted_by'     => $this->session->userdata('emp_id'),
			'deleted_date'   => date('Y-m-d h:i:s'),
			);
			$this->Mis_model->delete_product($product_id,$product_data,$lead_id);
			$product = $this->Mis_model->get_product_list($lead_id);
			echo json_encode(array('status' =>"Product Successfully Deleted",'product' => $product));
		}
		public function delete_doc(){
			$cust_id = $_REQUEST['cust_id'];
			$id    = $_REQUEST['id'];
			$doc = $this->Mis_model->delete_doc($cust_id,$id);
			echo json_encode(array('status' =>"File Successfully Deleted",'doc' => $doc));
		}
		public function get_product_gst(){
			$product = $_REQUEST['product'];
			$gst_info     = $this->Mis_model->get_product_gst($product);
			$gst     = $gst_info->gst;
			echo $gst;
		}
		//HC Start
		public function save_hc(){ 
			$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('hc_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'),
			);
			
			
			$product = $this->Mis_model->save_call($call_data, $lead_id,$product_id);
			if($product){
				echo json_encode(array('status' =>"Product Successfully Added",'product_data' => $product));
			}else{
				echo json_encode(array('status' =>"Technical Error",'product_data' => $product));
			}
			/*
			if($this->Mis_model->save_call($call_data, $lead_id,$product_id)){
				$product = $this->Mis_model->get_product_list($lead_id);
			   echo json_encode(array('status' =>"Product Successfully Added",'product' => $product));
				//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_hc_product(){
			$call_lead_id    =  $this->input->post('call_lead_id');
			$call_product_id =  $this->input->post('call_product_id');
			$product_data = $this->Mis_model->get_hc_product($call_lead_id,$call_product_id);
			echo json_encode(array('status' =>"SUCCESS",'product_edit' => $product_data));
		}
		public function get_rm_name($person_id){
			$rm_name = $this->Mis_model->get_rm_name($person_id);
			echo $rm_name;
		}
		public function update_completed(){
			$count        = $_REQUEST['count'];
			$product_id   = $_REQUEST['product_id'];
			$lead_info_id = $_REQUEST['lead_info_id'];   
			if($this->Mis_model->can_update($product_id)){
				$completed_data = $this->Mis_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...";
			}
		}
		*/
	}
?>