policybot/application/controllers/Frontend.php

1426 lines
43 KiB
PHP
Raw Permalink Normal View History

2021-11-30 10:56:55 +00:00
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Frontend extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('Frontend_model');
$this->load->model('Company_model');
$this->load->model('Category_model');
}
function home()
{
$data['pol']=$this->Frontend_model->list_policy();
$this->load->view('front/index',$data);
}
function becoame_agent()
{
if($this->input->post('becomeagent'))
{
$fullname = $this->input->post('agent_name');
$email = $this->input->post('agent_email');
$mobile = $this->input->post('agent_mobile');
$pincode = $this->input->post('agent_pincode');
$agent_cmp = $this->input->post('agent_cmp');
$agent_cat = $this->input->post('agent_cat');
$agent_lang = $this->input->post('agent_lang');
$password = $this->input->post('agent_pass');
$conform_password = $this->input->post('agent_cpass');
$lang =array();
foreach($agent_lang as $key=>$val)
{
$lang[]=$agent_lang[$key];
}
$lang_res= implode(', ', $lang);
$cat =array();
foreach($agent_cat as $key=>$val)
{
$cat[]=$agent_cat[$key];
}
$cat_res= implode(', ', $cat);
$table="users";
$values=array('userrole'=>1,//agent
'name'=>$fullname,
'email'=>$email,
'password'=>md5($password),
'mobile'=>$mobile,
'pincode'=>$pincode,
'cdate'=>date('Y-m-d H:i:s'),
'status'=>0);
$result=$this->commonsql_model->insert_table($table,$values);
$agent_id=$this->db->insert_id();
$table="agents";
$values=array('user_id'=>$agent_id,//agent
'category'=>$cat_res,
'racetype'=>$lang_res,
'pincode'=>$pincode,
'company'=>$agent_cmp,
'category_notify'=>0,//initially 0 for chance to edit once
'racetype_notify'=>0,//initially 0 for chance to edit once
'company_notify'=>0,//initially 0 for chance to edit once
'status'=>0);
$result=$this->commonsql_model->insert_table($table,$values);
$from_email = "kaleeswari.dotwings@gmail.com";
$to_email = $email;
//Load email library
$this->load->library('email');
$this->email->from($from_email, 'Policybot');
$this->email->to($to_email);
$this->email->set_header('Content-Type', 'text/html');
$this->email->subject('Policybot Email Verification');
$this->email->message('
<h2>Verify Your Email Account</h2>
<p>Hai '.$fullname.'<br><br>Thank you for Showing interest with us.</p>
<p>Please click the below button to verify your email.</p>
<a href='.base_url().'frontend/agentemailactivate/'.$agent_id.'><button type="button" style="color: #fff; background-color: #5bc0de;border-color: #46b8da; font-size: 14px;font-weight: 900; text-align:center;padding: 6px 12px; border-radius: 20px">Activate !</button></a>
');
$emailsent=$this->email->send();
if($emailsent)
{
$this->session->set_userdata('suc','Registeration completed successfully.Kindly verify your mail to activate this account..!');
redirect('home');
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('home');
}
}
$data['cmp']=$this->Company_model->list_cmp();
$data['cat']=$this->Category_model->list_cat();
$data['race']=$this->Frontend_model->agent_racetype();
$this->load->view('front/become_agent',$data);
}
function list_policy()
{
$data['pol']=$this->Frontend_model->list_policy();
$this->load->view('front/policy-list',$data);
}
function policy_detail($id)
{
$data['pol']=$this->Frontend_model->list_policy($id);
$data['pols']=$this->Frontend_model->list_policy();
$this->load->view('front/policy-detail',$data);
}
function emailcheck()
{
$email=$_POST['email'];
$tables="users";
$wheres=array("email"=>$email);
$shows=("*");
$emailex=$this->commonsql_model->selectTable($tables,$wheres,$shows);
if($emailex->num_rows()>0){
echo "1";
}
else
{
echo "2";
}
}
function enq_emailcheck()
{
$email=$_POST['email'];
$tables="users";
$wheres=array("email"=>$email);
$shows=("*");
$emailex=$this->commonsql_model->selectTable($tables,$wheres,$shows);
if($emailex->num_rows()>0){
$ee=$emailex->row();
$estatus=$ee->status;
$id=$ee->id;
if($estatus=="1")
{
echo "1_".$id;
}
if($estatus=="0")
{
echo "2_0";
}
}
else
{
echo "3_0";
}
}
function register()
{
$fullname = $this->input->post('rfullname');
$email = $this->input->post('remail');
$mobile = $this->input->post('rmobile');
$pincode = $this->input->post('rpincode');
$password = $this->input->post('password');
$conform_password = $this->input->post('conform_password');
$table="users";
$values=array('userrole'=>0,//user
'name'=>$fullname,
'email'=>$email,
'password'=>md5($password),
'mobile'=>$mobile,
'pincode'=>$pincode,
'cdate'=>date('Y-m-d H:i:s'),
'status'=>0);
$result=$this->commonsql_model->insert_table($table,$values);
$userid=$this->db->insert_id();
$from_email = "kaleeswari.dotwings@gmail.com";
$to_email = $email;
//Load email library
$this->load->library('email');
$this->email->from($from_email, 'Policybot');
$this->email->to($to_email);
;
$this->email->set_header('Content-Type', 'text/html');
$this->email->subject('Policybot Email Verification');
$this->email->message('
<h2>Verify Your Email Account</h2>
<p>Hai '.$fullname.'<br><br>Thank you for Showing interest with us.</p>
<p>Please click the below button to verify your email.</p>
<a href='.base_url().'frontend/emailactivate/'.$userid.'><button type="button" style="color: #fff; background-color: #5bc0de;border-color: #46b8da; font-size: 14px;font-weight: 900; text-align:center;padding: 6px 12px; border-radius: 20px">Activate !</button></a>
');
$emailsent=$this->email->send();
if($emailsent)
{
$this->session->set_userdata('suc','Registeration completed successfully.Kindly verify your mail to activate this account..!');
redirect('home');
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('home');
}
}
function emailactivate($uid)
{
$table="users";
$where=array("id"=>$uid);
$values=array(
'status'=>1);
$result=$this->commonsql_model->updateTable($table,$where,$values);
if($result)
{
$this->session->set_userdata('suc','Your user account has been activated...!');
redirect('home');
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('home');
}
}
function agentemailactivate($aid)
{
$table="users";
$where=array("id"=>$aid);
$values=array(
'status'=>1);
$result=$this->commonsql_model->updateTable($table,$where,$values);
$table="agents";
$where=array("user_id"=>$aid);
$values=array(
'status'=>1);
$result=$this->commonsql_model->updateTable($table,$where,$values);
if($result)
{
$this->session->set_userdata('suc','Your user account has been activated...!');
redirect('home');
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('home');
}
}
function logincheck()
{
$username = $this->input->post('loginemail');
$password = $this->input->post('loginpassword');
$check_user=$this->Frontend_model->frontusercheck($username,$password);
//echo $this->db->last_query();exit;
if($check_user->num_rows()>0)
{
$ch = $check_user->row();
$status=$ch->status;
if($status=="0")
{
$this->session->set_userdata('err','Please activate your account and login again..!');
redirect('home');
}
else
{
$this->session->set_userdata('primaryid',$ch->id);
$this->session->set_userdata('userrole',$ch->userrole);
$this->session->set_userdata('loggedname',$ch->name);
$this->session->set_userdata('loggedmobile',$ch->mobile);
$this->session->set_userdata('loggedpincode',$ch->pincode);
$this->session->set_userdata('loggeddob',"");
$this->session->set_userdata('loggedgender',"");
$this->session->set_userdata('loggedcarno',"");
$this->session->set_userdata('loggedbikeno',"");
$this->session->set_userdata('loggedcompanyno',"");
$this->session->set_userdata('loggedcountry',"");
$this->session->set_userdata('loggedleavingdate',"");
$this->session->set_userdata('loggedreturndate',"");
$this->session->set_userdata('suc','Successfully Logged in..!');
redirect('front-dashboard');
}
}
else
{
$this->session->set_userdata('err','The username or password you entered is incorrect.');
redirect('home');
}
}
function dashboard()
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
$this->load->view('front/ua-dashboard');
}
function user_logout()
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
$session_data=array('primaryid'=>'');
$session_data=array('userrole'=>'');
$session_data=array('loggedname'=>'');
$this->session->unset_userdata($session_data);
$res=$this->session->sess_destroy();
if($res)
{
$this->session->set_userdata('suc','Logged Out Successfully..!');
redirect('home');
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('home');
}
}
function agent_logout()
{
$session_data=array('primaryid'=>'');
$session_data=array('userrole'=>'');
$session_data=array('loggedname'=>'');
$this->session->unset_userdata($session_data);
$this->session->sess_destroy();
redirect('home');
}
function add_wish($uid,$pid)
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
$table="wishlist";
$values=array('user_id'=>$uid,//user
'policy_id'=>$pid,
'cdate'=>date('Y-m-d H:i:s'),
'status'=>1);
$result=$this->commonsql_model->insert_table($table,$values);
if($result)
{
$this->session->set_userdata('suc','Added to your wishlist...!');
redirect('policy-detail/'.$pid);
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('policy-detail/'.$pid);
}
}
function remove_wish($uid,$pid)
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
$table="wishlist";
$where=array("user_id"=>$uid,"policy_id"=>$pid);
$values=array(
'status'=>0);
$result=$this->commonsql_model->updateTable($table,$where,$values);
if($result)
{
$this->session->set_userdata('suc','Removed from your wishlist...!');
redirect('policy-detail/'.$pid);
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('policy-detail/'.$pid);
}
}
function user_profile()
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
$this->load->view('front/user-profile');
}
function user_editprofile()
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
if($this->input->post('submit'))
{
$primaryid=$this->input->post('primaryid');
$fullname=$this->input->post('fullname');
$mobile=$this->input->post('mobile');
$pincode=$this->input->post('pincode');
$address=$this->input->post('address');
$oldprofile=$this->input->post('oldprofile');
$profiles=$this->input->post('profiles');
$old_pass=$this->input->post('old_pass');
$change_passwords=$this->input->post('change_passwords');
$conform_passwords=$this->input->post('conform_passwords');
if($change_passwords==""){ $pass=$old_pass; }
else{ $pass=md5($change_passwords); }
if($profiles=="") {
$simage=$oldprofile;
}
if (!is_dir('uploads/userprofile')) {
mkdir('./uploads/userprofile', 0777, TRUE);
}
$valid_extensions = array('jpeg', 'jpg', 'png'); // valid extensions
$path = 'uploads/userprofile/'; // upload directory
if($_FILES['profiles'])
{
$img = $_FILES['profiles']['name'];
$tmp = $_FILES['profiles']['tmp_name'];
// get uploaded file's extension
$ext = strtolower(pathinfo($img, PATHINFO_EXTENSION));
// can upload same image using rand function
$final_image = "Image".rand(1000,1000000).$img;
// check's valid format
if(in_array($ext, $valid_extensions))
{
$simage = $path.strtolower($final_image);
if(move_uploaded_file($tmp,$simage))
{}} }
$table="users";
$where=array("id"=>$primaryid);
$values=array('name'=>$fullname,
'mobile'=>$mobile,
'pincode'=>$pincode,
'address'=>$address,
'profilepic'=>$simage,
'password'=>$pass,
'status'=>1);
$result=$this->commonsql_model->updateTable($table,$where,$values);
if($result)
{
$this->session->set_userdata('suc','Profile updated successfully...!');
redirect('front-dashboard');
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('front-dashboard');
}
}
}
function favourites()
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
$this->load->view('front/user-favourites');
}
function remocefavoyrite()
{
$wid=$_POST["wid"];
$table="wishlist";
$where=array("id"=>$wid);
$values=array(
'status'=>0);
$result=$this->commonsql_model->updateTable($table,$where,$values);
if($result)
{
echo "1";
}
else
{
echo "2";
}
}
function agent_profile()
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
$id=$this->session->userdata('primaryid');
$data['age']=$this->Frontend_model->agent_detail($id);
$data['cmp']=$this->Company_model->list_cmp();
$data['cat']=$this->Category_model->list_cat();
$data['race']=$this->Frontend_model->agent_racetype();
$this->load->view('front/agent-profile',$data);
}
function agent_edit_profile()
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
if($this->input->post('submit'))
{
$oldprofile=$this->input->post('oldprofile');
$profiles=$this->input->post('input6');
$old_pass=$this->input->post('old_pass');
$change_passwords=$this->input->post('change_passwords');
$conform_passwords=$this->input->post('conform_passwords');
if($change_passwords==""){ $pass=$old_pass; }
else{ $pass=md5($change_passwords); }
if($profiles=="") {
$simage=$oldprofile;
}
$primaryid=$this->input->post('primaryid');
$agent_code=$this->input->post('agent_code');
$fullname=$this->input->post('fullname');
$email=$this->input->post('email');
$exper_number=$this->input->post('exper_number');
$ex_period=$this->input->post('ex_period');
$intro=$this->input->post('intro');
$mobile=$this->input->post('mobile');
$pincode=$this->input->post('pincode');
$country=$this->input->post('country');
$city=$this->input->post('city');
$state=$this->input->post('state');
$address=$this->input->post('address');
$agent_cmp=$this->input->post('agent_cmp');
$agent_cat=$this->input->post('agent_cat');
$agent_lang=$this->input->post('agent_lang');
$oldcategory=$this->input->post('oldcategory');
$oldcompany=$this->input->post('oldcompany');
$oldrace=$this->input->post('oldrace');
$category_notify=$this->input->post('category_notify');
$racetype_notify=$this->input->post('racetype_notify');
$company_notify=$this->input->post('company_notify');
$experience=$exper_number." ".$ex_period;
$lang =array();
foreach($agent_lang as $key=>$val)
{
$lang[]=$agent_lang[$key];
}
$lang_ress= implode(', ', $lang);
$cat =array();
foreach($agent_cat as $key=>$val)
{
$cat[]=$agent_cat[$key];
}
$cat_ress= implode(', ', $cat);
//status 1
$catstatus=$category_notify;
$racestatus=$racetype_notify;
$cmpstatus=$company_notify;
$cat_res=$oldcategory;
$lang_res=$oldrace;
$agent_cmpp=$oldcompany;
if($category_notify!="1")
{ $cat_res= $cat_ress;
if($cat_ress!=$oldcategory){ $catstatus="1"; } else { $catstatus="0"; }
}
if($racetype_notify!="1"){
$lang_res= $lang_ress;
if($lang_ress!=$oldrace){ $racestatus="1"; } else { $racestatus="0"; }
}
if($company_notify!="1")
{
$agent_cmpp=$agent_cmp;
if($oldcompany!=$agent_cmp){ $cmpstatus="1"; } else{ $cmpstatus="0"; }
}
if (!is_dir('uploads/agentprofile')) {
mkdir('./uploads/agentprofile', 0777, TRUE);
}
$valid_extensions = array('jpeg', 'jpg', 'png'); // valid extensions
$path = 'uploads/agentprofile/'; // upload directory
if($_FILES['input6'])
{
//echo "asdasd";exit;
$img = $_FILES['input6']['name'];
$tmp = $_FILES['input6']['tmp_name'];
// get uploaded file's extension
$ext = strtolower(pathinfo($img, PATHINFO_EXTENSION));
// can upload same image using rand function
$final_image = "input6".rand(1000,1000000).$img;
// check's valid format
if(in_array($ext, $valid_extensions))
{
$simage = $path.strtolower($final_image);
if(move_uploaded_file($tmp,$simage))
{}} }
$table="users";
$where=array("id"=>$primaryid);
$values=array('name'=>$fullname,
'mobile'=>$mobile,
'pincode'=>$pincode,
'country'=>$country,
'state'=>$state,
'city'=>$city,
'address'=>$address,
'profilepic'=>$simage,
'password'=>$pass,
'status'=>1);
$result=$this->commonsql_model->updateTable($table,$where,$values);
$table="agents";
$where=array("user_id"=>$primaryid);
$values=array('agent_code'=>$agent_code,
'intro'=>$intro,
'pincode'=>$pincode,
'experience'=>$experience,
'company'=>$agent_cmpp,
'racetype'=>$lang_res,
'category'=>$cat_res,
'category_notify'=>$catstatus,
'racetype_notify'=>$racestatus,
'company_notify'=>$cmpstatus,
'status'=>1);
$result=$this->commonsql_model->updateTable($table,$where,$values);
$result= $this->db->last_query();
if($result)
{
$this->session->set_userdata('suc','Profile updated successfully...!');
redirect('agent-profile');
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('agent-profile');
}
}
$id=$this->session->userdata('primaryid');
$data['age']=$this->Frontend_model->agent_detail($id);
$data['cmp']=$this->Company_model->list_cmp();
$data['cat']=$this->Category_model->list_cat();
$data['race']=$this->Frontend_model->agent_racetype();
$this->load->view('front/agent-edit-profile',$data);
}
function agent_change_profile()
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
$this->load->view('front/agent-change-profile');
}
function change_agent_profile()
{
$primaryid=$this->input->post('primaryid');
if (!is_dir('uploads/agentprofile')) {
mkdir('./uploads/agentprofile', 0777, TRUE);
}
$valid_extensions = array('jpeg', 'jpg', 'png'); // valid extensions
$path = 'uploads/agentprofile/'; // upload directory
if($_FILES['input6'])
{
$img = $_FILES['input6']['name'];
$tmp = $_FILES['input6']['tmp_name'];
// get uploaded file's extension
$ext = strtolower(pathinfo($img, PATHINFO_EXTENSION));
// can upload same image using rand function
$final_image = "input6".rand(1000,1000000).$img;
// check's valid format
if(in_array($ext, $valid_extensions))
{
$path = $path.strtolower($final_image);
if(move_uploaded_file($tmp,$path))
{
$table="users";
$where=array("id"=>$primaryid);
$values=array(
'profilepic'=>$path
);
$result=$this->commonsql_model->updateTable($table,$where,$values);
} } }
if($result)
{
$this->session->set_userdata('suc','Profile picture updated successfully...!');
redirect('agent-change-profile');
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('agent-change-profile');
}
}
function agent_change_password()
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
if($this->input->post('submit'))
{
$primaryid=$this->input->post('primaryid');
$old_pass=$this->input->post('old_pass');
$change_passwords=$this->input->post('change_passwords');
$conform_passwords=$this->input->post('conform_passwords');
if($change_passwords==""){ $pass=$old_pass; }
else{ $pass=md5($change_passwords); }
$table="users";
$where=array("id"=>$primaryid);
$values=array('password'=>$pass,
'status'=>1);
$result=$this->commonsql_model->updateTable($table,$where,$values);
if($result)
{
$this->session->set_userdata('suc','Password updated successfully...!');
redirect('agent-change-password');
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('agent-change-password');
}
}
$this->load->view('front/agent-change-password');
}
function agent_review()
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
$id=$this->session->userdata('primaryid');
$data['rev']=$this->Frontend_model->user_review_to_agent($id);
$this->load->view('front/agent-review',$data);
}
function policydetailenquiry()
{
if($this->input->post('submit'))
{
$primaryid=$this->input->post('primaryid');
$policyid=$this->input->post('policyid');
$name=$this->input->post('name');
$email=$this->input->post('email');
$Pincode=$this->input->post('Pincode');
$Mobile=$this->input->post('Mobile');
$message=$this->input->post('message');
if($primaryid==""){
$table="users";
$values=array('name'=>$name,
'email'=>$email,
'mobile'=>$Mobile,
'pincode'=>$Pincode,
'cdate'=>date('Y-m-d H:i:s'),
'status'=>0);
$result=$this->commonsql_model->insert_table($table,$values);
$userid=$this->db->insert_id();
$table="policy_detail_enquiry";
$values=array('userid'=>$userid,
'policyid'=>$policyid,
'name'=>$name,
'email'=>$email,
'pincode'=>$Pincode,
'mobile'=>$Mobile,
'message'=>$message,
'cdate'=>date('Y-m-d H:i:s'),
'status'=>1);
$result=$this->commonsql_model->insert_table($table,$values);
}
else
{
$table="policy_detail_enquiry";
$values=array('userid'=>$primaryid,
'policyid'=>$policyid,
'name'=>$name,
'email'=>$email,
'pincode'=>$Pincode,
'mobile'=>$Mobile,
'message'=>$message,
'cdate'=>date('Y-m-d H:i:s'),
'status'=>1);
$result=$this->commonsql_model->insert_table($table,$values);
}
if($result)
{
$this->session->set_userdata('suc','Your enquiry details sent successfully. we will contact you soon...!');
redirect('policy-detail/'.$policyid);
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('policy-detail/'.$policyid);
}
}
}
function get_a_quote()
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
$loggeduserid=$_POST['priid'];
$policyid=$_POST['polid'];
$table="quotes";
$values=array('user_id'=>$loggeduserid,
'policy_id'=>$policyid,
'cdate'=>date('Y-m-d H:i:s'),
'status'=>0);
$result=$this->commonsql_model->insert_table($table,$values);
if($result)
{
echo "1";
}
else
{
echo "2";
}
}
function get_question_pop()
{
$cid=$_POST['catid'];
$data['primaryid']=$_POST['priid'];
$data['policyid']=$_POST['polid'];
$data['pincode']=$_POST['pin'];
$data['company']=$_POST['company'];
$data['getquest']=$this->Frontend_model->get_category_questions($cid);
//questionpop
$this->load->view('front/category_wise_question',$data);
}
function insert_question_category()
{
parse_str($_POST["ser"], $ser_data);
$hide_answer=$ser_data["hide_answer"];
$hide_question=$ser_data["hide_question"];
$userid=$ser_data["userid"];
$pincode=$ser_data["pincode"];
$policyid=$ser_data["policyid"];
$company=$ser_data["company"];
$table="quotes";
$values=array('user_id'=>$userid,
'policy_id'=>$policyid,
'cdate'=>date('Y-m-d H:i:s'),
'status'=>0);
$result=$this->commonsql_model->insert_table($table,$values);
$quoe=$this->db->insert_id();
foreach($hide_question as $key=>$val){
$hd_anss= $hide_answer[$key];
$table="quote_questions";
$values=array('quote_id'=>$quoe,
'question'=>$hide_question[$key],
'answer'=>$hd_anss,
'status'=>1);
$result=$this->commonsql_model->insert_table($table,$values);
}
$getingquote=$this->Frontend_model->select_pincode_agentcount($pincode,$agentcount=3,$company);
foreach($getingquote->result() as $gq){
$name=$gq->name;
$profilepic=$gq->profilepic;
$email=$gq->email;
$mobile=$gq->mobile;
$company=$gq->company;
$experience=$gq->experience;
$getcmpname=$this->Frontend_model->get_company_name($company);
if($getcmpname->num_rows()>0){
$cm=$getcmpname->row();
$companyname=$cm->name;
}
?>
<div class="entry col-12">
<div class="grid-inner row g-0">
<div class="col-auto">
<div class="entry-image">
<a ><img src="<?php if($profilepic!=""){ ?> <?=base_url();?>/<?=$profilepic;?> <?php } else { ?>https://0.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=60 <?php } ?>" style="width:48px;height:48px" alt="Image"></a>
</div>
</div>
<div class="col ps-3">
<div class="entry-title">
<h4><a ><?=ucwords($name);?> </a></h4>
</div>
<div class="entry-meta">
<ul>
<li><i class="icon-briefcase"></i><b> Company </b>: <?=$companyname;?></li>
<li><i class="icon-laptop-house"></i><b>Experience </b>: <?=$experience;?></li>
</ul>
</div>
</div>
</div>
</div>
<?php }
}
function agent_request()
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
$data['age_req']=$this->Frontend_model->show_quote_to_agent();
$this->load->view('front/agent-request',$data);
}
function respondtouser()
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
if($this->input->post('submit'))
{
$qid=$this->input->post('qid');
$uid=$this->input->post('user');
$agid=$this->input->post('agid');
$cMessage=$this->input->post('cMessage');
$cEmail=$this->input->post('cEmail');
$cMobile=$this->input->post('cMobile');
$table="quote_response";
$values=array('agency_id'=>$agid,
'user_id'=>$uid,
'quote_id'=>$qid,
'mobile'=>$cMobile,
'email'=>$cEmail,
'message'=>$cMessage,
'cdate'=>date('Y-m-d H:i:s'),
'status'=>0);
$result=$this->commonsql_model->insert_table($table,$values);
if($result)
{
$this->session->set_userdata('suc','Your response sent to the user successfully...!');
redirect('agent-request');
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('agent-request');
}
}
}
function user_request()
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
$id=$this->session->userdata('primaryid');
$data['user_req']=$this->Frontend_model->show_quote_to_user($id);
$this->load->view('front/user-request',$data);
}
function user_request_cancel($qid)
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
$where=array("id"=>$qid);
$table="quotes";
$values=array(
'status'=>3);
$result=$this->commonsql_model->updateTable($table,$where,$values);
$where=array("quote_id"=>$qid);
$table="quote_response";
$values=array(
'status'=>3); //cancelled
$result=$this->commonsql_model->updateTable($table,$where,$values);
if($result)
{
$this->session->set_userdata('suc','Your quote cancelled successfully...!');
redirect('user-request');
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('user-request');
}
}
function view_user_response($quoteid)
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
$id=$this->session->userdata('primaryid');
$data['user_req']=$this->Frontend_model->show_response_detail_to_user($id,$quoteid);
$this->load->view('front/user-response-view',$data);
}
function writereview()
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
$uid=$this->input->post('user');
$agid=$this->input->post('agid');
$rating=$this->input->post('rating');
$cMessage=$this->input->post('cMessage');
$policyid=$this->input->post('policyid');
$table="reviews";
$values=array('user_id'=>$uid,
'agency_id'=>$agid,
'rating'=>$rating,
'text'=>$cMessage,
'cdate'=>date('Y-m-d H:i:s'),
'status'=>0);
$result=$this->commonsql_model->insert_table($table,$values);
if($result)
{
$this->session->set_userdata('suc','Your review updated successfully...!');
redirect('policy-detail/'.$policyid);
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('policy-detail/'.$policyid);
}
}
function user_reply_to_quote($aid,$uid,$qid,$val)
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
if($val=="1"){ $ms="Accepted";
$table="quotes";$where=array("id"=>$qid);
$values=array( 'status'=>1,
'agency_id'=>$aid);
$result=$this->commonsql_model->updateTable($table,$where,$values);
}
else { $ms="Cancelled"; }//status 7->user not interested
$where=array("agency_id"=>$aid,"user_id"=>$uid,"quote_id"=>$qid);
$table="quote_response";
$values=array(
'status'=>$val);
$result=$this->commonsql_model->updateTable($table,$where,$values);
if($result)
{
$this->session->set_userdata('suc','Quote '.$ms.'..!!!');
redirect('user-request');
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('user-request');
}
}
function agent_order()
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
$aid=$this->session->userdata('primaryid');
$data['age_ord']=$this->Frontend_model->show_response_to_agent_for_accept($aid);
$this->load->view('front/agent-order',$data);
}
function agentacceptorder($qid)
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
$table="quotes";$where=array("id"=>$qid);
$values=array(
'status'=>1);
$result=$this->commonsql_model->updateTable($table,$where,$values);
if($result)
{
$this->session->set_userdata('suc','Quote Accepted..!!!');
redirect('agent-order');
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('agent-order');
}
}
function agentcompleteorder($qid)
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
$table="quotes";$where=array("id"=>$qid);
$values=array(
'status'=>2);
$result=$this->commonsql_model->updateTable($table,$where,$values);
if($result)
{
$this->session->set_userdata('suc','Quote Accepted..!!!');
redirect('agent-order');
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('agent-order');
}
}
function user_order()
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
$uid=$this->session->userdata('primaryid');
$data['user_ord']=$this->Frontend_model->show_response_to_user_for_accept_complete($uid);
$this->load->view('front/user-order',$data);
}
function cancelorderofagent($qid)
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
$table="quotes";$where=array("id"=>$qid);
$values=array(
'status'=>3);
$result=$this->commonsql_model->updateTable($table,$where,$values);
if($result)
{
$this->session->set_userdata('suc','Quote Accepted..!!!');
redirect('user-order');
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('user-order');
}
}
function approvereview($id,$val)
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
$table="reviews";$where=array("id"=>$id);
$values=array(
'status'=>$val);
$result=$this->commonsql_model->updateTable($table,$where,$values);
if($val=="1"){ $ms="Approved"; }
else { $ms="Not Approved"; }
if($result)
{
$this->session->set_userdata('suc','Review '.$ms.'...!!!');
redirect('agent-review');
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('agent-review');
}
}
function user_review()
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
$id=$this->session->userdata('primaryid');
$data['rev']=$this->Frontend_model->agent_approve_review_to_user($id);
$this->load->view('front/user-review',$data);
}
function showpopupforreview()
{
if($this->session->userdata('primaryid')==""){ redirect('home'); }
$agentid= $_POST['agentid'];
$data['revw']=$this->Frontend_model->agent_review_from_user($agentid);
// echo $this->db->last_query();exit;
$this->load->view('front/review-popup',$data);
}
function category_view_price($cid)
{
if($cid=="1")
{
$lifepincode=$this->input->post("lifepincode");
$lifename=$this->input->post("lifename");
$lifedob=$this->input->post("lifedob");
$lifemobile=$this->input->post("lifemobile");
$life_age=$this->input->post("lifeage");
$data['lfgetpoltop']=$this->Frontend_model->get_categorywise_policy_with_agelimit_top($cid,$life_age);//top
$data['lfgetpol']=$this->Frontend_model->get_categorywise_policy_with_agelimit($cid,$life_age);//more
//echo $this->db->last_query();exit;
$data['lfgetcat']=$this->Frontend_model->get_categorydetails_for_categoryview($cid);
$data['lifepincode']=$lifepincode;
$data['lifename']=$lifename;
$data['lifedob']=$lifedob;
$data['lifemobile']=$lifemobile;
$data['life_age']=$life_age;
$data['mobexist']=$this->Frontend_model->check_mobile_exist_for_login_register($lifemobile);
$this->session->set_userdata('loggeddob',$lifedob);
}
if($cid=="2")
{
$healthpincode=$this->input->post("healthpincode");
$healthname=$this->input->post("healthname");
$healthgender=$this->input->post("healthradio");
$healthmobile=$this->input->post("healthmobile");
$data['lifepincode']=$healthpincode;
$data['healthname']=$healthname;
$data['healthgender']=$healthgender;
$data['healthmobile']=$healthmobile;
$data['lfgetpoltop']=$this->Frontend_model->get_categorywise_policy_with_agelimit_top($cid);//top
$data['lfgetpol']=$this->Frontend_model->get_categorywise_policy_with_agelimit($cid);//more
$data['lfgetcat']=$this->Frontend_model->get_categorydetails_for_categoryview($cid);
$data['mobexist']=$this->Frontend_model->check_mobile_exist_for_login_register($healthmobile);
$this->session->set_userdata('loggedgender',$healthgender);
}
if($cid=="3")
{
$carpincode=$this->input->post("carpincode");
$carregister=$this->input->post("carregister");
$carmobile=$this->input->post("carmobile");
$data['carpincode']=$carpincode;
$data['carregister']=$carregister;
$data['carmobile']=$carmobile;
$data['lfgetpoltop']=$this->Frontend_model->get_categorywise_policy_with_agelimit_top($cid);//top
$data['lfgetpol']=$this->Frontend_model->get_categorywise_policy_with_agelimit($cid);//more
$data['lfgetcat']=$this->Frontend_model->get_categorydetails_for_categoryview($cid);
$data['mobexist']=$this->Frontend_model->check_mobile_exist_for_login_register($carmobile);
$this->session->set_userdata('loggedcarno',$carregister);
}
if($cid=="4")
{
$bikepincode=$this->input->post("bikepincode");
$bikeregister=$this->input->post("bikeregister");
$bikemobile=$this->input->post("bikemobile");
$data['bikepincode']=$bikepincode;
$data['bikeregister']=$bikeregister;
$data['bikemobile']=$bikemobile;
$data['lfgetpoltop']=$this->Frontend_model->get_categorywise_policy_with_agelimit_top($cid);//top
$data['lfgetpol']=$this->Frontend_model->get_categorywise_policy_with_agelimit($cid);//more
$data['lfgetcat']=$this->Frontend_model->get_categorydetails_for_categoryview($cid);
$data['mobexist']=$this->Frontend_model->check_mobile_exist_for_login_register($bikemobile);
$this->session->set_userdata('loggedbikeno',$bikeregister);
}
if($cid=="5")
{
$smepincode=$this->input->post("smepincode");
$smeregister=$this->input->post("smeregister");
$smemobile=$this->input->post("smemobile");
$data['smepincode']=$smepincode;
$data['smeregister']=$smeregister;
$data['smemobile']=$smemobile;
$data['lfgetpoltop']=$this->Frontend_model->get_categorywise_policy_with_agelimit_top($cid);//top
$data['lfgetpol']=$this->Frontend_model->get_categorywise_policy_with_agelimit($cid);//more
$data['lfgetcat']=$this->Frontend_model->get_categorydetails_for_categoryview($cid);
$data['mobexist']=$this->Frontend_model->check_mobile_exist_for_login_register($smemobile);
$this->session->set_userdata('loggedcompanyno',$smeregister);
}
if($cid=="6")
{
$country=$this->input->post("country");
$Leaving=$this->input->post("Leaving");
$Return=$this->input->post("Return");
$data['Leaving']=$Leaving;
$data['Return']=$Return;
$data['country']=$country;
$data['lfgetpoltop']=$this->Frontend_model->get_categorywise_policy_with_agelimit_top($cid);//top
$data['lfgetpol']=$this->Frontend_model->get_categorywise_policy_with_agelimit($cid);//more
$data['lfgetcat']=$this->Frontend_model->get_categorydetails_for_categoryview($cid);
//echo $this->db->last_query();exit;
$this->session->set_userdata('loggedcountry',$country);
$this->session->set_userdata('loggedleavingdate',$Leaving);
$this->session->set_userdata('loggedreturndate',$Return);
}
$this->load->view('front/category_viewprice',$data);
}
function getplantocompare()
{
$pid=$_POST["pid"];
$plan=$_POST["plan"];
$data['complan']=$this->Frontend_model->get_policy_compare($pid,$plan);//top
$this->load->view('front/category_compare_plan',$data);
}
function compare_plan_details($cat)
{
if($this->input->post("submitcompare"))
{
$selectedpaln=$this->input->post("selectedplans");
$str_arr = explode (",", $selectedpaln);
$data['compared']=$this->Frontend_model->get_comparisions($cat,$str_arr);//top
// echo $this->db->last_query();
$data['compared_mas']=$this->Frontend_model->get_comparisions_master($cat,$str_arr);//top
$data['cate']=$cat;//top
}
$this->load->view('front/category_compare_details',$data);
}
function view_agent_profile($aid,$qid)
{
$data['agede']=$this->Frontend_model->agent_detail($aid);//top
//echo $this->db->last_query();exit;
$data['prev_qid']=$qid;
$this->load->view('front/view_agent_to_user',$data);
}
function agent_collect_documents($qid,$cid)
{
if($this->input->post('doc_submit'))
{
$document=$this->input->post('documentss'); print_r($document);
$user_id=$this->input->post('user_id');
$policy_id=$this->input->post('policy_id');
$agency_id=$this->input->post('agency_id');
foreach($document as $key=>$val)
{
if (!is_dir('uploads/document_collect')) {
mkdir('./uploads/document_collect', 0777, TRUE);
}
if($_FILES['file']['tmp_name'])
{
$temp_vehicle_doc=$_FILES['file']['tmp_name'][$key];
$business_doc=str_replace(' ', '_', $_FILES["file"]["name"][$key]);
$extension1 = pathinfo($business_doc, PATHINFO_EXTENSION);
$business_document=date('ymdhis').'.'.$business_doc;
$documents='uploads/document_collect/'.$business_document;
$targetPath = './uploads/document_collect/';
$targetFile=$targetPath.$business_document;
if(move_uploaded_file($temp_vehicle_doc, $targetFile))
{ }
}
$table="collected_documents_from_customer";
$values=array('document_id'=>$document[$key],
'doc_copy'=>$documents,
'quote'=>$qid,
'category'=>$cid,
'policy'=>$policy_id,
'user'=>$user_id,
'agent'=>$agency_id,
'status'=>1);
if($document[$key]!=" " && $documents!=" "){
$result=$this->commonsql_model->insert_table($table,$values);
}
}
$table="quotes";$where=array("id"=>$qid);
$values=array(
'status'=>4); //document collect
$result=$this->commonsql_model->updateTable($table,$where,$values);
if($result)
{
$this->session->set_userdata('suc','Documents Submitted ...!!!');
redirect('agent-request');
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('agent-request');
}
}
$data['doc_coll']=$this->Frontend_model->get_documents_collection($cid);//top
$data['quote_user']=$this->Frontend_model->get_details_of_quote_user($qid);//top
$data['prev_qid']=$qid;
$data['cat_qid']=$cid;
$this->load->view('front/agent-document-collect',$data);
}
function change_document_status($qid,$val,$agid)
{
$table="quotes";$where=array("id"=>$qid);
$values=array('status'=>$val); //verify
$result=$this->commonsql_model->updateTable($table,$where,$values);
if($val=="2")//2-completed in quotes so same as quotes response
{
$table="quote_response";$where=array("quote_id"=>$qid,"agency_id"=>$agid);
$values=array('status'=>$val); //verify
$result=$this->commonsql_model->updateTable($table,$where,$values);
}
if($result)
{
$this->session->set_userdata('suc','Your policy submitted ...!!!');
redirect('agent-request');
}
else
{
$this->session->set_userdata('err','Please try again');
redirect('agent-request');
}
}
function get_current_policy_detail()
{
$cid=$_POST['idd'];
$get_pol=$this->Frontend_model->get_current_policy_detail($cid);
if($get_pol->num_rows()>0){$p=$get_pol->row();$categoryname=$p->catname;}else {$categoryname="";};
?>
<h4 style="color: #ef7f1a;text-align:center;text-transform:uppercase"><?= ($categoryname);?></h4>
<div class="row justify-content-center col-mb-50 "><?php
if($get_pol->num_rows()>0){
foreach($get_pol->result() as $gp){
$polid=$gp->id;
$logo=$gp->logo;
$policyname=$gp->name;
$intro=$gp->intro;
$short_des = substr($intro, 0, 50);
?>
<div class="col-sm-6 col-lg-4 text-center">
<a href="#"><img src="<?=$logo;?>" alt="Image" style="width:128px;height:128px;" class="bottommargin-sm"></a>
<h4><?=ucwords($policyname);?></h4>
<p><?=$short_des;?></p>
</div>
<?php
}} else { ?> <p> No related polices</p> <?php } ?> </div><?php
}
}
?>