<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Dashboard extends CI_Controller {

    
    public function __construct()
    {
        parent::__construct();
        $this->load->model('User_model');
        $this->User_model->check_plogin();

    }



	public function index()
	{			
		$data['title'] = "Dashboard";	
		$data['userInfo'] =  $this->User_model->userInfo("first_name,last_name");
		$student_id = $this->User_model->userInfo()['student_id'];
		
		$father_cnic = $this->db->select('father_cnic')->from('student')->where('id', $student_id)->where('status', '0')->get()->result();
		$father_cnic = $father_cnic[0]->father_cnic;

		
		$get_all_student = $this->db->select('id')->from('student')->where('father_cnic', $father_cnic )->where('status', '0')->get()->result_array();


		$data['main'] = "portalview/dashboard/index";
	 	$this->load->view('portalview/includes/main', $data);
	}



	// public function insert_student()
	// {

	// 	$result = $this->db->select('id, grno, student_name,father_name')->from('student')->where('status', '0')->get()->result_array();

	// 		 foreach ($result as $value) {

	// 			$data = array(
	// 			   'student_id' => $value['id'] ,
	// 			   'username' => $value['grno'],
	// 			   'first_name' => $value['student_name'],
	// 			   'password' => md5('softvilla')
	// 			);

	// 			$this->db->insert('admin', $data);

	// 		}
			
		
	// }



	// public function insert_parent()
	// {

	// 	$result = $this->db->select('id, grno, student_name,father_name')->from('student')->where('status', '0')->get()->result_array();

	// 		 foreach ($result as $value) {
	
	// 			$data = array(
	// 			   'student_id' => $value['id'] ,
	// 			   'username' => $value['grno'].'_parent',
	// 			   'first_name' => $value['father_name'],
	// 			    'password' => md5('softvilla')
	// 			);

	// 			$this->db->insert('admin', $data);

	// 		}
			
		
	// }


	// 	public function insert_id_morning()
// 	{
// 		$query =  $this->db->query("SELECT * FROM `student` WHERE `branch` = 1")->result_array();
// 		$query=array_column($query,'id');

// 				$data = array(
// 				   'role_id' => 15 
// 				);
// 				$this->db->where('student_id !=', 0);
// 				$this->db->where_in('student_id', $query);
// 				$this->db->update('admin', $data);
// 	}



// public function insert_id_evening()
// 	{
// 		$query =  $this->db->query("SELECT * FROM `student` WHERE `branch` = 2")->result_array();
// 		$query=array_column($query,'id');

// 				$data = array(
// 				   'role_id' => 16
// 				);
// 				$this->db->where('student_id !=', 0);
// 				$this->db->where_in('student_id', $query);
// 				$this->db->update('admin', $data);
// 	}





}
	