<?php
defined('BASEPATH') or exit('Direct access is not allowed');
require_once ROOT . '/trainingportal/app/models/Pne/PneModel.php';//trainingportal
require_once LIBS_ROUTE .'Session.php';
/**
 * Pne controller
 */
class PneController extends Controller
{  private $session;
  /**
   * string 
   */
  public $nombre;

  /**
   * object 
   */
  public $model;

  /**
   * Inicializa valores 
   */
  public function __construct()
  {
    $this->model = new PneModel();
    $this->nombre = 'Guru';
    $this->session = new Session();
    // $this->session->init();
    // if($this->session->getStatus() === 1 || empty($this->session->get('email')))
    //   exit('Access denie session in pne controller');
   }
  /**
  * Método estándar
  */
  public function exec()
  {
    $this->show();
  }

  /**
  * Método de ejemplo
  */
  public function show()
  { $this->session->init();
    $res = $this->model->get_pne_course_data(); 
    $params = array('course_details_data' => $res,'nombre' => $this->nombre,'email' => $this->session->get('email'),'user_name' => $this->session->get('user_name'),'role_id' => $this->session->get('role_id'),'emp_code' => $this->session->get('emp_code'),'segment_name' => $this->session->get('segment_name'),'rating' => $this->session->get('rating'),'designation' => $this->session->get('designation'),'enroll_courses' => $this->session->get('enroll_courses'),'profile_image_path' => $this->session->get('profile_image_path'));
    $this->render(__CLASS__,$params); 
  }



  public function get_module_data_by_trainingid_moduleid_segmentid($param)
  {
    $res = $this->model->get_module_data($param); 
    echo json_encode($res);
  }

  public function apply_training_pne($param)
  { $userId=$this->session->get('user_id');
    $user_name=$this->session->get('user_name');
    $res = $this->model->apply_training($param,$userId,$user_name); 
    echo json_encode($res);
  }


  /**
  * Método de ejemplo con model. Obtiene un usuario segun ID
  */
  public function usuario($param)
  {
    $res = $this->model->getUser($param);
    $this->nombre = $res['usuario_dev'];
    $this->show();
  }

  public function herfpage(){
    $this->render("MainController",$params); 
    //echo "MeThod";
  }
  public function logout()
  {
    $this->session->close();
    header('location: /trainingportal/Home');
  }
}