<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

/**
 *
 *
 * @author Lalendra
 */
class Report_Controller extends MY_Controller {

    function __construct() {
        parent::__construct();
        $this->load->model('Report_model');
        $sess_array = $this->session->userdata('uDetails');
        if ($sess_array['type'] != "admin") {
            redirect(base_url() . "Welcome/dashboardRedirect");
        }
    }

    public function Report1() {
        $this->load->view("template/header");
        $this->load->view("template/navigation");
        $this->load->view("admin/report_1");
        $this->load->view("template/footer");
    }

    public function loadReport1() {
        $empid = $this->input->get('empid');
        $data['empData'] = $this->Report_model->getEmpDetail($empid);
        if (!count($data['empData'])) {
            echo json_encode(0);
            return FALSE;
        }
        $data['empTask'] = $this->Report_model->getEmpTaskList($empid);
//        $data['supExpec'] = $this->Report_model->getSupExpec($empid);
        echo json_encode($data);
    }

    public function activityReportLoad() {
        $activityArr = $this->input->get('activityArr');
        $sup = $this->input->get('sup');
        $dep = $this->input->get('dep');
        $data['array1'] = $this->Report_model->distributionEmpVsHours($activityArr, $sup, $dep);
        $data['array2'] = $this->Report_model->distributionEmpCountVsHours($activityArr, $sup, $dep);
        $data['array3'] = $this->Report_model->activityReportStatisfaction($activityArr, $sup, $dep);
        echo json_encode($data);
    }

    public function activityReporEmpList() {
        $activityArr = $this->input->get('activityArr');
        $sup = $this->input->get('sup');
        $dep = $this->input->get('dep');
        $hour = $this->input->get('hour');
        $data['array'] = $this->Report_model->activityReporEmpList($activityArr, $sup, $dep, $hour);
        echo json_encode($data);
    }

    public function ActivityReport() {
        $this->load->model('Activity_model');
        $data['department'] = $this->Activity_model->getDepartmentList();
        $data['supList'] = $this->Activity_model->getAllActiveSupervisor();
        $this->load->view("template/header");
        $this->load->view("template/navigation");
        $this->load->view("admin/activity_report", $data);
        $this->load->view("template/footer");
    }

    public function organizationReport() {
        $this->load->model('Activity_model');
        $data['department'] = $this->Report_model->departmentVsEmp();
        $data['supervisor'] = $this->Report_model->departmentVsSup();
        $this->load->view("template/header");
        $this->load->view("template/navigation");
        $this->load->view("admin/organization_report", $data);
        $this->load->view("template/footer");
    }

    public function organizationReportEmpList() {
        $dep = $this->input->get('dep');
        $data['empList'] = $this->Report_model->organizationReportEmpList($dep);
        $data['activityList'] = $this->Report_model->departmentActList($dep);
        echo json_encode($data);
    }
}
