File: /home/barbeatleanalyti/public_html/mbaris.beatleanalytics.com/application/controllers/Survey.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Survey extends CI_Controller {
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see https://codeigniter.com/user_guide/general/urls.html
*/
public function diwalibanner(){
echo '<img src="'.base_url().'assets/survey/assets/'.rand(1,6).'.jpg">';
exit;
}
public function index()
{
$this->load->model('Survey_model');
$alldata = '';
if(isset($_SESSION['LoginIndid'])){
if( preg_match('/m.beatle/', $_SERVER['HTTP_HOST'])){
redirect('index.php/survey/home');
}
}
if (isset($_POST['stSubmit']))
{
$depId = $this->input->post('stationId');
$alldata = $this->Survey_model->loginSurvey($depId);
if (!empty($alldata))
{
$dataUsesrId = $alldata[0]->stationId;
$sessiondata = $this->session->set_userdata('LoginIndid',$dataUsesrId);
redirect ('index.php/survey/home');
}
else
{
$alldata['error_masg'] = 'Department-Id Is Not Match Please Enter Right Department-Id';
}
}
$this->load->view('survey/index' , $alldata);
}
public function home()
{
$this->load->model('Survey_model');
$this->load->model('Admin_model');
$staId = $this->session->userdata('LoginIndid');
//$alldata['LimeData'] = $this->Admin_model->getAllUserByIndustryId($indId);
//$Orgid = $alldata['LimeData'][0]->db_branchOrg;
//$alldata['orgdata'] = $this->Admin_model->getOrganizationById($Orgid);
/*if (isset($_POST['storySubmit']))
{
redirect('index.php/survey/end_user_login');
}*/
$this->load->view('survey/home');
}
public function end_user_login()
{
if(!isset($_SESSION['LoginIndid']))
redirect('index.php/survey');
$this->load->model('Survey_model');
$this->load->model('Admin_model');
$staId = $this->session->userdata('LoginIndid');
//$alldata['LimeData'] = $this->Admin_model->getAllUserByIndustryId($indId);
//$Orgid = $alldata['LimeData'][0]->db_branchOrg;
//$alldata['orgdata'] = $this->Admin_model->getOrganizationById($Orgid);
//$token = $this->input->post('token');
if (isset($_POST['userSubmit']))
{
$username = $this->input->post('endusername');
$password = $this->input->post('enduserpassword');
$dataUsesr = $this->Survey_model->endUserLogin($username,$password);
//print_r($dataUsesr);die;
if (!empty($dataUsesr))
{
$dataUsesrId = $dataUsesr[0]->userId;
$sessiondata = $this->session->set_userdata('userId',$dataUsesrId);
$tString = $dataUsesrId."".date("Ymd");
$tokenID = md5($tString);
$this->session->set_userdata('tokenID',$tokenID);
$tokenID = $this->session->userdata('tokenID');
//redirect('index.php/survey/feedback?token='.$tokenID);
redirect('index.php/survey/question');
}
else
{
$alldata['error_masg'] = 'Username or Password Does Not Match Please Confirm Your Username Or Password Again';
}
}
$this->load->view('survey/userLogin');
}
public function question()
{
if(!isset($_SESSION['LoginIndid']))
redirect('index.php/survey');
if(!isset($_SESSION['userId']) || !isset($_SESSION['tokenID']))
redirect('index.php/survey/end_user_login');
$this->load->model('Survey_model');
$this->load->model('Admin_model');
$staId = $this->session->userdata('LoginIndid');
//$alldata['question'] = $this->Survey_model->getAllquestion();
$alldata['question'] = $this->Survey_model->getAllquestionBystd($staId);
$this->load->view('survey/question', $alldata);
}
public function subquestion()
{
if(!isset($_SESSION['LoginIndid']))
redirect('index.php/survey');
if(!isset($_SESSION['userId']) || !isset($_SESSION['tokenID']))
redirect('index.php/survey/end_user_login');
$this->load->model('Survey_model');
$this->load->model('Admin_model');
//$alldata['queId'] = $this->uri->segment(3);
$queId = $_REQUEST['queId'];
if(empty($queId)){
redirect('index.php/survey/question');
}
$staId = $this->session->userdata('LoginIndid');
$alldata['question'] = $this->Survey_model->getAllquestion($queId);
$alldata['params'] = $this->Survey_model->getParamsDetails($alldata['question'][0]->db_paramId);
$this->load->view('survey/subquestion', $alldata);
}
/* public function feedback()
{
if(!isset($_SESSION['userId']) || !isset($_SESSION['tokenID']))
redirect('index.php/survey/end_user_login');
$this->load->model('Survey_model');
$this->load->model('Admin_model');
$indId = $this->session->userdata('LoginIndid');
$userid = $this->session->userdata('userId');
$alldata['LimeData'] = $this->Admin_model->getAllUserByIndustryId($indId);
$Orgid = $alldata['LimeData'][0]->db_branchOrg;
$alldata['orgdata'] = $this->Admin_model->getOrganizationById($Orgid);
$alldata['Loginuserdata'] = $this->Admin_model->getuserdata($userid);
//print_r($alldata['orgdata']);
$this->load->view('survey/feedback' , $alldata);
}
public function userfeedback_question(){
if(!isset($_SESSION['userId']) || !isset($_SESSION['tokenID']))
redirect('index.php/survey/end_user_login');
$this->load->model('Survey_model');
$this->load->model('Admin_model');
$indId = $this->session->userdata('LoginIndid');
$userid = $this->session->userdata('userId');
$alldata['LimeData'] = $this->Admin_model->getAllUserByIndustryId($indId);
$Orgid = $alldata['LimeData'][0]->db_branchOrg;
$alldata['orgdata'] = $this->Admin_model->getOrganizationById($Orgid);
$alldata['Loginuserdata'] = $this->Admin_model->getuserdata($userid);
$alldata['Inddata'] = $this->Admin_model->getIndustryById($indId);
$this->load->view('survey/userfeedback_question' , $alldata);
}*/
public function logout(){
unset($_SESSION['userId']);
unset($_SESSION['tokenID']);
redirect('index.php/survey/end_user_login');
}
/*public function summery(){
if(!isset($_SESSION['userId']) || !isset($_SESSION['tokenID']))
redirect('index.php/survey/end_user_login');
$this->load->model('Survey_model');
$this->load->model('Admin_model');
$indId = $this->session->userdata('LoginIndid');
$userid = $this->session->userdata('userId');
$alldata['LimeData'] = $this->Admin_model->getAllUserByIndustryId($indId);
$Orgid = $alldata['LimeData'][0]->db_branchOrg;
$alldata['orgdata'] = $this->Admin_model->getOrganizationById($Orgid);
$alldata['Loginuserdata'] = $this->Admin_model->getuserdata($userid);
$alldata['Inddata'] = $this->Admin_model->getIndustryById($indId);
$this->session->userdata('LoginIndid');
$alldata['userPhoneNo'] = $this->Admin_model->getUserPhoneNo($this->session->userdata('userId'),$this->session->userdata('tokenID'));
$this->load->view('survey/summery' , $alldata);
}*/
public function userfeedback()
{
if(!isset($_SESSION['LoginIndid']))
redirect('index.php/survey');
if(!isset($_SESSION['userId']) || !isset($_SESSION['tokenID']))
redirect('index.php/survey/end_user_login');
$this->load->model('Survey_model');
$this->load->model('Admin_model');
$staId = $this->session->userdata('LoginIndid');
$queId = $_REQUEST['queId'];
$paramId = $_REQUEST['paramId'];
$alldata['question'] = $this->Survey_model->getAllquestion($queId);
$alldata['param'] = $this->Survey_model->getAllparams($paramId);
$alldata['pages'] = $this->Survey_model->getPagesDetails($alldata['question'][0]->db_pagesId);
//echo $_REQUEST['queId']." / ".$_REQUEST['paramId'];
//die();
// $indId = $this->session->userdata('LoginIndid');
// $userid = $this->session->userdata('userId');
// $alldata['LimeData'] = $this->Admin_model->getAllUserByIndustryId($indId);
// $Orgid = $alldata['LimeData'][0]->db_branchOrg;
// $alldata['orgdata'] = $this->Admin_model->getOrganizationById($Orgid);
// $alldata['Loginuserdata'] = $this->Admin_model->getuserdata($userid);
// $alldata['Inddata'] = $this->Admin_model->getIndustryById($indId);
$this->load->view('survey/userfeedback',$alldata);
}
public function insertUserFeedback()
{
$this->load->model('Survey_model');
$stationId = $_REQUEST['stationId'];
$userId = $_REQUEST['userId'];
$questionId = $_REQUEST['questionId'];
$paramId = $_REQUEST['paramId'];
$pageid = $_REQUEST['pageid'];
$avavalue = $_REQUEST['avavalue'];
$data = $this->Survey_model->insertUserFeedback($stationId,$userId,$questionId,$paramId,$pageid,$avavalue);
if (!empty($data))
{
echo 'yes';
}
}
public function thankyou(){
$this->load->model('Survey_model');
$this->load->model('Admin_model');
$indId = $this->session->userdata('LoginIndid');
$userid = $this->session->userdata('userId');
$alldata['LimeData'] = $this->Admin_model->getAllUserByIndustryId($indId);
$Orgid = $alldata['LimeData'][0]->db_branchOrg;
$alldata['orgdata'] = $this->Admin_model->getOrganizationById($Orgid);
$alldata['Loginuserdata'] = $this->Admin_model->getuserdata($userid);
$alldata['Inddata'] = $this->Admin_model->getIndustryById($indId);
$this->session->userdata('LoginIndid');
$alldata['userPhoneNo'] = $this->Admin_model->getUserPhoneNo($this->session->userdata('userId'),$this->session->userdata('tokenID'));
// set bonus point data
$this->Admin_model->setBonusPoints($this->session->userdata('userId'),$this->session->userdata('tokenID'),$indId,$Orgid,$alldata['LimeData'][0]->BranchID,$alldata['Loginuserdata'][0]->db_usertype);
$this->db->where("tokenid",$this->session->userdata('tokenID'));
$this->db->where("db_surveyUserid",$this->session->userdata('userId'));
$insertquery = $this->db->update("beatle_survey" , array('is_submit' => "Y"));
$this->load->view('survey/thankyou' , $alldata);
unset($_SESSION['userId']);
unset($_SESSION['tokenID']);
}
public function dailyreports(){
$this->load->model('Survey_model');
$this->load->model('Admin_model');
$indId = $this->session->userdata('LoginIndid');
$userid = $this->session->userdata('userId');
$rsSurveyData = $this->Admin_model->getAllOrgByIndustryId($indId);
$userID = $rsSurveyData[0]->db_userid;
$OrgID = $rsSurveyData[0]->OrgId;
$BranchID = $rsSurveyData[0]->db_bracnchid;
$PageID = $rsSurveyData[0]->db_pagesId;
$alldata['rsSurveyData'] = $this->Admin_model->fetchLoginDataFrom($indId,$OrgID,$BranchID,$PageID);
$alldata['orgdata'] = $this->Admin_model->getOrganizationById($OrgID);
$alldata['pageData'] = $this->Admin_model->fetchPageIDDetails($PageID);
//echo "<pre>";
//print_r($alldata['rsSurveyData']);
//echo "</pre>";
$this->load->view('survey/dailyreports' , $alldata);
}
}