<?php
defined('BASEPATH') or exit('Direct access is not allowed');
require_once ROOT . '/trainingportal/app/models/Automotive/AutomotiveModel.php';//trainingportal
require_once LIBS_ROUTE .'Session.php';

/**
 * Automotive controller
 */
class AutomotiveController extends Controller
{
  /**
   * string 
   */
  public $nombre;
  private $session;
  /**
   * object 
   */
  public $model;

  /**
   * Inicializa valores 
   */
  public function __construct()
  {
    $this->model = new AutomotiveModel();
    $this->session = new Session();
  }

  /**
  * Método estándar
  */
  public function exec()
  {
    $this->show();
    
  }

  /**
  * Método de ejemplo
  */
  public function show()
  {
    //$params = array('nombre' => $this->nombre);
    $this->session->init();
    $res = $this->model->get_automotive_course_data(); 
    $params = array('course_details_data' => $res,'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_automotive($param); 
    echo json_encode($res);
  }

  public function apply_training_automotive($param)
  { $userId=$this->session->get('user_id');
    $user_name=$this->session->get('user_name');
    $res = $this->model->applytraining_automotive($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');
  }
}