Server IP : 103.191.208.50 / Your IP : 216.73.216.53 Web Server : LiteSpeed System : Linux orion.herosite.pro 4.18.0-553.53.1.lve.el8.x86_64 #1 SMP Wed May 28 17:01:02 UTC 2025 x86_64 User : celkcksm ( 1031) PHP Version : 7.4.33 Disable Function : show_source, system, shell_exec, passthru, popen, exec MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/celkcksm/ecampus.ncriptech.com/application/controllers/admin/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php defined('BASEPATH') OR exit('No direct script access allowed'); /** * */ class Agents extends BaseAdminController { function __construct() { parent::__construct(); } function index(){ if($this->data['userdata']->user_type=='student'){ redirect($this->data['base_url']); } if(session_userdata('isAdminLoggedin')){ $this->data['page_title']='Agents'; $this->theme->title($this->data['page_title'])->load('users/vw_agents', $this->data); }else{ redirect($this->data['base_url']); } } function indexBranch(){ if(session_userdata('isAdminLoggedin')){ if($this->data['userdata']->user_type==='institute_branch'){ redirect($this->data['base_url'].'/agents'); }else{ $this->data['page_title']='Branch Agents'; $this->data['branches']=$this->um->get_institute_branch(array('branch_parent_inst_id'=>$this->data['userdata']->user_id),FALSE); $this->theme->title($this->data['page_title'])->load('users/vw_agents_branch', $this->data); } }else{ redirect($this->data['base_url']); } } function indexAddEdit($agent_id=null){ if(session_userdata('isAdminLoggedin')){ $this->data['page_title']='Agents'; $_states=array(); $aadhar_card=$this->data['no_image']; $pan_card=$this->data['no_image']; $profile_photo=$this->data['no_image']; if($agent_id!=null){ $agent_id=decode_data($agent_id); $agent_userdata=$this->um->get_user(array('agent_id'=>$agent_id),'agent'); $aadhar_file=$this->sm->get_file(array('storage_type'=>'aadhar_card','storage_type_of'=>'agent','storage_type_id'=>$agent_userdata->user_id)); $pan_card_file=$this->sm->get_file(array('storage_type'=>'pan_card','storage_type_of'=>'agent','storage_type_id'=>$agent_userdata->user_id)); $profile_photo_file=$this->sm->get_file(array('storage_type'=>'profile_photo','storage_type_of'=>'agent','storage_type_id'=>$agent_userdata->user_id)); if(!empty($aadhar_file)){ if(file_exists(FCPATH.$aadhar_file->media_disk_path)){ $aadhar_card=($aadhar_file->media_mime=='application/pdf')?base_url('uploads/app/pdf.png'):base_url($aadhar_file->media_disk_path_relative); }else{ $aadhar_card=$this->data['no_image']; } }else{ $aadhar_card=$this->data['no_image']; } if(!empty($pan_card_file)){ if(file_exists(FCPATH.$pan_card_file->media_disk_path)){ $pan_card=($pan_card_file->media_mime=='application/pdf')?base_url('uploads/app/pdf.png'):base_url($pan_card_file->media_disk_path_relative); }else{ $pan_card=$this->data['no_image']; } }else{ $pan_card=$this->data['no_image']; } if(!empty($profile_photo_file)){ if(file_exists(FCPATH.$profile_photo_file->media_disk_path)){ $profile_photo=($profile_photo_file->media_mime=='application/pdf')?base_url('uploads/app/pdf.png'):base_url($profile_photo_file->media_disk_path_relative); }else{ $profile_photo=$this->data['no_image']; } }else{ $profile_photo=$this->data['no_image']; } $this->data['agent_data']=$agent_userdata; } $this->data['profile_photo']=$profile_photo; $this->data['aadhar_file']=$aadhar_card; $this->data['pan_card']=$pan_card; $states=$this->sm->_get_states(array('state_country_id'=>'1'),FALSE); if(!empty($states)){ foreach ($states as $key => $value) { $_states[]=array( 'state_id'=>$value->state_id, 'state_name'=>$value->state_name, 'selected'=>(isset($agent_userdata) && ($agent_userdata->agent_state==$value->state_id))?'selected':'' ); } } $this->data['states']=$_states; $this->theme->title($this->data['page_title'])->load('users/vw_agents_add_edit', $this->data); }else{ redirect($this->data['base_url']); } } public function onAddEditAgents(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $institute_data=check_institute($this->data['userdata']); $inst_id=$institute_data['institute_id']; $inst_parent_id=$institute_data['inst_parent_id']; $inst_type=$institute_data['inst_type']; $inst_code=$institute_data['inst_code']; $inst_name=$institute_data['inst_name']; $inst_email=$institute_data['inst_email']; $inst_ph=$institute_data['inst_ph']; $inst_logo_url=$institute_data['inst_logo_url']; $student_upload_limit=$institute_data['student_upload_limit']; $file_error=array(); // $user_id=$this->data['userdata']->user_id; // if($this->data['userdata']->user_type=='institute'){ // $parent_inst_id=$this->data['userdata']->user_id; // }else if($this->data['userdata']->user_type=='institute_branch'){ // $parent_inst_id=$this->data['userdata']->branch_parent_inst_id; // } $agent_id=post_data('_agent'); $agent_name=post_data('agent_name'); $agent_email=post_data('agent_email'); $agent_ph=post_data('agent_phone'); $agent_country=post_data('agent_country'); $agent_state=post_data('agent_state'); $agent_city=post_data('agent_city'); $agent_address=post_data('agent_address'); $agent_password=post_data('agent_password'); $agent_doj=post_data('agent_doj'); $agent_approval=post_data('agent_approval_status'); $agent_status=post_data('agent_status'); $user_id=$this->data['userdata']->user_id; if(empty($agent_id)){ $agent_exists=$this->um->get_agents(array('agent_inst_id'=>$inst_id,'agent_ph'=>$agent_ph)); // print_obj($agent_exists);die; if(empty($agent_exists)){ $agent_data=array( 'agent_inst_type'=>$inst_type, 'agent_inst_id'=>$inst_id, 'agent_inst_parent_id'=>$inst_parent_id, 'agent_code'=>'', 'agent_name'=>$agent_name, 'agent_email'=>$agent_email, 'agent_ph'=>$agent_ph, 'agent_country'=>$agent_country, 'agent_state'=>$agent_state, 'agent_city'=>$agent_city, 'agent_address'=>$agent_address, 'agent_approval_status'=>$agent_approval, 'created_by'=>$user_id, 'created_at'=>date('Y-m-d') ); // print_obj($agent_data); $agent_id=$this->um->store_agents($agent_data); if($agent_id){ $agent_userdata=$this->um->get_user(array('user_name'=>$agent_email),'agent'); if(empty($agent_userdata)){ $password=(!empty($agent_password))?password_hash($agent_password, PASSWORD_BCRYPT, array('cost'=>12)):password_hash('Password@123', PASSWORD_BCRYPT, array('cost'=>12)); $agent_user_data=array( 'user_name'=>$agent_email, 'user_password'=>$password, 'user_password_visible'=>encode_data($agent_password), 'user_type'=>'agent', 'user_status'=>$agent_status, 'created_by_type'=>'institute', 'created_by'=>$user_id, 'created_at'=>date('Y-m-d H:i:s') ); $agent_user_id=$this->um->store_users($agent_user_data); // print("agent_user:"); // print($agent_user_id); // die(); if($agent_user_id){ $agent_code=strtoupper($inst_code).'/'.date('Y').'/AGT'.$agent_user_id; $this->um->update_agents(array('agent_user_id'=>$agent_user_id,'agent_code'=>$agent_code),array('agent_id'=>$agent_id)); $mail_data['inst_id']=$inst_id; $mail_data['mail_from']='webmaster'; $mail_data['to_email']=$agent_email; $mail_data['mail_from_name']=$inst_name; $mail_data['mail_subject']=ucwords($inst_name).' CMS Portal Registration'; $mail_data['mail_type']='html'; $mail_data['mail_custom_type']='html'; $mail_data['mail_data']=array( 'agent_code'=>$agent_code, 'agent_name'=>$agent_name, 'agent_email'=>$agent_email, 'agent_ph'=>$agent_ph, 'user_name'=>$agent_email, 'user_password'=>$agent_password, 'portal_url'=>$this->data['base_url'], 'portal_logo'=>$inst_logo_url, 'portal_inst_name'=>$inst_name, 'access_url'=>$this->data['base_url'], 'college_email'=>$inst_email, 'college_phone'=>$this->data['userdata']->user_contact_no, 'default_logo_small'=>$this->data['default_logo_small'], 'created_at'=>date('Y-m-d') ); $mail_data['log_type']='consultant_account_creation_mail'; $mail_data['mail_view']='_pages/mails/vw_registration_agent_mail'; $mail_msg=$this->onSendMail($mail_data); } } $return['success']='Consultant added successfully.'.$mail_msg; }else{ $return['error']='Consultant not added'; } }else{ $return['error']='Consultant already exists'; } }else{ $agent_id=decode_data($agent_id); $agent_profile_data=$this->um->get_user(array('agent_user_id'=>$agent_id),'agent'); //print_obj($agent_profile_data);die; if(!empty($agent_profile_data)){ $_agent_profile_data=$this->um->get_user(array('agent_user_id!='=>$agent_id,'agent_email'=>$agent_email),'agent'); if(empty($_agent_profile_data)){ $agent_data=array( 'agent_inst_type'=>$inst_type, 'agent_inst_id'=>$inst_id, 'agent_inst_parent_id'=>$inst_parent_id, 'agent_name'=>$agent_name, 'agent_email'=>$agent_email, 'agent_ph'=>$agent_ph, 'agent_country'=>$agent_country, 'agent_state'=>$agent_state, 'agent_city'=>$agent_city, 'agent_address'=>$agent_address, 'agent_approval_status'=>$agent_approval, 'agent_doj'=>date('Y-m-d',strtotime($agent_doj)), 'created_by'=>$user_id, 'created_at'=>date('Y-m-d') ); $updated=$this->um->update_agents($agent_data,array('agent_user_id'=>$agent_id)); if($updated){ if(!empty($agent_password)){ $password=password_hash($agent_password, PASSWORD_BCRYPT, array('cost'=>12)); $agent_user_data=array( 'user_name'=>$agent_profile_data->agent_email, 'user_password'=>$password, 'user_password_visible'=>encode_data($agent_password), 'user_type'=>'agent', 'user_status'=>$agent_status, 'created_by_type'=>'institute', 'created_by'=>$user_id, 'created_at'=>date('Y-m-d H:i:s') ); $this->um->update_users($agent_user_data,array('user_id'=>$agent_profile_data->agent_user_id,'user_type'=>'agent')); $mail_data['inst_id']=$inst_id; $mail_data['mail_from']='webmaster'; $mail_data['to_email']=$agent_profile_data->agent_email; $mail_data['mail_from_name']=$inst_name; $mail_data['mail_subject']=ucwords($inst_name).' CMS Portal Account Reset'; $mail_data['mail_type']='html'; $mail_data['mail_custom_type']='html'; $mail_data['mail_data']=array( 'agent_code'=>$agent_profile_data->agent_code, 'agent_name'=>$agent_profile_data->agent_name, 'agent_email'=>$agent_profile_data->agent_email, 'agent_ph'=>$agent_profile_data->agent_ph, 'user_name'=>$agent_profile_data->agent_email, 'user_password'=>$agent_password, 'portal_url'=>$this->data['base_url'], 'portal_logo'=>$inst_logo_url, 'portal_inst_name'=>$inst_name, 'access_url'=>$this->data['base_url'], 'college_email'=>$inst_email, 'college_phone'=>$inst_ph, 'default_logo_small'=>$inst_logo_url, 'created_at'=>date('Y-m-d') ); $mail_data['log_type']='consultant_account_updation_mail'; $mail_data['mail_view']='_pages/mails/vw_registration_agent_mail'; $mail_msg=$this->onSendMail($mail_data); } if(isset($_FILES['agent_aadhar_card']) && $_FILES['agent_aadhar_card']['name']!=''){ $aadhar_card_file=array( 'file_size'=>'0.05', 'file_name'=>'agent_aadhar_card', 'file_types'=>'png,jpg,jpeg,pdf', 'file_type_of'=>'agent', 'file_storage_type'=>'aadhar_card', 'file_storage_dir'=>$storage_dir, 'file_storage_type_id'=>$agent_id, 'file_parent_id'=>$inst_id, 'file_compress'=>false, 'file_operation_type'=>'update', 'file_uploaded_by'=>$user_id ); $aadhar_card_file_id=$this->onUploadFiles($aadhar_card_file); if(!is_numeric($aadhar_card_file_id)){ $file_error[]='AADHAR Card '.$aadhar_card_file_id; } } if(isset($_FILES['agent_pan_card']) && $_FILES['agent_pan_card']['name']!=''){ $pan_card_file=array( 'file_size'=>'0.01', 'file_name'=>'agent_pan_card', 'file_types'=>'png,jpg,jpeg,pdf', 'file_type_of'=>'agent', 'file_storage_type'=>'pan_card', 'file_storage_dir'=>$storage_dir, 'file_storage_type_id'=>$agent_id, 'file_parent_id'=>$inst_id, 'file_compress'=>false, 'file_operation_type'=>'update', 'file_uploaded_by'=>$user_id ); $pan_card_file_id=$this->onUploadFiles($pan_card_file); if(!is_numeric($pan_card_file_id)){ $file_error[]='PAN Card '.$pan_card_file_id; } } if(isset($_FILES['agent_profile_file']) && $_FILES['agent_profile_file']['name']!=''){ $agent_profile_file=array( 'file_size'=>'0.01', 'file_name'=>'agent_profile_file', 'file_types'=>'png,jpg,jpeg,pdf', 'file_type_of'=>'agent', 'file_storage_type'=>'profile_photo', 'file_storage_dir'=>$storage_dir, 'file_storage_type_id'=>$agent_id, 'file_parent_id'=>$inst_id, 'file_compress'=>false, 'file_operation_type'=>'update', 'file_uploaded_by'=>$user_id ); $agent_profile_file_id=$this->onUploadFiles($agent_profile_file); if(!is_numeric($agent_profile_file_id)){ $file_error[]='Profile Photo '.$agent_profile_file_id; } } $return['success']='Consultant data updated successfully.'; $return['file_error']=$file_error; }else{ $return['error']='Consultant data not updated'; } }else{ $return['error']='Another consultant exists with the same email'; } }else{ $return['error']='Consultant not updated'; } } json_headers($return); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onSearchAgentsList(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ if($this->input->is_ajax_request() && $this->input->server('REQUEST_METHOD')=='POST'){ $db_group=$this->data['userdata']->user_code; $param['column_order'] = array( null, 'agent_name' ); // $param['inst_id']=$this->data['userdata']->user_id; $param['column_search'] = array('agent_name'); $param['order'] = array('agent_id' => 'ASC'); $posts=$this->input->post(); if($posts['data_of']==='own'){ $param['inst_id']=$this->data['userdata']->user_id; }else if($posts['data_of']==='branch'){ $param['inst_parent_id']=$this->data['userdata']->user_id; } if(isset($posts['data_of_id']) && !empty($posts['data_of_id'])){ $param['inst_id']=$posts['data_of_id']; } if(isset($posts['agent_approval_status']) && !empty($posts['agent_approval_status'])){ $param['agent_approval_status']=$posts['agent_approval_status']; } $list = $this->um->_get_agents($posts,$param,FALSE,FALSE,$db_group); //print_obj($list);die; $data = array(); $no = isset($posts['start'])?$posts['start']:0; $action=''; foreach ($list as $agent){ $no++; $row = array(); $agent_image=$this->sm->get_file(array('storage_type'=>'agent_profile_photo','storage_type_id'=>$agent->agent_user_id,'storage_parent_id'=>$agent->agent_inst_id)); if(!empty($agent_image) && is_file(FCPATH.$agent_image->media_disk_path)){ $image=$this->data['base_url'].$agent_image->media_disk_path; }else{ $image=$this->data['no_image']; } $row[] = $no; $row[] = '<img src="'.$image.'" height="30px;" width="30px;">'; $row[] = $agent->agent_name; $row[] = $agent->agent_email; $row[] = $agent->agent_ph; // $row[] = $agent->agent_city; //$row[] = $agent->state_name; if($agent->agent_approval_status=='approved'){ $approval_status='<span class="badge badge-sm badge-success">Approved</span>'; }else if($agent->agent_approval_status=='disapproved'){ $approval_status='<span class="badge badge-sm badge-danger">Not Approved</span>'; } $row[] = $approval_status; if($posts['data_of']==='own'){ if($agent->agent_approval_status=='approved'){ $row[] = '<a class="btn btn-xs btn-dark" href="'.$this->data['base_url'].'/payments/agents/'.encode_data($agent->agent_user_id).'">Payments</a> <a class="btn btn-xs btn-dark" href="'.$this->data['base_url'].'/agents/add/'.encode_data($agent->agent_id).'"><i class="fa fa-edit"></i></a> <button type="button" class="btn btn-xs btn-danger" data-agent_id="'.encode_data($agent->agent_id).'"><i class="fa fa-trash"></i></button>'; }else{ $row[] = '<a class="btn btn-xs btn-dark" href="'.$this->data['base_url'].'/agents/add/'.encode_data($agent->agent_id).'"><i class="fa fa-edit"></i></a> <button type="button" class="btn btn-xs btn-danger" data-agent_id="'.encode_data($agent->agent_id).'"><i class="fa fa-trash"></i></button>'; } } $data[] = $row; } $output = array( "draw" => isset($posts['draw'])?$posts['draw']:'', "recordsTotal" => $this->um->_get_agents($posts,$param,TRUE,FALSE,$db_group), "recordsFiltered" => $this->um->_get_agents($posts,$param,TRUE,FALSE,$db_group), "data" => $data, ); echo json_encode($output); }else{ redirect($this->data['base_url']); } }else{ redirect($this->data['base_url']); } } public function onCheckEmailExists(){ if(session_userdata('isAdminLoggedin')==TRUE && session_userdata('admin_id')){ $agent_email=post_data('agent_email'); $agent_data=$this->um->get_user(array('agent_email'=>$agent_email),'agent'); if(!empty($agent_data)){ echo false; }else{ echo 'true'; } } } }