HEX
Server: Apache
System: Linux 185.122.168.184.host.secureserver.net 5.14.0-570.52.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Oct 15 06:39:08 EDT 2025 x86_64
User: barbeatleanalyti (1024)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: /home/barbeatleanalyti/public_html/m.beatleanalytics.com/application/controllers/BeatleAdmin.php
<?php 
ini_set('memory_limit', '-1');

defined('BASEPATH') OR exit('No direct script access allowed');
 
class BeatleAdmin 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 index()
	{
		 
		$AdminModel = $this->load->model('Admin_model');	
		if (isset($_POST['user_submit']))
		{
			$username 			= 	$this->input->post('username');
			$password 			= 	$this->input->post('userpass');
			$logindatap 	  	= 	$this->Admin_model->admin_userlogin($username,$password);
			if (!empty($logindatap))
			{
				$dataUsesrId = $logindatap[0]->userId;
				$sessiondata = $this->session->set_userdata('LoginUserid',$dataUsesrId);
				redirect('index.php/beatleAdmin/dashboard');
			}
			else 
			{
				echo 'username or password Does not match';
			}
		}
		
		$this->load->view('beatleAdmin/index');
	}
	
	function logout()
	{
		$user_data = $this->session->all_userdata();
		
			foreach ($user_data as $key => $value) {
				echo $value;
				//if ($key != 'session_id' && $key != 'ip_address' && $key != 'user_agent' && $key != 'last_activity') {
					//$this->session->unset_userdata($key);
				//}
			}
		$this->session->sess_destroy();
		redirect('');
	}
	
	public function directlogin(){
		echo '<div style="text-align:center"> <h1>Please wait.. </h1></div>';
		$userid = $this->uri->segment(3);
		$userid = urldecode($userid);
		
		$urlAction = 'http://owner.beatleanalytics.com/manage.php?pg=login';
		
		if( preg_match('/m.beatle/', $_SERVER['HTTP_HOST']) || preg_match('/admin.beatle/', $_SERVER['HTTP_HOST'])){
			$urlAction = 'https://manage.beatleanalytics.com/manage.php?pg=login';
		}
		
		
		?>
        <form class="form-horizontal" name="fromLogin" id="frmLogin" method="post" action="<?php echo $urlAction;?>">
        
        
        
        <input type="hidden" name="pg" value="login" id="pg"/>
        <input type="hidden" name="acn" value="FetchUserDataToLogin" id="acn"/>  
        <input type="hidden" name="UserType" id="UserType" value="" />
        <input type="hidden" name="UserID"  id="userid" value="<?php echo $userid;?>" >
        <input type="hidden" name="Password" id="password" value="beatle@8460">
        </form>
        <script>
			//$(document).load(function(){
				document.getElementById('frmLogin').submit();
			//})
				
        </script>
		<?php
	}


	public function dashboard()
	{
		$this->load->model('Admin_model');
		$loginId 						= 	$this->session->userdata('LoginUserid');
		
		$alldata['userdata1'] 			= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{//echo 'ddddd'; die;
			redirect('');
		} 
		$alldata['AllOrg'] 				=	$this->Admin_model->getAllOrganization(); 
		$alldata['AllBranch'] 			=	$this->Admin_model->getAllBranch(); 
	 	$alldata['AllIndus'] 			=	$this->Admin_model->getAllIndustry();
		// peram = 'N' = set all users as no 
		$alldata['Allusesr'] 			=	$this->Admin_model->getAllUser('N'); 
		$alldata['Allowner'] 			=	$this->Admin_model->getAllUserOwner(); 
		$alldata['Allmanager'] 			=	$this->Admin_model->getAllUserManager(); 
		$alldata['Alllinemangaer'] 		=	$this->Admin_model->getAllUserLinemanage();  
		$alldata['AllIndForGraph'] 		=	$this->Admin_model->getAllIndustryForGraph(); 
		$alldata['AllOrgForGraph'] 		=	$this->Admin_model->getAllOrganizationForGraph(); 
		$alldata['AllBranchForGraph'] 	=	$this->Admin_model->getAllBranchForGraph(); 
		$alldata['AllEnduser'] 			=	$this->Admin_model->getAllenduserForGraph(); 
		$alldata['Alltablet'] 			=	$this->Admin_model->getAllTabForGraph(); 
		$alldata['Alltabs'] 			=	$this->Admin_model->getAlltabs(); 
		$alldata['AllFeedback']			=	$this->Admin_model->getAllFeedback(); 
		$alldata['AllLowRating']		=	$this->Admin_model->getAllLowRating();
		$alldata['AllTicket']			=	$this->Admin_model->getAllTicket();
		
		
		//echo '<pre>';print_r($alldata['AllEnduser'] );die;
		$this->load->view('beatleAdmin/dashboard' , $alldata);
	}
 
	 
	
	public function getAjaxOrgByName()
	{
		$this->load->model('Admin_model');
		$Orgname = $_POST['Orgname'];
		$array = array();
		$array1 = '';
		$data 	 = $this->Admin_model->getAjaxOrgByName($Orgname);
		 //print_r($data['db_Orgname'].',');
		/* foreach ($data as $keyorg=>$valorg)
		 {
			 $array[$valorg->OrgId] = $valorg->db_Orgname;
		 }*/
		 //print_r($array);
		  //echo json_encode($array);
		if (!empty($data))
		{
			foreach ($data as $keyorg=>$valorg)
			{
				echo '<div class="ajaxcalldata orgclass" data-orgid="'.$valorg->OrgId.'" data-orgname="'.$valorg->db_Orgname.'">'.$valorg->db_Orgname.'</div>';
			}
		}
		else 
		{
			echo '<div class="ajaxcalldata orgclass" >No Match</div>';
		}
	}
	public function getAjaxBranchByName()
	{
		$this->load->model('Admin_model');
		$Orgname = $_POST['Orgname'];
		$array = array();
		$array1 = '';
		$data 	 = $this->Admin_model->getAjaxBranchByName($Orgname);
		 //print_r($data['db_Orgname'].',');
		/* foreach ($data as $keyorg=>$valorg)
		 {
			 $array[$valorg->branchId] = $valorg->db_branchName;
		 }*/
		 //p/rint_r($array);
		   
		if (!empty($data))
		{
			foreach ($data as $keyorg=>$valorg)
			{
				echo '<div class="ajaxcalldata branchclass" data-orgid="'.$valorg->branchId.'" data-orgname="'.$valorg->db_branchName.'">'.$valorg->db_branchName.'</div>';
			}
		}
	}
 	public function getAjaxBranchByType()
	{
		$this->load->model('Admin_model');
		$Orgname = $_POST['Orgname'];
		$array = array();
		$array1 = '';
		$data 	 = $this->Admin_model->getAjaxBranchByType($Orgname);
		 //print_r($data['db_Orgname'].',');
		/* foreach ($data as $keyorg=>$valorg)
		 {
			 $array[$valorg->branchId] = $valorg->db_branchName;
		 }*/
		 //p/rint_r($array);
		   
		if (!empty($data))
		{
			foreach ($data as $keyorg=>$valorg)
			{
				echo '<div class="ajaxcalldata branchTypeclass" data-orgname="'.$valorg->db_branch_type.'">'.$valorg->db_branch_type.'</div>';
			}
		}
	}
	public function getAjaxIndByName()
	{
		$this->load->model('Admin_model');
		$Orgname = $_POST['Orgname'];
		$array = array();
		$array1 = '';
		$data 	 = $this->Admin_model->getAjaxIndByName($Orgname);
	 
		if (!empty($data))
		{
			foreach ($data as $keyorg=>$valorg)
			{
				echo '<div class="ajaxcalldata indclass" data-orgid="'.$valorg->IndId 	.'" data-orgname="'.$valorg->db_industry.'">'.$valorg->db_industry.' ('.$valorg->IndId.')'.'</div>';
			}
		}
	}
	public function checkAjaxloginUserName()
	{
		$this->load->model('Admin_model');
		$username = $_POST['username'];
		$uid = $_POST['uid'];
		$array = array();
		$array1 = '';
		$data 	 = $this->Admin_model->checkAjaxloginUserName($username,$uid);
		if (!empty($data))
		{
			echo '<div style="color:#900;font-size:12px;"><i class="fa fa-close" aria-hidden="true"></i> Username already taken, please try with different name.</div>';
		}
		exit;
	}
	public function userprofile()
		{
			$this->load->model('Admin_model');
			$loginId 				= 	$this->session->userdata('LoginUserid');
			$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
			if (empty($alldata['userdata1']))
			{ 
				redirect('');
			} 
			$this->load->view('beatleAdmin/userprofile' , $alldata);
		}
	public function users()
	{ 
		
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		} 
		$id = $this->uri->segment(3);
		if (!empty($id))
		{
			$alldata['Editdata'] = $this->Admin_model->getuserdata($id);
			//$alldata['Shiftdata'] = $this->Admin_model->getshiftdata($id);
		}
		
		$uid = $this->input->post('UID');
		$user = $this->input->post('addUserName');
		if (empty($uid) && !empty($user))
		{//echo '<pre>';print_r($_POST);die;
			$username 		= 	$this->input->post('addUserName');
			$password 		= 	md5($this->input->post('addUserPassword'));
			$email 			= 	$this->input->post('addUserEmail');
			$ajaxIndId 		= 	$this->input->post('ajaxIndId');
			$phone 			= 	$this->input->post('addUserPhone');
			$usergroup 		= 	$this->input->post('addUserGroup');
			
			$valid 			= 	$this->input->post('single_cal1');
			$dateArr = explode("-",$valid);
			$startDate = date("Y-m-d",strtotime(trim($dateArr[0])))." 00:00:00";
			$endDate = date("Y-m-d",strtotime(trim($dateArr[1])))." 23:59:59";
						
			
			$addOrgname 	= 	$this->input->post('addOrgname');
			$addIndname 	= 	$this->input->post('addIndname');
			$addBranchname 	= 	$this->input->post('addBranchname');
			$lastOrgId 		= 	$this->input->post('mainOrgId');
			$mainBraId 		= 	$this->input->post('mainBraId');
			$addUsernameMain = 	$this->input->post('addUsernameMain');
			$dashboard 		= 	$this->input->post('dashboard');
			$ticket 		= 	$this->input->post('ticket');
			$report 		= 	$this->input->post('report');
			$feedback 		= 	$this->input->post('feedback');
			$offer 			= 	$this->input->post('offer');
			$guestLogin		=	$this->input->post('guestlogin');
			$keyword1		=	$this->input->post('addKWname1');
			$keyword2		=	$this->input->post('addKWname2');
			$keyword3		=	$this->input->post('addKWname3');
			$keyword4		=	$this->input->post('addKWname4');
			$shiftPerm 		=	$this->input->post('shift');
			$reSurvey 		= 	$this->input->post('reSurvey');
			$reEmailField 	= 	$this->input->post('reEmailField');
			$printPdf 		= 	$this->input->post('printPdf');
			$excelDownload 	= 	$this->input->post('excelDownload');
			$pagepermission = 	$dashboard.','.$ticket.','.$report.','.$feedback.','.$offer.','.$guestLogin.','.$shiftPerm.','.$reSurvey.','.$reEmailField.','.$printPdf.','.$excelDownload;
			$status = '1';
			$date 	= date('Y-m-d H:i:s');
			if ($usergroup == 'SU_admin')
				{
					$uniq = rand(1,1000);
					$unqId = 'AD_'.$uniq;
				}
				elseif ($usergroup == 'owner')
				{
					$uniq = rand(1,1000);
					$unqId = 'OW_'.$uniq;
				}
				elseif ($usergroup == 'manager')
				{
					$uniq = rand(1,1000);
					$unqId = 'MA_'.$uniq;
				}
				elseif ($usergroup == 'line_manager')
				{
					$uniq = rand(1,1000);
					$unqId = 'LIMA_'.$uniq;
				}
				elseif (strtolower($usergroup) == 'end_user')
				{
					$uniq = rand(10000,99999);
					$unqId = 'END_'.$uniq;
				}
					/*$target_dir = "assets/userPics/";
					$target_file = time().'_'.'UserProfile.jpg';
				 
					$imageFileType = pathinfo($_FILES['filetoupload']['name'],PATHINFO_EXTENSION);
					
					if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" ) 
					{
						echo 'e1';
						$dirfile = $target_dir.$target_file; 
						move_uploaded_file($_FILES['filetoupload']['tmp_name'],$dirfile);

					}
					else
					{}*/

					$shift1From = "";
					$shift1To	= "";
					$shift2From = "";
					$shift2To	= "";
					$shift3From = "";
					$shift3To	= "";
					$shift4From = "";
					$shift4To	= "";
					$shiftLimit1 = "";
                    $shiftLimit2 = "";
                    $shiftLimit3 = "";
                    $shiftLimit4 = "";

					if(!empty($shiftPerm)){
						$shift1From =  date("G:i", strtotime($this->input->post('shift1_start')));
						$shift1To	=  date("G:i", strtotime($this->input->post('shift1_end')));
						$shift2From =  date("G:i", strtotime($this->input->post('shift2_start')));
						$shift2To	=  date("G:i", strtotime($this->input->post('shift2_end')));
						$shift3From =  date("G:i", strtotime($this->input->post('shift3_start')));
						$shift3To	=  date("G:i", strtotime($this->input->post('shift3_end')));
						$shift4From =  date("G:i", strtotime($this->input->post('shift4_start')));
						$shift4To	=  date("G:i", strtotime($this->input->post('shift4_end')));
						$shiftLimit1 = $this->input->post('feedbackLimit1');
	                    $shiftLimit2 = $this->input->post('feedbackLimit2');
	                    $shiftLimit3 = $this->input->post('feedbackLimit3');
	                    $shiftLimit4 = $this->input->post('feedbackLimit4');
					}

						$insertedData = array (
							'db_userRandId' 		=> 	$unqId,
							'db_username'			=> 	$username,
							'db_pagepermistion'	=> 	$pagepermission,
							'db_userLoginName'	=> 	$addUsernameMain,
							'db_password'		=> 	$password,
							'db_phone'			=> 	$phone,
							'db_email'			=> 	$email,
							//'db_userprofilepic'	=> 	$target_file,
							'db_status'			=> 	$status,
							'db_usertype'		=> 	$usergroup,
							'db_valid_from'			=> 	$startDate,
							'db_valid'			=> 	$endDate,
							'created_date'		=> 	$date
						 
						);
						
					$alldata['message'] = $this->Admin_model->InsertUser($insertedData,$email,$addOrgname,$addIndname,$addBranchname,$loginId,$lastOrgId,$mainBraId,$usergroup,$ajaxIndId,$keyword1,$keyword2,$keyword3,$keyword4,$shiftPerm,$shift1From,$shift1To,$shift2From,$shift2To,$shift3From,$shift3To,$shift4From,$shift4To,$shiftLimit1,$shiftLimit2,$shiftLimit3,$shiftLimit4);
					//print_r($alldata['message']);die;

					/*$insertShiftData = array(
						'userId' 		=> ,
						'OrgID' 		=> ,
						'BranchID' 		=> ,
						'IndustryID' 	=> ,
						'from' 			=> ,
						'to' 			=> ,
						'created_date' 	=>  );*/
		}
		
		
		
		if (!empty($uid))
		{
			$username = $this->input->post('addUserName');
			$password = $this->input->post('addUserPassword');
			$email = $this->input->post('addUserEmail');
			$phone = $this->input->post('addUserPhone');
			$usergroup = $this->input->post('addUserGroup');
			$editid	= $this->input->post('UID');
			$addUsernameMain = $this->input->post('addUsernameMain');
			$valid = $this->input->post('single_cal1');
			$dateArr = explode("-",$valid);
			$startDate = date("Y-m-d",strtotime(trim($dateArr[0])))." 00:00:00";
			$endDate = date("Y-m-d",strtotime(trim($dateArr[1])))." 23:59:59";	
			$keyword1 = $this->input->post('addKWname1');
			$keyword2 = $this->input->post('addKWname2');
			$keyword3 = $this->input->post('addKWname3');
			$keyword4 = $this->input->post('addKWname4');			
			 
			$date 	= date('Y-m-d H:i:s');
			if ($usergroup == 'SU_admin')
				{
					$uniq = rand(1,1000);
					$unqId = 'AD_'.$uniq;
				}
				elseif ($usergroup == 'owner')
				{
					$uniq = rand(1,1000);
					$unqId = 'OW_'.$uniq;
				}
				elseif ($usergroup == 'manager')
				{
					$uniq = rand(1,1000);
					$unqId = 'MA_'.$uniq;
				}
				elseif ($usergroup == 'line_manager')
				{
					$uniq = rand(1,1000);
					$unqId = 'LIMA_'.$uniq;
				}
				/*if (!empty($_FILES['filetoupload']['name']))
				{
					$target_dir = "assets/userPics/";
					$target_file = time().'_'.'UserProfile.jpg';
				 
					$imageFileType = pathinfo($_FILES['filetoupload']['name'],PATHINFO_EXTENSION);
					
					if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" ) 
					{
						echo 'e1';
					}
					else
					{
						$dirfile = $target_dir.$target_file; 
						move_uploaded_file($_FILES['filetoupload']['tmp_name'],$dirfile);
						$uploadimage  = $target_file;
					}
				}
					else {$uploadimage  = $this->input->post('oldimg');}*/
					
					$orgid_ 		= $this->input->post('orgid_edit');
					$branchid_ 		= $this->input->post('branchid_edit');
					$indid_ 		= $this->input->post('indid_edit');


					$dashboard 		= 	$this->input->post('dashboard');
					$ticket 		= 	$this->input->post('ticket');
					$report 		= 	$this->input->post('report');
					$feedback 		= 	$this->input->post('feedback');
					$offer 			= 	$this->input->post('offer');
					$guestLogin		=	$this->input->post('guestlogin');
					$shiftPerm 		=	$this->input->post('shift');
					$reSurvey 		= 	$this->input->post('reSurvey');//survey app button hide or show 
					$reEmailField 	= 	$this->input->post('reEmailField');//survey app Email Field hide or show 

					//$guestLoginNo	=	$this->input->post('guestno');
					$printPdf 		= 	$this->input->post('printPdf');
					$excelDownload 	= 	$this->input->post('excelDownload');
					$pagepermission = 	$dashboard.','.$ticket.','.$report.','.$feedback.','.$offer.','.$guestLogin.','.$shiftPerm.','.$reSurvey.','.$reEmailField.','.$printPdf.','.$excelDownload;
					
					$valid 			= 	$this->input->post('single_cal1');
					if(!empty($valid))
					$valid =  date("Y-m-d",strtotime($valid))." 00:00:00";

						// 'db_password'		=> 	$password,
						$editData = array (
							//'db_userRandId' 	=> 	$unqId,
							'db_username'	  	  => 	$username,
							'db_phone'		 	  => 	$phone,
							'db_email'		 	  => 	$email,
							'db_pagepermistion'	  => 	$pagepermission,
							//'db_userprofilepic'	 => 	$uploadimage,
							'db_userLoginName' 	  => 	$addUsernameMain,
							'db_usertype'	  	  => 	$usergroup,
							'db_valid_from'		  => 	$startDate,
							'db_valid'			  => 	$endDate,
							'OrgID'				  => 	$orgid_,
							'BranchID'		 	  => 	$branchid_,
							'IndustryID'	   	  => 	$indid_,
							'updated_date'	 	  => 	date('Y-m-d H:i:s')
						);
						$editIndData = array
									(
										'keywordName'		=>	$keyword1,
										'keywordServer'		=>	$keyword2,
										'keywordPax'		=>	$keyword3,
										'keyword4'			=>	$keyword4
									);

					$shift1From = "";
					$shift1To	= "";
					$shift2From = "";
					$shift2To	= "";
					$shift3From = "";
					$shift3To	= "";
					$shift4From = "";
					$shift4To	= "";
					$shiftLimit1 = "";
                    $shiftLimit2 = "";
                    $shiftLimit3 = "";
                    $shiftLimit4 = "";

					if(!empty($shiftPerm)){
						$shift1From =  date("G:i", strtotime($this->input->post('shift1_start')));
						$shift1To	=  date("G:i", strtotime($this->input->post('shift1_end')));
						$shift2From =  date("G:i", strtotime($this->input->post('shift2_start')));
						$shift2To	=  date("G:i", strtotime($this->input->post('shift2_end')));
						$shift3From =  date("G:i", strtotime($this->input->post('shift3_start')));
						$shift3To	=  date("G:i", strtotime($this->input->post('shift3_end')));
						$shift4From =  date("G:i", strtotime($this->input->post('shift4_start')));
						$shift4To	=  date("G:i", strtotime($this->input->post('shift4_end')));
						$shiftLimit1 = $this->input->post('feedbackLimit1');
	                    $shiftLimit2 = $this->input->post('feedbackLimit2');
	                    $shiftLimit3 = $this->input->post('feedbackLimit3');
	                    $shiftLimit4 = $this->input->post('feedbackLimit4');
					}
						
						$alldata['message'] = $this->Admin_model->editUserById($editData,$editid,$editIndData);
						$this->Admin_model->editShiftById($editid,$orgid_,$branchid_,$indid_,$shiftPerm,$shift1From,$shift1To,$shift2From,$shift2To,$shift3From,$shift3To,$shift4From,$shift4To,$shiftLimit1,$shiftLimit2,$shiftLimit3,$shiftLimit4);
		}
			//echo "<pre>";
			//print_r($alldata);
			//echo "</pre>";
			$this->load->view('beatleAdmin/users',$alldata);
	}
	
	public function userlist()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		} 
		$orgId = $this->uri->segment(3);
		$usertype = $this->uri->segment(4);
		$hashvalue = $this->uri->segment(5);
		if ($usertype == 'manager')
		{
			$alldata['allUser']=	$this->Admin_model->getAllUsersMangerByOrgId($orgId);
		}
		else if ($usertype == 'Lime' && empty($hashvalue))
		{
			$alldata['allUser']=	$this->Admin_model->getAllUsersLimeByOrgId($orgId);
		}
		else if ($usertype == 'owner')
		{
			$alldata['allUser']=	$this->Admin_model->getAllUsersownerByOrgId($orgId);
			//echo '<pre>';print_r($alldata['allUser']);
		}
		else if ($usertype == 'Lime' && $hashvalue == 'B')
		{  
			$alldata['allUser']=	$this->Admin_model->getAllUsersownerByBranchId($orgId);
		}
		else
		{
			$alldata['allUser']		=	$this->Admin_model->getAllUser();
		}
		
		$this->load->view('beatleAdmin/userlist' , $alldata);
	}
	
	
	public function manageproducts()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		}
		
		
		
		$actionfollow 		= 	$this->input->post('actionfollow');
		
		
		if($actionfollow == 'addnewproducts'){
			
			$productName 			 = $this->input->post('productName');
			$redeemPoints 			= $this->input->post('redeemPoints');
			$Stocks 				  = $this->input->post('Stocks');
			
			$insertProduct = array();
			$insertProduct['name'] = $productName;
			$insertProduct['points'] = $redeemPoints;
			$insertProduct['stock'] = $Stocks;
			$insertProduct['created_date'] = date("Y-m-d H:i:s");
			
			$alldata['message'] = $this->Admin_model->addProductData($insertProduct);
			
		}else if($actionfollow == 'editproducts'){


			$productName 			 = $this->input->post('productName');
			$redeemPoints 			= $this->input->post('redeemPoints');
			$Stocks 				  = $this->input->post('Stocks');
			$productid 			   = $this->input->post('productid');
			
			$insertProduct = array();
			$insertProduct['name'] = $productName;
			$insertProduct['points'] = $redeemPoints;
			$insertProduct['stock'] = $Stocks;
			$insertProduct['updated_date'] = date("Y-m-d H:i:s");
			
			
			
			$alldata['message'] = $this->Admin_model->editProductData($insertProduct,$productid);
			
			
		}
		
		//$usertype = $this->uri->segment(4);
		//$hashvalue = $this->uri->segment(5);
		//$alldata['action_']		=	$action_;
		$prodid = $this->uri->segment(4);
		$alldata['productData']		=	$this->Admin_model->getAllProductsData($prodid);
		
		$this->load->view('beatleAdmin/manageproducts' , $alldata);
		
		//echo "<pre>";
		//print_r($alldata);
		//echo "</pre>";
	}
	
	public function manageoffers()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		}
		
		$pt = '/';
		$actionfollow 		= 	$this->input->post('actionfollow');
		$editstatus = $this->uri->segment(3);
		if($editstatus == 'editstatus'){
			$offerid = $this->uri->segment(4);
			$status = $this->uri->segment(5);
			$actionfollow = 'editstatus';
		}else 
		if($editstatus == 'editonhold'){
			$offerid = $this->uri->segment(4);
			$status = $this->uri->segment(5);
			$actionfollow = 'editonhold';
		}
		
		
		
		if($actionfollow == 'addnewproducts'){
			//echo "<pre>";
			//print_r($_POST);
			//print_r($_FILES);
			
			$orgid 			 = $this->input->post('mainOrgId');
			$title 			= $this->input->post('title');
			$spoint 			= $this->input->post('spoint');
			$epoint 			= $this->input->post('epoint');
			$description 				  = $this->input->post('description');
			$startdate 				  = $this->input->post('startdate');
			$dateArr = explode("-",$startdate);
			
			$startDate = date("Y-m-d",strtotime(trim($dateArr[0])))." 00:00:00";
			$endDate = date("Y-m-d",strtotime(trim($dateArr[1])))." 23:59:59";
			$comment 				  = $this->input->post('comment');
			
			
			$insertProduct = array();
			$insertProduct['orgid'] = $orgid;
			$insertProduct['title'] = $title;
			$insertProduct['spoint'] = $spoint;
			$insertProduct['epoint'] = $epoint;
			$insertProduct['startdate'] = $startDate;
			$insertProduct['enddate'] = $endDate;
			$insertProduct['description'] = $description;
			$insertProduct['comment'] = $comment;
			$insertProduct['active'] = "Y";
			$insertProduct['onhold'] = "N";
			$insertProduct['created_date'] = date("Y-m-d H:i:s");
			
			//print_r($insertProduct);
			//die;
			$alldata['message'] = $this->Admin_model->addOfferData($insertProduct);
			
			if($alldata['message'] != 'success'){
				
				unset($_POST['actionfollow']);
				$alldata['data'] = $_POST;
				
			}
			
		}
		else if($actionfollow == 'editproducts'){


			$orgid 			 = $this->input->post('mainOrgId');
			$title 			= $this->input->post('title');
			$spoint 			= $this->input->post('spoint');
			$epoint 			= $this->input->post('epoint');
			$description 				  = $this->input->post('description');
			$startdate 				  = $this->input->post('startdate');
			$dateArr = explode("-",$startdate);
			
			$startDate = date("Y-m-d",strtotime(trim($dateArr[0])))." 00:00:00";
			$endDate = date("Y-m-d",strtotime(trim($dateArr[1])))." 23:59:59";
			$comment 				  = $this->input->post('comment');
			
			
			$insertProduct = array();
			$insertProduct['orgid'] = $orgid;
			$insertProduct['title'] = $title;
			$insertProduct['spoint'] = $spoint;
			$insertProduct['epoint'] = $epoint;
			$insertProduct['startdate'] = $startDate;
			$insertProduct['enddate'] = $endDate;
			$insertProduct['description'] = $description;
			$insertProduct['comment'] = $comment;
			$insertProduct['active'] = "Y";
			$insertProduct['onhold'] = "N";
			//$insertProduct['created_date'] = date("Y-m-d H:i:s");
			$offerid = $this->uri->segment(4);
			//echo "<pre>";
			
			//print_r($_POST);
			//print_r($insertProduct);
			//print_r($_FILES);
			
			$alldata['message'] = $this->Admin_model->editOfferData($insertProduct,$offerid);
		}
		else if($actionfollow == 'editstatus'){
			$insertProduct['active'] = $status;
			$alldata['message'] = $this->Admin_model->editStatusOfferData($insertProduct,$offerid);
			
			redirect(base_url().'index.php/beatleAdmin/manageoffers');
			exit;
		}
		else if($actionfollow == 'editonhold'){
			$insertProduct['onhold'] = $status;
			$alldata['message'] = $this->Admin_model->editStatusOnholdData($insertProduct,$offerid);
			
			redirect(base_url().'index.php/beatleAdmin/manageoffers');
			exit;
			
		}
		else if($actionfollow == 'addfromtempdata'){
			
			
			$orgid 			 = $this->input->post('mainOrgId');
			$title 			= $this->input->post('title');
			$spoint 			= $this->input->post('spoint');
			$epoint 			= $this->input->post('epoint');
			$description 				  = $this->input->post('description');
			$startdate 				  = $this->input->post('startdate');
			$offertempid 				  = $this->input->post('offertempid');
			$bannerlink 				  = $this->input->post('bannerlink');
			
			$dateArr = explode("-",$startdate);
			
			$startDate = date("Y-m-d",strtotime(trim($dateArr[0])))." 00:00:00";
			$endDate = date("Y-m-d",strtotime(trim($dateArr[1])))." 23:59:59";
			$comment 				  = $this->input->post('comment');
			
			
			$insertProduct = array();
			$insertProduct['orgid'] = $orgid;
			$insertProduct['title'] = $title;
			$insertProduct['spoint'] = $spoint;
			$insertProduct['epoint'] = $epoint;
			$insertProduct['startdate'] = $startDate;
			$insertProduct['enddate'] = $endDate;
			$insertProduct['description'] = $description;
			$insertProduct['comment'] = $comment;
			$insertProduct['active'] = "Y";
			$insertProduct['onhold'] = "N";
			$insertProduct['created_date'] = date("Y-m-d H:i:s");
			
			$insertProduct['offertempid'] = $offertempid;
			
			$alldata['message'] = $this->Admin_model->addOfferData($insertProduct,$bannerlink);
			
			$status 				  = $this->input->post('status');
			$msg = $this->Admin_model->changeStatusOfferTemprData($status,$offertempid);
			
			if($alldata['message'] != 'success'){
				unset($_POST['actionfollow']);
				$_POST['startdate'] = $startDate;
				$_POST['enddate'] = $endDate;
				$alldata['data'] = $_POST;
			}
			
			$pt = '/'.$this->uri->segment(3).'/'.$this->uri->segment(4);
			if($alldata['message'] == 'success'){
				$pt = '/add';
			}
			
			redirect(base_url().'index.php/beatleAdmin/manageoffers'.$pt.'/'.$alldata['message']);
			exit;
			//$this->load->view('beatleAdmin/manageoffers' , $alldata);
		}
		
		//$usertype = $this->uri->segment(4);
		//$hashvalue = $this->uri->segment(5);
		//$alldata['action_']		=	$action_;
		$prodid = $this->uri->segment(4);
		$alldata['productData']		=	$this->Admin_model->getAllOffersData($prodid);
		
		//echo "<pre>";
		//print_r($alldata['productData']);
		//echo "</pre>";
		
		$alldata['requestlist']		=	$this->Admin_model->getAllRequestData($prodid);
		$this->load->view('beatleAdmin/manageoffers', $alldata);
		
	}
	
	public function managenews()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		}
		
		
		
		$actionfollow 		= 	$this->input->post('actionfollow');
		$editstatus = $this->uri->segment(3);
		if($editstatus == 'editstatus'){
			$offerid = $this->uri->segment(4);
			$status = $this->uri->segment(5);
			$actionfollow = 'editstatus';
		}else 
		if($editstatus == 'editonhold'){
			$offerid = $this->uri->segment(4);
			$status = $this->uri->segment(5);
			$actionfollow = 'editonhold';
		}
		
		
		
		if($actionfollow == 'addnewproducts'){
			//echo "<pre>";
			//print_r($_POST);
			//print_r($_FILES);
			
			
			$title 			= $this->input->post('title');
			$description 				  = $this->input->post('description');
			$startdate 				  = $this->input->post('startdate');
			$dateArr = explode("-",$startdate);
			
			$startDate = date("Y-m-d",strtotime(trim($dateArr[0])))." 00:00:00";
			$endDate = date("Y-m-d",strtotime(trim($dateArr[1])))." 23:59:59";
			
			
			
			$insertProduct = array();
			$insertProduct['title'] = $title;
			$insertProduct['startdate'] = $startDate;
			$insertProduct['enddate'] = $endDate;
			$insertProduct['description'] = $description;
			$insertProduct['active'] = "Y";
			$insertProduct['created_date'] = date("Y-m-d H:i:s");
			
			//print_r($insertProduct);
			//die;
			$alldata['message'] = $this->Admin_model->addNewsData($insertProduct);
			
			if($alldata['message'] != 'success'){
				
				unset($_POST['actionfollow']);
				$alldata['data'] = $_POST;
				
			}
			
		}
		else if($actionfollow == 'editproducts'){


			$orgid 			 = $this->input->post('mainOrgId');
			$title 			= $this->input->post('title');
			$spoint 			= $this->input->post('spoint');
			$epoint 			= $this->input->post('epoint');
			$description 				  = $this->input->post('description');
			$startdate 				  = $this->input->post('startdate');
			$dateArr = explode("-",$startdate);
			
			$startDate = date("Y-m-d",strtotime(trim($dateArr[0])))." 00:00:00";
			$endDate = date("Y-m-d",strtotime(trim($dateArr[1])))." 23:59:59";
			$comment 				  = $this->input->post('comment');
			
			
			$insertProduct = array();
			$insertProduct['title'] = $title;
			$insertProduct['startdate'] = $startDate;
			$insertProduct['enddate'] = $endDate;
			$insertProduct['description'] = $description;
			$insertProduct['active'] = "Y";
			// $insertProduct['created_date'] = date("Y-m-d H:i:s");
			$offerid = $this->uri->segment(4);
			//echo "<pre>";
			
			//print_r($_POST);
			//print_r($insertProduct);
			//print_r($_FILES);
			
			$alldata['message'] = $this->Admin_model->editNewsData($insertProduct,$offerid);
		}
		else if($actionfollow == 'editstatus'){
			$insertProduct['active'] = $status;
			$alldata['message'] = $this->Admin_model->editStatusNewsData($insertProduct,$offerid);
			
			redirect(base_url().'index.php/beatleAdmin/managenews');
			exit;
		}
		
		//$usertype = $this->uri->segment(4);
		//$hashvalue = $this->uri->segment(5);
		//$alldata['action_']		=	$action_;
		echo $prodid = $this->uri->segment(4);
		$alldata['productData']		=	$this->Admin_model->getAllNewsData($prodid);
		
		$this->load->view('beatleAdmin/managenews' , $alldata);
		
		//echo "<pre>";
		//print_r($alldata);
		//echo "</pre>";
	}
	
	public function managepurchase()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		}
		
		$purchaseType 	= $this->uri->segment(3);
		$status       	  = $this->uri->segment(4);
		$purid           = $this->uri->segment(5);
		
		$actionfollow 		= 	$this->input->post('actionfollow');
		$editstatus = $this->uri->segment(3);
		if($editstatus == 'editstatus'){
			$offerid = $this->uri->segment(4);
			$status = $this->uri->segment(5);
			$actionfollow = 'editstatus';
		}else 
		if($editstatus == 'editonhold'){
			$offerid = $this->uri->segment(4);
			$status = $this->uri->segment(5);
			$actionfollow = 'editonhold';
		}
		
		
		if($actionfollow == 'editproducts'){

			//print_r($_POST);
			//die;
			
			$purid 			 = $this->input->post('purid');
			$point 			 = $this->input->post('points');
			$orgid 			 = $this->input->post('orgid');
			$status 			= $this->input->post('status');
			
			if($status == 'approved') {
				
				$rsPurchaseData = $this->Admin_model->fetchPurchaseDataOrgWise($orgid);
				
				if(count($rsPurchaseData) > 0) {
					
					$remian_point  		 		= $point + $rsPurchaseData[0]->remian_point;
					$point		 			   = $point;
					$customer_use_point    	  = $point + $rsPurchaseData[0]->customer_use_point;
					
				}else{
					
					$remian_point       	= $point;
					$point		       = $point;
					$customer_use_point  = $point;
				}
				
				
				$insertPurchase = array();
				$insertPurchase['remian_point'] = $remian_point;
				$insertPurchase['point'] = $point;
				$insertPurchase['customer_use_point'] = $customer_use_point;
				$insertPurchase['created_date'] = date('Y-m-d H:i:s');
				$insertPurchase['type'] = 'email';
				$insertPurchase['orgid'] = $orgid;
				$this->Admin_model->newInsertPurchaseData($insertPurchase);
			
			}
			

			//print_r($insertPurchase);
			//die;
			
			
			
			
			$insertProduct = array();
			$insertProduct['status'] = $status;
			// $insertProduct['created_date'] = date("Y-m-d H:i:s");
			//$this->Admin_model->insertEmailPoints($insertProduct,$purid);
			$alldata['message'] = $this->Admin_model->editPurchaseData($insertProduct,$purid);
			
		}
		
		//$usertype = $this->uri->segment(4);
		//$hashvalue = $this->uri->segment(5);
		//$alldata['action_']		=	$action_;
		
		$purid = $this->uri->segment(5);
		
		$alldata['productData']		=	$this->Admin_model->getAllPurchaseData($purid,$purchaseType,$status);
		
		$this->load->view('beatleAdmin/managepurchase' , $alldata);
		
		//echo "<pre>";
		//print_r($alldata);
		//echo "</pre>";
	}
	
	public function manageorders()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		}
		
		$actionfollow 		= 	$this->input->post('actionfollow');
		
		if($actionfollow == 'editproducts'){


			$status 				  = $this->input->post('status');
			$orderid 			   = $this->input->post('orderid');
			
			$insertProduct = array();
			$insertProduct['status'] = $status;
			$insertProduct['updated_date'] = date("Y-m-d H:i:s");
			
			$alldata['message'] = $this->Admin_model->editOrderData($insertProduct,$orderid);
			
		}
		
		//$usertype = $this->uri->segment(4);
		//$hashvalue = $this->uri->segment(5);
		//$alldata['action_']		=	$action_;
		$prodid = $this->uri->segment(4);
		$alldata['productData']		=	$this->Admin_model->getAllOrdersData($prodid);
		
		$this->load->view('beatleAdmin/manageorders' , $alldata);
		
		//echo "<pre>";
		//print_r($alldata);
		//echo "</pre>";
	}
	
	public function deleteUserById()
	{
		$UID  = $this->input->post('id');
		$this->load->model('Admin_model');
		$data = $this->Admin_model->deleteUserById($UID);
		return $data;
	}
	
	public function deleteNewsById()
	{
		$UID  = $this->input->post('id');
		$this->load->model('Admin_model');
		$data = $this->Admin_model->deleteNewsById($UID);
		return $data;
	}
	
	public function deletePurchaseById()
	{
		$UID  = $this->input->post('id');
		$this->load->model('Admin_model');
		$data = $this->Admin_model->deletePurchaseById($UID);
		return $data;
	}

	public function deleteBranchById()
	{
		$UID  = $this->input->post('id');
		$this->load->model('Admin_model');
		$data = $this->Admin_model->deleteBranchById($UID);
		echo '1';
	}
	
	public function deleteOrgById()
	{
		$UID  = $this->input->post('id');
		$this->load->model('Admin_model');
		$data = $this->Admin_model->deleteOrgById($UID);
		echo '1';
	}
	
	public function deleteIndById()
	{
		$UID  = $this->input->post('id');
		$this->load->model('Admin_model');
		$data = $this->Admin_model->deleteIndById($UID);
		echo '1';
	}
	
	public function fetchPageContentData_ajax(){
		
		$pageid = $_POST['pageid']; 
		$this->load->model('Admin_model');
		$pagecArr = $this->Admin_model->getPageConByPageId($pageid);
		
		$html = '';
		$html .= '<select name="pageContentID" id="pageContentID" style="width: 70%; padding: 7px 7px; margin-bottom: 15px; border-radius: 7px;">';
								for($i=0; $i<count($pagecArr); $i++){
									$html .= '<option value="'.$pagecArr[$i]->pageConId.'">'.$pagecArr[$i]->db_pageConTitle.'</option>'; 
								}
		$html .= '</select>';
		echo $html;
		exit;
		//echo "xxxx";
		
	}
	
	public function createpageticketcontent_ajax(){
			
		$pageid = $_POST['pageid']; 
		$pagecid = $_POST['pagecid']; 
		$this->load->model('Admin_model');
		
			$cnt = 0;
			
			
			$Exist = 'n';
			if(isset($_SESSION['ticketdata'])){
				$cnt = count($_SESSION['ticketdata']);
			}
			
			for($i=0; $i<count(@$_SESSION['ticketdata']); $i++) {
				if($_SESSION['ticketdata'][$i]['pagecid'] == $pagecid) {
					$Exist = 'y';
				}
			}
			
			if($Exist == 'n') {
				$_SESSION['ticketdata'][$cnt]['pageid'] = $pageid;
				$_SESSION['ticketdata'][$cnt]['pagecid'] = $pagecid;
			}
			
			$html = '';
			for($i=0; $i<count($_SESSION['ticketdata']); $i++) {
				$pgCArr = $this->Admin_model->getPageConByPageContentId($_SESSION['ticketdata'][$i]['pagecid']);
				$html .= $pgCArr[0]->db_pageConTitle.'&nbsp; <i onclick="javascript: return deleteData('.$i.')" class="fa fa-times" aria-hidden="true" style="color:#a94442;"></i> &nbsp;&nbsp;&nbsp;';
			}
			echo $html;
	}
	
	public function removedatafromsessionticket_ajax(){

		$sid = $_POST['sid']; 
		$this->load->model('Admin_model');
		$newArr = array();
		$cnt = 0;
		
		for($i=0; $i<count($_SESSION['ticketdata']); $i++) {
			if($i != $sid) {
				$newArr[$cnt]['pageid'] = $_SESSION['ticketdata'][$i]['pageid'];
				$newArr[$cnt]['pagecid'] = $_SESSION['ticketdata'][$i]['pagecid'];
				$cnt++;
			}
		}
		
		unset($_SESSION['ticketdata']);
		
		$_SESSION['ticketdata'] = $newArr;
		
		$html = '';
			if(count($_SESSION['ticketdata']) > 0) {
				for($i=0; $i<count($_SESSION['ticketdata']); $i++) {
					$pgCArr = $this->Admin_model->getPageConByPageContentId($_SESSION['ticketdata'][$i]['pagecid']);
					$html .= $pgCArr[0]->db_pageConTitle.'&nbsp; <i onclick="javascript: return deleteData('.$i.')" class="fa fa-times" aria-hidden="true" style="color:#a94442; cursor:pointer;"></i> &nbsp;&nbsp;&nbsp;';
				}
			}else{
				$html = 'No any option selected';	
			}
		echo $html;
		
	}
	
	public function SearchUserByType()
	{	
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
			{ 
				redirect('');
			} 
		$usertype = $_POST['usertype']; 
		
		$data = $this->Admin_model->SearchUserByType($usertype);
		if (!empty($data))
		{
			foreach ($data as $key=>$valuser)
			{ 
				echo '<tr class="animate-repeat bg-white ng-scope" id="rowid_'.$valuser->userId.'">
									<td class="ng-binding">'.$valuser->db_username.'</td>
									<td class="ng-binding">'.$valuser->db_userLoginName.'</td>
									<td class="ng-binding">'.$valuser->db_phone.'></td>
									<td class="ng-binding">'.$valuser->db_email.'</td>
									<td class="ng-binding">'.$usertype.'</td>
									<td class="ng-binding" href="#">';
										$userid = $valuser->userId;
										$usertype = $valuser->db_usertype;
										$data = $this->Admin_model->getAllOrganizationByUserId($usertype,$userid);
										if (!empty($data[0]->db_Orgname)){echo $data[0]->db_Orgname;}
									echo '</td>
									<td><a class="btn-sm btn btn-success btn-rounded" href="users/'.$valuser->userId.'">Edit</a></td>
									<td><a class="btn-sm btn btn-primary btn-rounded deluser" data-uid="'.$valuser->userId.'">Delete</a></td>
								</tr>';
				 
			}
		}
		else 
		{
			echo '<tr class="ng-hide">
								<td colspan="10"><h1 class="text-center text-muted ng-scope">No Users</h1><!-- end ngIf: !UsersList.ui.loading --></td>
							</tr>';
		}
		//return $data; 
	}
	
	public function organization()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		} 
		$alldata['Alluser'] 	=	$this->Admin_model->getAllUser();
		$UID					=   $this->input->post('UID'); 
		$Orgnamec  				= 	$this->input->post('addOrgName');
		$Orgid = $this->uri->segment(3);
		$alldata['orgid'] = $Orgid;
		if (!empty($Orgid))
		{
			$alldata['OrgById'] = $this->Admin_model->getOrganizationById($Orgid);
		}
		if (empty($Orgid) && !empty($Orgnamec))
		{ 
			$Orgname  = $this->input->post('addOrgName');
			$ownerId  = $this->input->post('addBranchOrg');
			$OrgType  = $this->input->post('addOrgType');
			$target_dir = "assets/OrganizationPics/";
			$target_file = time().'_'.'OrgProfile.jpg';
			$date	= date('Y-m-d H:i:s');
			$status = '1';
			$imageFileType = pathinfo($_FILES['filetoupload']['name'],PATHINFO_EXTENSION);
			
			if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" ) 
			{
				echo 'e1';
			}
			else
			{
				$dirfile = $target_dir.$target_file;
				move_uploaded_file($_FILES['filetoupload']['tmp_name'],$dirfile);
				$insertdata = array
				(
					'db_Orgname' => $Orgname,
					'db_Orgpics' => $target_file,
					'db_ownerId' => $ownerId,
					'db_orgtype' => $OrgType,
					'status'	 => $status,
					'db_userById'=> $loginId,	
					'created_date' => $date
				);
				
				$alldata['message'] = $this->Admin_model->addOrganization($insertdata,$Orgname);
				//print_r($alldata['message']);
				//redirect('beatleAdmin/organizationList');
			}
		}
		 
		
		
		$this->load->view('beatleAdmin/organization' , $alldata);
	}
	
	public function organization_profile()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		} 
//		$alldata['Alluser'] 	=	$this->Admin_model->getAllUser();
		$alldata['Alluser'] 	=	$this->Admin_model->getAllUserOwner();
		$alldata['AllOrg'] 		=	$this->Admin_model->getAllOrganization(); 
		$alldata['AllOrgtype'] 	=	$this->Admin_model->getAllOrganizationtype();
		$alldata['AllBranch'] 		=	$this->Admin_model->getAllOrganization(); 
		$UID					=   $this->input->post('UID'); 
		$Orgnamec  				= 	$this->input->post('addOrgName');
		$Orgid = $this->uri->segment(3);
		$alldata['orgid'] = $Orgid;
		if (!empty($Orgid))
		{
			$alldata['OrgById'] = $this->Admin_model->getOrganizationById($Orgid);
		}
		
		
		$this->load->view('beatleAdmin/organization_profile' , $alldata);
	}
	
	
	
	public function end_user_profile()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		} 
		$alldata['Alluser'] 	=	$this->Admin_model->getAllUser();
		$UID					=   $this->input->post('UID'); 
		$Orgnamec  				= 	$this->input->post('addOrgName');
		$Orgid = $this->uri->segment(3);
		$alldata['orgid'] = $Orgid;
		if (!empty($Orgid))
		{
			$alldata['OrgById'] = $this->Admin_model->getOrganizationById($Orgid);
		}
		if (empty($Orgid) && !empty($Orgnamec))
		{ 
			$Orgname  = $this->input->post('addOrgName');
			$ownerId  = $this->input->post('addBranchOrg');
			$OrgType  = $this->input->post('addOrgType');
			$target_dir = "assets/OrganizationPics/";
			$target_file = time().'_'.'OrgProfile.jpg';
			$date	= date('Y-m-d H:i:s');
			$status = '1';
			$imageFileType = pathinfo($_FILES['filetoupload']['name'],PATHINFO_EXTENSION);
			
			if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" ) 
			{
				echo 'e1';
			}
			else
			{
				$dirfile = $target_dir.$target_file;
				move_uploaded_file($_FILES['filetoupload']['tmp_name'],$dirfile);
				$insertdata = array
				(
					'db_Orgname' => $Orgname,
					'db_Orgpics' => $target_file,
					'db_ownerId' => $ownerId,
					'db_orgtype' => $OrgType,
					'status'	 => $status,
					'db_userById'=> $loginId,	
					'created_date' => $date
				);
				
				$alldata['message'] = $this->Admin_model->addOrganization($insertdata,$Orgname);
				//print_r($alldata['message']);
				//redirect('beatleAdmin/organizationList');
			}
		}
		 
		
		
		$this->load->view('beatleAdmin/end_user_profile' , $alldata);
	}
	
	
	
	public function total_low_rating()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		} 
		$alldata['Alluser'] 	=	$this->Admin_model->getAllUser();
		$UID					=   $this->input->post('UID'); 
		$Orgnamec  				= 	$this->input->post('addOrgName');
		$Orgid = $this->uri->segment(3);
		$alldata['orgid'] = $Orgid;
		if (!empty($Orgid))
		{
			$alldata['OrgById'] = $this->Admin_model->getOrganizationById($Orgid);
		}
		if (empty($Orgid) && !empty($Orgnamec))
		{ 
			$Orgname  = $this->input->post('addOrgName');
			$ownerId  = $this->input->post('addBranchOrg');
			$OrgType  = $this->input->post('addOrgType');
			$target_dir = "assets/OrganizationPics/";
			$target_file = time().'_'.'OrgProfile.jpg';
			$date	= date('Y-m-d H:i:s');
			$status = '1';
			$imageFileType = pathinfo($_FILES['filetoupload']['name'],PATHINFO_EXTENSION);
			
			if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" ) 
			{
				echo 'e1';
			}
			else
			{
				$dirfile = $target_dir.$target_file;
				move_uploaded_file($_FILES['filetoupload']['tmp_name'],$dirfile);
				$insertdata = array
				(
					'db_Orgname' => $Orgname,
					'db_Orgpics' => $target_file,
					'db_ownerId' => $ownerId,
					'db_orgtype' => $OrgType,
					'status'	 => $status,
					'db_userById'=> $loginId,	
					'created_date' => $date
				);
				
				$alldata['message'] = $this->Admin_model->addOrganization($insertdata,$Orgname);
				//print_r($alldata['message']);
				//redirect('beatleAdmin/organizationList');
			}
		}
		 
		
		
		$this->load->view('beatleAdmin/total_low_rating' , $alldata);
	}
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	public function editOrganization()
	{
			$this->load->model('Admin_model');
			$loginId 				= 	$this->session->userdata('LoginUserid');
			$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
			if (empty($alldata['userdata1']))
			{ 
				redirect('');
			} 
			$alldata['Alluser'] 	=	$this->Admin_model->getAllUser();
			$ownerId  = $this->input->post('addBranchOrg');
			$Orgname  = $this->input->post('addOrgName');
			$OrgType  = $this->input->post('addOrgType');
			$Orid 	= $this->input->post('orgid');
			$target_dir = "assets/OrganizationPics/";
			$target_file = time().'_'.'OrgProfile.jpg';
			$date	= date('Y-m-d H:i:s');
			
			
				if (!empty($_FILES['filetoupload']['name']))
				{
						$imageFileType = pathinfo($_FILES['filetoupload']['name'],PATHINFO_EXTENSION);
						
						if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif" ) 
						{
							echo 'e1';
						}
						else 
						{
							$dirfile = $target_dir.$target_file; 
							move_uploaded_file($_FILES['filetoupload']['tmp_name'],$dirfile);
						}
				}
				else 
				{
					$target_file = $this->input->post('oldimg');
				}
				$insertdata = array
					(
						'db_Orgname' => $Orgname,
						'db_Orgpics' => $target_file,
						'db_orgtype' => $OrgType,
						'db_ownerId' => $ownerId,
						'db_userById'=> $loginId,	
						'updated_date' => $date
					);
			// print_r($insertdata); echo $Orid; die;
					$alldata['message'] = $this->Admin_model->UpdateOrganizationById($insertdata,$Orid);

					$reviewdata = array
					(
						
						'webprofileimage' => $target_file,
						'restType' 		  => $OrgType,
					);
					$this->Admin_model->UpdateReviewPageById($reviewdata,$Orid);
				//	$url = $_SERVER['HTTP_REFERER'];
					//redirect($url);
					redirect('index.php/beatleAdmin/organizationList');
		 
	}
	public function organizationList()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		} 
		$alldata['AllOrg'] 		=	$this->Admin_model->getAllOrganization(); 
		$alldata['AllOrgtype'] 	=	$this->Admin_model->getAllOrganizationtype(); 
		$this->load->view('beatleAdmin/organizationList' , $alldata);
	}
	public function getOrgByType()
	{
		$this->load->model('Admin_model');
		$serachType = $_POST['serachbytype'];
		$data = $this->Admin_model->getOrgByType($serachType);
	}
	
	public function branch()
	{
	
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		} 
		$alldata['AllOrg'] 		=	$this->Admin_model->getAllOrganization(); 
		$alldata['Alluser'] 	=	$this->Admin_model->getAllUser(); 
		$alldata['AllState'] 	=	$this->Admin_model->getAllState(); 
		
		$bracId = $this->uri->segment(3);
		$alldata['bracId'] = $bracId;
		if (!empty($bracId))
		{
			$alldata['editbranch'] = $this->Admin_model->getBranchById($bracId);
		}
		if (isset($_POST['addBranchsubmit']))
		{
			
			$branchname 		= 	$this->input->post('addBranchName');
			$branchOrg 			= 	$this->input->post('addBranchOrg');
			$branchlocation 	= 	$this->input->post('addBranchLocation');
			$branchManager 		= 	$this->input->post('addBranchManager');
			$date 				= 	date('Y-m-d H:i:s');
			$status 			= 	'1';
			$r  				= 	rand(1,1000);
			$unqId  			= 	'BR_'.$r;
			$insertdata = array
				(
					'db_branchName' 	=> 	$branchname,
					'db_branchOrg' 		=> 	$branchOrg,
					'db_branchUnId' 	=> 	$unqId,
					'db_branchLocation' => 	$branchlocation,
					'db_branchManager' 	=> 	$branchManager,
					'db_branchAddedBy'	=>	$loginId,
					'status' 			=> 	$status,
					'Branchcreated_date'=> 	$date
				);
				
			$alldata['message'] = $this->Admin_model->addBranch($insertdata);	
		 
		}	
		
		
		$this->load->view('beatleAdmin/branch' , $alldata);
	}
	
	public function editBranch()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		} 
		$alldata['AllOrg'] 		=	$this->Admin_model->getAllOrganization(); 
		$alldata['Alluser'] 	=	$this->Admin_model->getAllUser(); 
		$alldata['AllState'] 	=	$this->Admin_model->getAllState(); 
		$branchname 		= 	$this->input->post('addBranchName');
		$branchType 		= 	$this->input->post('addBranchType');
		$branchOrg 			= 	$this->input->post('addBranchOrg');
		$branchlocation 	= 	$this->input->post('addBranchLocation');
		$branchManager 		= 	$this->input->post('addBranchManager');
		$bracId 			= 	$this->input->post('bracId');
		$date 				= 	date('Y-m-d H:i:s');
		$status 			= 	'1';
		 
			$insertdata = array
				(
					'db_branchName' 	=> 	$branchname,
					'db_branch_type'	=>	$branchType,
					'db_branchOrg' 		=> 	$branchOrg,
					'db_branchLocation' => 	$branchlocation,
					'db_branchManager' 	=> 	$branchManager,
					'db_branchAddedBy'	=>	$loginId,
					'status' 			=> 	$status,
					'updated_date'		=> 	$date
				);
				//print_r($insertdata);die;
			$alldata['message'] = $this->Admin_model->editBranch($insertdata,$bracId);	
			redirect('index.php/beatleAdmin/branchList');
	 
	}
	
	public function getBranchByOrgIDAjax()
	{	echo $orgid = $_POST['orgId']; die;
		$this->load->model('Admin_model');
	
		//$data = $this->Admin_model-> getAllBranchByOrg($orgid);
		//print_r($data);
	}
	
	public function branchList()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		} 
		$alldata['AllOrg'] 		=	$this->Admin_model->getAllOrganization(); 
		$alldata['Alluser'] 	=	$this->Admin_model->getAllUser(); 
		$alldata['AllState'] 	=	$this->Admin_model->getAllState(); 
		
		$Orgid 					=	$this->uri->segment(3); 
		$token 					=	$this->uri->segment(4); 
		
		if (!empty($Orgid) && $token == '')
		{ 
			$alldata['AllBranch'] 	=	$this->Admin_model->getAllBranchByOrg($Orgid); 
		}
		else if (!empty($Orgid) && $token == 'token')
		{ 
			$alldata['AllBranch'] 	=	$this->Admin_model->getBranchByIndId($Orgid); 
		}
		else 
		{
			$alldata['AllBranch'] 	=	$this->Admin_model->getAllBranch(); 
		}
		$this->load->view('beatleAdmin/branchList' , $alldata);
	}
	
	public function organizationBranch()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		} 
		$alldata['AllOrg'] 		=	$this->Admin_model->getAllOrganization(); 
		$alldata['Alluser'] 	=	$this->Admin_model->getAllUser(); 
		$alldata['AllState'] 	=	$this->Admin_model->getAllState(); 
		$Orgid 					=	$this->uri->segment(3); 
		$alldata['OrgById'] 	= 	$this->Admin_model->getOrganizationById($Orgid);
		$alldata['AllBranch'] 	=	$this->Admin_model->getAllBranchByOrg($Orgid); 	
		
		if (isset($_POST['addBranchsubmit']))
		{
			$branchname 		= 	$this->input->post('addBranchName');
			$branchOrg 			= 	$this->input->post('addBranchOrg');
			$branchlocation 	= 	$this->input->post('addBranchLocation');
			$branchManager 		= 	$this->input->post('addBranchManager');
			$date 				= 	date('Y-m-d H:i:s');
			$status 			= 	'1';
			$r  				= 	rand(1,1000);
			$unqId  			= 	'BR_'.$r;
			$insertdata = array
				(
					'db_branchName' 	=> 	$branchname,
					'db_branchOrg' 		=> 	$branchOrg,
					'db_branchUnId' 	=> 	$unqId,
					'db_branchLocation' => 	$branchlocation,
					'db_branchManager' 	=> 	$branchManager,
					'db_branchAddedBy'	=>	$loginId,
					'status' 			=> 	$status,
					'Branchcreated_date'=> 	$date
				);
				
			$alldata['message'] = $this->Admin_model->addBranch($insertdata);	
			$url = $_SERVER['HTTP_REFERER'];
			redirect($url);
		}	
		
		$this->load->view('beatleAdmin/organizationBranch' , $alldata);	
	}
	
	public function getBranchById()
	{
		echo $BId = $_POST['BId'];die;
		$this->load->model('Admin_model');
		$data = $this->Admin_model->getBranchById($BId);
		
	}
	
	public function moreIndustry()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		$alldata['AllBranch'] 		= 	$this->Admin_model->getAllBranch();
		$industryname1 = $this->input->post('addOrgName');
		$InId = $this->uri->segment(3);
		
		$this->load->view('beatleAdmin/industry' , $alldata);
	}
	
	
	public function industry()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		} 
		//$alldata['AllBranch'] 	= 	$this->Admin_model->getAllBranch();
		$alldata['AllOrg'] 		=	$this->Admin_model->getAllOrganization(); 
		$industryname1 = $this->input->post('addOrgName');
		$addLinemanager = $this->input->post('addLinemanager');
		$InId = $this->uri->segment(3);
		$orgId = $this->uri->segment(4);
		if (!empty($InId))
		{
			$alldata['AllBranchByorgid'] 	= 	$this->Admin_model->getAllBranchByOrg($orgId);
			$alldata['getAllLineManByOrg'] 	= 	$this->Admin_model->getAllLineManByOrg($orgId);
			$alldata['orgId'] = $orgId;
			$alldata['InId'] = $InId;
		}
		else 
		{
			$alldata['AllBranchByorgid'] 	= 	$this->Admin_model->getAllBranchByOrgnization();
			
			$alldata['getAllLineManByOrg'] 	= 	$this->Admin_model->getAllLineManByOrganization();
			//echo '<pre>';print_r($alldata['getAllLineManByOrg']);
		}
		
		$alldata['getIndustryTypeData'] 	= 	$this->Admin_model->fetch_all_ind_type_data();
		
		/*if (!empty($orgId))
		{
			$alldata['branchByOrg'] = $this->Admin_model->getAllBranchByOrg($orgId);
		}
		else 
		{*/
			$alldata['branchByOrg'] = $this->Admin_model->getAllBranch();
		//}
		$alldata["Linemanager"] =  $this->Admin_model->getAllUserLinemanage();
		 
		if (empty($InId) && !empty($industryname1))
		{
			//print_r($_POST);die;
			$BranchOrg = $_POST['addBranchOrg'];
			$status = '1';
			$date 	= date('Y-m-d H:i:s');
			$industryname = $this->input->post('addOrgName');
			//$addBranchOrg = $this->input->post('addBranchOrg');
			$addnumbertabs = $this->input->post('addnumbertabs');
			$addBranchOrg = $this->input->post('addBranchOrg');
			$addLinemanager = $this->input->post('addLinemanager');
			$industrytype = $this->input->post('industrytype');
			
				$indLogin = rand(1,1000);
				$indLoginId = 'IND_'.$addBranchOrg.'_'.$indLogin;
				$insertdata = array(
					'db_industry' 	=> 	$industryname,
					'db_ind_type_id' =>	$industrytype,
					'db_bracnchid' 	=> 	$addBranchOrg,
					'db_numberTabs' => 	$addnumbertabs,
					'db_userid' 	=> 	$addLinemanager,
					'db_IndUnqId' 	=> 	$indLoginId,
					'db_IndLoginId' => 	$indLoginId,
					'db_addedBy' 	=> 	$loginId,
					'status' 		=> 	$status,
					'created_date' 	=> 	$date
				);
				$data['message'] = $this->Admin_model->insertIndustry($insertdata); 
			 
			
			if (!empty($data))
			{
				redirect('index.php/beatleAdmin/industryList', 'refresh');
				//redirect('admin/industryList');
			}
		}
		$alldata['InById'] = $this->Admin_model->getIndustryById($InId);
		
		$this->load->view('beatleAdmin/industry' , $alldata);
	}
	
	
	public function industrytype()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		
		$alldata['all_ind_type_data'] 	= 	$this->Admin_model->fetch_all_ind_type_data();
		$acn = $this->uri->segment(3);
		$typeid = $this->uri->segment(4);
		$alldata['indtypedata'] 	= 	array();
		if(!empty($acn) && $acn == 'edit' && !empty($typeid) && $typeid != 0 && $typeid != ''){
				$alldata['indtypedata'] 	= 	$this->Admin_model->fetch_all_ind_type_data($typeid);			
		}
		//print_r($_POST);
		$actionfollow = $this->input->post("actionfollow");
		
		if($actionfollow == 'adddata'){
			$name = $this->input->post("name");
			
			$alldata['message'] = $this->Admin_model->addIndTypeData(array('name'=>$name));
			
			if($alldata['message'] != 'success'){
				unset($_POST['actionfollow']);
				$alldata['data'] = $_POST;
			}
						
		}else if($actionfollow == 'editdata'){
			$name = $this->input->post("name");
			$alldata['message'] = $this->Admin_model->editIndTypeData(array('name'=>$name),$typeid);
		}
		$this->load->view('beatleAdmin/industrytype' , $alldata);
	}
	
	function menusettingsajax(){
		
		$this->load->model('Admin_model');
		$this->load->model('Customer_model');
		$this->load->database();
		$name = $this->input->post("name");
		$status = $this->input->post("status");
		
		$status == 'true'?$status = 'checked':$status = '';
		$updateArr = array();
		$updateArr['ConfigValue'] = $status;
		
		$query = $this->db->where('ConfigName',$name)->update('appconfig',$updateArr);
		$this->Customer_model->defineCustomerAppColor();	
		
		$this->Admin_model->fetchCustomerAppMenu();
		
		
	}
	
	public function customerandroidapp()
	{

		$this->load->model('Customer_model');
		$this->Customer_model->defineCustomerAppColor();	

		
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		
		$type_ = $this->input->post("type_");
		if($type_ == 'setcolor' || $type_ == 'default'){
			
			if($type_ == 'setcolor'){
				$background_color = $this->input->post("background_color");
				$footer_color = $this->input->post("footer_color");
				$button_color = $this->input->post("button_color");
			}else if($type_ == 'default'){
				$background_color = $this->input->post("background_color_default");
				$footer_color = $this->input->post("footer_color_default");
				$button_color = $this->input->post("button_color_default");
			}
			
			if(!empty($background_color) && strlen($background_color) == 6)
			$query = $this->db->where('ConfigName',"CA_BACKGROUND_COLOR")->update('appconfig',array("ConfigValue"=>"#".$background_color));

			if(!empty($footer_color) && strlen($footer_color) == 6)
			$query = $this->db->where('ConfigName',"CA_FOOTER_COLOR")->update('appconfig',array("ConfigValue"=>"#".$footer_color));
			
			if(!empty($button_color) && strlen($button_color) == 6)
			$query = $this->db->where('ConfigName',"CA_LOGIN_BUTTON_COLOR")->update('appconfig',array("ConfigValue"=>"#".$button_color));
			
		}
		
		$this->load->view('beatleAdmin/customerandroidapp' , $alldata);
	}
	
	public function EditIndustry()
	{		
			$this->load->model('Admin_model');
			$loginId 				= 	$this->session->userdata('LoginUserid');
			$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
			if (empty($alldata['userdata1']))
			{ 
				redirect('');
			} 
			$alldata['AllBranch'] 	= 	$this->Admin_model->getAllBranch();

			$status = '1';
			$date 	= date('Y-m-d H:i:s');
			$industryname = $this->input->post('addOrgName');
			//$Id			  = $this->input->post('InId');
			//$addBranchOrg = $this->input->post('addBranchOrg');
			 
			$BranchOrg = $_POST['addBranchOrg'];
			$addnumbertabs = $this->input->post('addnumbertabs');
			$addLinemanager = $this->input->post('addLinemanager');
			$industrytype = $this->input->post('industrytype');
			
				$insertdata = array(
					'db_industry' 	=> 	$industryname,
					'db_ind_type_id' 	=> 	$industrytype,
					'db_bracnchid' 	=> 	$BranchOrg,
					'db_numberTabs' => 	$addnumbertabs,
					'db_userid' 	=> 	$addLinemanager,
					'db_addedBy' 	=> 	$loginId,
					'status' 		=> 	$status
				);
//print_r($insertdata);die;
				$InId = $this->input->post('InId');
				$data['message'] = $this->Admin_model->updateIndustry($insertdata,$InId);
				$indName = $this->Admin_model->fetch_all_ind_type_data($industrytype);
				$insertReviewdata = array(
					'restType' 	=> 	$indName[0]->name
				);
			  	$this->Admin_model->updateReviewPageIndustry($insertReviewdata,$InId);
			 
			 redirect('index.php/beatleAdmin/industryList', 'refresh');
	}
	public function industryList()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		} 
		echo $bId = $this->uri->segment(3);
		
		if (!empty($bId))
		{
			$alldata['allIndustry']	=	$this->Admin_model->getIndustryByBranchId($bId);
			
			//print_r($alldata['allIndustry']);
			
		}
		else 
		{
			$alldata['allIndustry']	=	$this->Admin_model->getAllIndustry();
		}
		$alldata['allpages']	=	$this->Admin_model->getallpage();
		$this->load->view('beatleAdmin/industryList' , $alldata);
	}
	
	//testing file	
	public function customer()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		} 
		echo $bId = $this->uri->segment(3);
		
		if (!empty($bId))
		{
			$alldata['allIndustry']	=	$this->Admin_model->getIndustryByBranchId($bId);
			
			//print_r($alldata['allIndustry']);
			
		}
		else 
		{
			$alldata['allIndustry']	=	$this->Admin_model->getAllIndustry();
		}
		$alldata['allpages']	=	$this->Admin_model->getallpage();
		$alldata['allUser1']		=	$this->Admin_model->getAllUser();
		$this->load->view('beatleAdmin/customer' , $alldata);
	}
	
	
	//testing file total_email	
	public function total_email()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		} 
		echo $bId = $this->uri->segment(3);
		
		if (!empty($bId))
		{
			$alldata['allIndustry']	=	$this->Admin_model->getIndustryByBranchId($bId);
			
			//print_r($alldata['allIndustry']);
			
		}
		else 
		{
			$alldata['allIndustry']	=	$this->Admin_model->getAllIndustry();
		}
		$alldata['allpages']	=	$this->Admin_model->getallpage();
		$this->load->view('beatleAdmin/total_email' , $alldata);
	}
	
	
	
	//total_package
	public function total_package()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		} 
		echo $bId = $this->uri->segment(3);
		
		if (!empty($bId))
		{
			$alldata['allIndustry']	=	$this->Admin_model->getIndustryByBranchId($bId);
			
			//print_r($alldata['allIndustry']);
			
		}
		else 
		{
			$alldata['allIndustry']	=	$this->Admin_model->getAllIndustry();
		}
		$alldata['allpages']	=	$this->Admin_model->getallpage();
		$this->load->view('beatleAdmin/total_package' , $alldata);
	}
	
	//limited_pro
	public function limited_pro()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		} 
		echo $bId = $this->uri->segment(3);
		
		if (!empty($bId))
		{
			$alldata['allIndustry']	=	$this->Admin_model->getIndustryByBranchId($bId);
			
			//print_r($alldata['allIndustry']);
			
		}
		else 
		{
			$alldata['allIndustry']	=	$this->Admin_model->getAllIndustry();
		}
		$alldata['allpages']	=	$this->Admin_model->getallpage();
		$this->load->view('beatleAdmin/limited_pro' , $alldata);
	}
	
	//unlimited_pro
	public function unlimited_pro()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		} 
		echo $bId = $this->uri->segment(3);
		
		if (!empty($bId))
		{
			$alldata['allIndustry']	=	$this->Admin_model->getIndustryByBranchId($bId);
			
			//print_r($alldata['allIndustry']);
			
		}
		else 
		{
			$alldata['allIndustry']	=	$this->Admin_model->getAllIndustry();
		}
		$alldata['allpages']	=	$this->Admin_model->getallpage();
		$this->load->view('beatleAdmin/unlimited_pro' , $alldata);
	}
	
	
	//tria_pro
	public function tria_pro()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		} 
		echo $bId = $this->uri->segment(3);
		
		if (!empty($bId))
		{
			$alldata['allIndustry']	=	$this->Admin_model->getIndustryByBranchId($bId);
			
			//print_r($alldata['allIndustry']);
			
		}
		else 
		{
			$alldata['allIndustry']	=	$this->Admin_model->getAllIndustry();
		}
		$alldata['allpages']	=	$this->Admin_model->getallpage();
		$this->load->view('beatleAdmin/tria_pro' , $alldata);
	}
	
	
	
	
	//total-feedback
	public function total_feedback()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		} 
		echo $bId = $this->uri->segment(3);
		
		if (!empty($bId))
		{
			$alldata['allIndustry']	=	$this->Admin_model->getIndustryByBranchId($bId);
			
			//print_r($alldata['allIndustry']);
			
		}
		else 
		{
			$alldata['allIndustry']	=	$this->Admin_model->getAllIndustry();
		}
		$alldata['allpages']	=	$this->Admin_model->getallpage();
		$this->load->view('beatleAdmin/total_feedback' , $alldata);
	}
	
	public function feedbackdetails()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		} 


		
		// to get organization id from url
		$orgid = $this->uri->segment(3);
		
		// to get branch id from url
		$branchid = $this->uri->segment(4);
		
		// to get industry id from url
		$indid = $this->uri->segment(5);
		
		
		$dataArr = array();
		$dataArr['orgid'] = $orgid;
		$dataArr['branchid'] = $branchid;
		$dataArr['indid'] = $indid;
		
		
		
		$alldata['orgName'] 	= 	$this->Admin_model->getOrganizationById($orgid);
		
		
		$alldata['surveydata'] 	= 	$this->Admin_model->fetchAllSurveyData($dataArr);
		
		$this->load->view('beatleAdmin/feedbackdetails' , $alldata);
	}
	
	
	public function branchIndustry()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		} 
		$alldata['allIndustry']	=	$this->Admin_model->getAllIndustry();
		$alldata['Alluser'] 	=	$this->Admin_model->getAllUser(); 
		$id 					=	$this->uri->segment(3);
		$alldata['branchById']	=	$this->Admin_model->getBranchInfoById($id);
		
		if (isset($_POST['addIndsubmit'])){
		echo '<pre>';print_r($_POST);}
		
		$this->load->view('beatleAdmin/branchIndustry' , $alldata);
	}
	
	
	
	
	public function addIndustryInBranch()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
	}
	

	public function pages()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		} 
		$pageid = $this->uri->segment(3);
		$alldata['pageid'] = $pageid;
		$pagename1 = $this->input->post('addOrgName');
		if (empty($pageid) && !empty($pagename1))
		{
			$pagename = $this->input->post('addOrgName');
			$page = $pagename;
			$pagetype = $this->input->post('addBranchOrg');
			$status   = '1';
			$date 	  = date('Y-m-d H:i:s');
			$inserdata = array(
				'db_pagename' 		=> 	$page,
				'db_pagetype' 		=> 	$pagetype,
				'db_pageaddedBy' 	=> 	$loginId,
				'status' 			=> 	$status,
				'created_date' 		=> 	$date
			);	
			$alldata['success'] = $this->Admin_model->insertPage($inserdata,$page);
			 	 
	
		
			//$url = $_SERVER['HTTP_REFERER'];
			//redirect($url);
		}
		
		$alldata['pageByid'] = $this->Admin_model->getPageById($pageid); 
	
		
		$this->load->view('beatleAdmin/pages' , $alldata);
	}	
	public function editPageById()
	{
			$this->load->model('Admin_model');
			$loginId 				= 	$this->session->userdata('LoginUserid');
			$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
			if (empty($alldata['userdata1']))
			{ 
				redirect('');
			} 
			$pagename = $this->input->post('addOrgName');
			$page = $pagename;
			$pagetype = $this->input->post('addBranchOrg');
			$pageid = $this->input->post('pageid');
			$status   = '1';
			$date 	  = date('Y-m-d H:i:s');
			$inserdata = array(
				'db_pagename' => $page,
				'db_pagetype' => $pagetype,
				'db_pageaddedBy' => $loginId,
				'status' => $status,
				'created_date' => $date
			);	
			 
			$alldata['success'] = $this->Admin_model->UpdatePageById($inserdata,$pageid,$page);
			 redirect('index.php/beatleAdmin/pageList');
	}
	public function pageList()
	{
		$this->load->model('Admin_model');
		$loginId 						= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 			= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		} 
		$indId = $this->uri->segment(3);
		if (empty($indId))
		{
			$alldata['allpages'] 			= 	$this->Admin_model->getallpage();
		}
		else 
		{
			$alldata['allpagesserach'] 			= 	$this->Admin_model->getallpageByIndId($indId);
		}
		$alldata['allpagesContent'] 	= 	$this->Admin_model->getallPageContent();
		$this->load->view('beatleAdmin/pagesList' , $alldata);
	}
	public function deletePageById()
	{
		$pageId = $_POST['id'];
		$this->load->model('Admin_model');
		$data = $this->Admin_model->deletePageById($pageId);
		//print_r($data[0]['db_pagesId']);
		/*for ($i=0; $i < count($data); $i++) { 
			echo $data[$i]->IndId;
		}*/
		$rsArr  = array();
		foreach ($data as $key => $value) {
			//echo $value->IndId;
			$pagesCount = explode(',',$value->db_pagesId);
			foreach ($pagesCount as $k=>$v)
				 {
					 if($v != $pageId){
					 	$rsArr[]  = $v;
					 }
					
				 }
				 $allval    = implode(',',$rsArr);
				 $insertdata = array(
					'db_pagesId' => $allval
				);
				$this->Admin_model->addpagesToIndustry($value->IndId,$insertdata);
				$rsArr  = array();
		}

		echo  '1';

	}

	public function deletePageContentById(){
		$pageConId = $_POST['id'];
		$this->load->model('Admin_model');
		$data = $this->Admin_model->deletePageContentById($pageConId);
		echo '1';
	}

	public function pagesContent()
	{
		$this->load->model('Admin_model');
		$loginId 				= 	$this->session->userdata('LoginUserid');
		$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
		if (empty($alldata['userdata1']))
		{ 
			redirect('');
		} 
		$pageid = $this->uri->segment(3);
		
			$alldata['pageByid'] = $this->Admin_model->getPageById($pageid); 
		
		//$pagename1 = $this->input->post('addOrgName');
		if (!empty($_POST)){
			$pagename 	= 	$_POST['addOrgName'];
			$page 		= 	strtolower($pagename);
			
			if (empty($_POST['addChoice']))
			{
				$pagetype = '';
			}
			else 
			{
				$pagetype 	= 	$_POST['addChoice'];
			}
			if (empty($_POST['questiontype']))
			{
				$selecttype = '';
			}else{
			$selecttype = 	$_POST['questiontype'];}
			$Pid	  	= 	$_POST['Pid'];	
			$status   	= 	'1';
			$date 	  	= 	date('Y-m-d H:i:s');
			$inserdata 	= 	array(
				'db_pageConTitle' 	=> 	$pagename,
				'db_pageChoice' 	=> 	$pagetype,
				'db_pageid'			=>	$Pid,
				'db_pageselection'	=>	$selecttype,
				'db_pageConAddedBy' => 	$loginId,
				'status' 			=> 	$status,
				'created_date' 		=> 	$date
			);	
			$alldata['message'] = $this->Admin_model->insertPageContent($inserdata,$page);
			
		}
		$this->load->view('beatleAdmin/pagesContent' , $alldata);
	}
 
	
		public function pagesContentList($pageid)
		{
			$this->load->model('Admin_model');
			$loginId 				= 	$this->session->userdata('LoginUserid');
			$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
			if (empty($alldata['userdata1']))
			{ 
				redirect('');
			} 
			$pageid = $this->uri->segment(3);
			$conid = $this->uri->segment(4);
			if (!empty($conid))
			{
				$alldata['pagesContent'] = $this->Admin_model->pagesContentListById($conid); 
				//rint_r($alldata['pageByid']);die;
			}
			else 
			{
				$alldata['pagesContent'] = $this->Admin_model->pagesContentList($pageid); 
			}
			$alldata['pageid'] = $pageid;
			if (!empty($_POST))
			{
				$pagename = $this->input->post('addOrgName');
				$pagetype = $this->input->post('addChoiceh');
				$selecttype = $this->input->post('questiontype');
		 
				if ($selecttype == 'multiline' || $selecttype == 'single_line')
				{
					$addChoicehide = '';
				}
				else 
				{//die('asdfasd');
					$addChoicehide = $this->input->post('addChoice');
				}
				 
				$Pid	  = $this->input->post('InId');	
				$status   = '1';
				$date 	  = date('Y-m-d H:i:s');
				$inserdata = array(
					'db_pageConTitle' 	=> 	$pagename,
					'db_pageselection'	=>	$selecttype,
					'db_pageChoice' 	=> 	$addChoicehide,
					'db_pageid'			=>	$Pid,
					'db_pageConAddedBy' => 	$loginId,
					'status' 			=> 	$status,
					'updated_date' 		=> 	$date
				);	
				//print_r($inserdata);die;
				$alldata['success'] = $this->Admin_model->updatePageContent($inserdata,$conid);
				redirect('index.php/beatleAdmin/relatedcontent/'.$Pid.'');
			}
 			$this->load->view('beatleAdmin/pagesContentList' , $alldata);
		}
		
		public function relatedcontent()
		{
			$this->load->model('Admin_model');
			$loginId 				= 	$this->session->userdata('LoginUserid');
			$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
			if (empty($alldata['userdata1']))
			{ 
				redirect('');
			} 
			$pageid = $this->uri->segment(3);
			$alldata['pagesContent'] = $this->Admin_model->pagesContentList($pageid); 
			
			
			$this->load->view('beatleAdmin/relatedcontent' , $alldata);
		}
		
		
		public function survey()
		{
			$this->load->model('Admin_model');
			$loginId 				= 	$this->session->userdata('LoginUserid');
			$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
			if (empty($alldata['userdata1']))
			{ 
				redirect('');
			} 
			$sId = $this->uri->segment(3);
			$alldata['SurveyById']	=	$this->Admin_model->getSurveyById($sId);
			if (isset($_POST['addOrgsubmit']))
			{
				$pagename = $this->input->post('addOrgName');
				//$Pid	  = $this->input->post('Pid');	
				$status   = '1';
				$date 	  = date('Y-m-d H:i:s');
				$inserdata = array(
					'db_surveyname' 	=> 	$pagename,
					'db_addedBy' 		=> 	$loginId,
					'status' 			=> 	$status,
					'created_date' 		=> 	$date
				);	
				$alldata['message'] = $this->Admin_model->insertsurvey($inserdata);
 			}
			
		if (isset($_POST['editOrgsubmit']))
			{
				$pagename = $this->input->post('addOrgName');
				//$Pid	  = $this->input->post('Pid');	
				$status   = '1';
				$date 	  = date('Y-m-d H:i:s');
				$inserdata = array(
					'db_surveyname' 	=> 	$pagename,
					'db_addedBy' 		=> 	$loginId,
					'status' 			=> 	$status,
					'updated_date' 		=> 	$date
				);	
				$alldata['message'] = $this->Admin_model->updatesurvey($inserdata,$sId);
				if (!empty($alldata['message']))
				{
					redirect('beatleAdmin/surveyList');
				}
 			}
			
			$this->load->view('beatleAdmin/survey' , $alldata);
		}
		public function surveyList()
		{
			$this->load->model('Admin_model');
			$loginId 				= 	$this->session->userdata('LoginUserid');
			$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
			if (empty($alldata['userdata1']))
			{ 
				redirect('');
			} 
			$alldata['allsurvey']	=	$this->Admin_model->getallsurvey();
			$alldata['allpage']		=	$this->Admin_model->getallpage();
			
			$this->load->view('beatleAdmin/surveyList' , $alldata);
		}
		public function deleteSurveyById()
		{
			$this->load->model('Admin_model');
			$sId = $_POST['id']; 
			$data = $this->Admin_model->deleteSurveyById($sId);
			echo '1';
		}
		
		public function addpagesToIndustry()
		{
			$this->load->model('Admin_model');
			$allval    = implode(',',$_POST['dashboard']);
			$mainIndId = $_POST['indusId'];
			$insertdata = array(
				'db_pagesId' => $allval
			);
			$data = $this->Admin_model->addpagesToIndustry($mainIndId,$insertdata);
			$url = $_SERVER['HTTP_REFERER'];
			redirect ($url);
		}
		
		
		public function feedback()
		{
			$this->load->model('Admin_model');
			$loginId 				= 	$this->session->userdata('LoginUserid');
			$alldata['userdata1'] 	= 	$this->Admin_model->getuserdata($loginId);
			if (empty($alldata['userdata1']))
			{ 
				redirect('');
			} 
			$alldata['allUser']		=	$this->Admin_model->getAllUser('Y');
			
			//echo "<pre>";
			//print_r($alldata['allUser']);
		//	die;
			
			$this->load->view('beatleAdmin/feedback' , $alldata);
		}
		
}