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

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

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

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

  /**
  * Método de ejemplo
  */
  public function show()
  {
    $this->session->init();
    $selected_segment_id=$this->session->get('selected_segment');
    $res = $this->model->get_segment_list();
    $training_list = $this->model->get_training_list($selected_segment_id);
    $module_list = $this->model->get_module_list($selected_segment_id);
    $training_details_data = $this->model->get_training_details_all_data($selected_segment_id);
    $module_data = $this->model->get_module_all_data($selected_segment_id);
    $targets_data = $this->model->get_targets_all_data($selected_segment_id);
    $trainees_data = $this->model->get_trainees_all_data($selected_segment_id);
    $training_content = $this->model->get_training_content_all_data($selected_segment_id);
    $user_list = $this->model->get_user_list();
    $trainees_list = $this->model->get_trainees_list($selected_segment_id);
    $params = array('trainees_list' => $trainees_list,'user_list' => $user_list,'training_content' => $training_content,'module_list' => $module_list,'trainees_data' => $trainees_data,'targets_data' => $targets_data,'module_data' => $module_data,'training_list' => $training_list,'segment_list' => $res,'training_data' => $training_details_data,'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); 
  }

  /**
  * 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 save_training_details_data($param){
    $userId=$this->session->get('user_id');
    $res = $this->model->save_training_details($param,$userId);
    echo $res;
  }

  public function save_module_data($param){
    $userId=$this->session->get('user_id');
    $res = $this->model->save_module($param,$userId);
    echo $res;
  }

  public function save_target_data($param){
    $userId=$this->session->get('user_id');
    $res = $this->model->save_target($param,$userId);
    echo $res;
  }
  
  public function save_trainees_data($param){
    $userId=$this->session->get('user_id');
    $res = $this->model->save_trainees($param,$userId);
    echo $res;
  }

  public function save_training_content_data($param){
    $userId=$this->session->get('user_id');
    $res = $this->model->save_training_content($param,$userId);
    echo $res;
  }
  public function set_segmentid_for_dropdown($param){
    $this->session->init();
    $this->session->add('segmentid_for_dropdown',$param["selected_segment_dropdown"]);
  }
}