<?php

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

class Welcome extends CI_Controller {

    /**
     * Index Page for this controller.
     *
     * Maps to the following URL
     * 		http://example.com/index.php/welcome
     * 	- or -  
     * 		http://example.com/index.php/welcome/index
     * 	- or -
     * Since this controller is set as the default controller in 
     * config/routes.php, it's displayed at http://example.com/
     *
     * So any other public methods not prefixed with an underscore will
     * map to /index.php/welcome/<method_name>
     * @see http://codeigniter.com/user_guide/general/urls.html
     */
    public function __construct() {
        parent::__construct();
        $sec_res = session_id();
        $this->load->helper(array('url', 'form', 'date'));
        $this->load->library('form_validation');
        $this->load->library('session');
        $this->load->database();
        $this->load->library('session');
        $this->load->model('candidate_profile');
    }

    public function index() {
        $data['solution'] = $this->candidate_profile->solution();
        $data['job_details'] = $this->candidate_profile->job_details();
        $this->load->view('index', $data);
    }
  public function test() {
        $data['solution'] = $this->candidate_profile->solution();
        $data['job_details'] = $this->candidate_profile->job_details();
        $this->load->view('index2', $data);
    }
    function post_details() {
        //echo '<pre>';print_r($_POST);exit;
        //echo 'name: '. $img_name=$_POST['image1'];   exit;   
        $job_code = $_POST['job_code'];
        $fname = $_POST['fname'];
        $mobile = $_POST['mobile'];
        $lname = $_POST['lname'];
        $dob = $_POST['dob'];
        $email = $_POST['email'];
        $industry = $_POST['industry'];
        $current_location = $_POST['current_location'];
        //$resume1 = $_POST['userfile'];      

        $class10_p = $_POST['class10_p'];
        $school_year = $_POST['school_year'];
        $school = $_POST['school_name'];
        $school_city = $_POST['school_city'];
        $class12_p = $_POST['class12_p'];
        $college_year = $_POST['college_year'];
        $college_name = $_POST['college_name'];
        $college_city = $_POST['college_city'];
        $graduation_p = $_POST['graduation_p'];
        $graduation_year = $_POST['graduation_year'];
        $univercity_name = $_POST['univercity_name'];
        $univercity_city = $_POST['univercity_city'];
        $employer_name = $_POST['employer_name'];
        $roles_responsibilitie = $_POST['roles_responsibilitie'];
        $duration_from = $_POST['duration_from'];
        // $duration_to=$_POST['duration_to'];
        $total_exp_year = $_POST['total_exp_year'];
        $total_exp_month = $_POST['total_exp_month'];
        $course_name = $_POST['course_name'];
        $modeofdelivery = $_POST['modeofdelivery'];
        $course_name1 = $_POST['course_name1'];
        $training_center_name = $_POST['training_center_name'];
        $course_name2 = $_POST['course_name2'];
        $center_location = $_POST['center_location'];
        $course_name3 = $_POST['course_name3'];
        //        Resume_upload function with raw name 
        $thumbimage = date(CdymqHis);
        $config['file_name'] = $thumbimage;
        $config['upload_path'] = 'public/resumes';
        $config['allowed_types'] = 'doc|pdf|docx|png|jpg|gig';
        // $config['allowed_types'] = 'png|jpg|gif';
        $config['max_size'] = '2048';
        //  $config['max_width'] = '1024';
        // $config['max_height'] = '768';

        $this->load->library('upload', $config);

        if (!$this->upload->do_upload('doc')) {
            $error = array('error' => $this->upload->display_errors());
        } else {
             $data = array('upload_data' => $this->upload->data());
            $resume_name = $data['upload_data']['raw_name'] . '' . $data['upload_data']['file_ext'];
        }
        //       Image_upload function with raw name 


        if (!$this->upload->do_upload('image1')) {
            $error = array('error' => $this->upload->display_errors());
            echo 'img: <br>' . $this->upload->display_errors();
            echo $data['upload_data']['file_ext'];
            exit;
            $profile_img_name = 'NULL';
        } else {
            $data = array('upload_data' => $this->upload->data());
            //echo "<p>File sucesfully uploaded</p>";
//            echo '<pre>';
//                        print_r($data);

            $profile_img_name = $data['upload_data']['raw_name'] . '' . $data['upload_data']['file_ext'];
        }
        $this->candidate_profile->post_details($job_code, $fname, $mobile, $lname, $dob, $email, $industry, $current_location, $resume_name, $class10_p, $school_year, $school, $school_city, $class12_p, $college_year, $college_name, $college_city, $graduation_p, $graduation_year, $univercity_name, $univercity_city, $employer_name, $roles_responsibilitie, $duration_from, $total_exp_year, $total_exp_month, $course_name, $modeofdelivery, $course_name1, $training_center_name, $course_name2, $center_location, $course_name3, $profile_img_name);
//        $this->index();
        // $ms='Thank you! Your Details Posted Successfully For Job Code :'.$job_code;
        //echo $ms;exit;
        $this->session->set_flashdata('message', 'Thank you! Your Details Have Been Posted Successfully For The Job Code :' . $job_code);
        redirect('welcome/index', 'refresh');
    }

    function getcenter($mode) {
        //echo $mode;exit;
        $center = $this->candidate_profile->get_center($mode);
        // echo'<pre>';print_r($center);exit;
        echo ' <select name="center_name" class="" id="get_center" >';
        echo '<option value="">--Select Center--</option>';
        for ($i = 0; $i < count($center); $i++) {
            echo '<option value="' . $center[$i]->Center_Name . '"  >' . $center[$i]->Center_Name . '</option>';
        }
        echo '</select>';
    }

    function getcenter_location($center_name, $mode) {
        //echo $center_name,$mode;exit;
        $center_location = $this->candidate_profile->get_center_location(urldecode($center_name), $mode);
        // echo'<pre>';print_r($center_location);exit;
        echo ' <select name="center_location" class="" id="get_center_location" >';
        echo '<option value="">--Select Location--</option>';
        for ($i = 0; $i < count($center_location); $i++) {
            echo '<option value="' . $center_location[$i]->City . '"  >' . $center_location[$i]->City . '</option>';
        }
        echo '</select>';
    }

    function getsolution_short_text($solution) {
        //echo $solution;exit;
        $solutiontext = $this->candidate_profile->getsolution_short_text(urldecode($solution));
        echo ' <select name="solution_shorttext" class="" id="solution_shorttext" >';
        echo '<option value="">Select Solution Short Text</option>';
        for ($i = 0; $i < count($solutiontext); $i++) {
            echo '<option value="' . $solutiontext[$i]->solution_short_text . '"  >' . $solutiontext[$i]->solution_short_text . '</option>';
        }
        echo '</select>';
    }

    function getsolution_long_text($solution_short_text, $solution) {
        // echo $solution_short_text,$solution;exit;
        $solution_longtext = $this->candidate_profile->getsolution_long_text(urldecode($solution), urldecode($solution_short_text));
        echo ' <select name="solution_longtext" class="" id="solution_longtext" >';
        echo '<option value="">Select Solution Long Text</option>';
        for ($i = 0; $i < count($solution_longtext); $i++) {
            echo '<option value="' . $solution_longtext[$i]->id . '"  >' . $solution_longtext[$i]->solution_long_text . '</option>';
        }
        echo '</select>';
    }

    function getproduct_name($solution_longtext) {

        $solution_productname = $this->candidate_profile->getsolution_product_name(urldecode($solution_longtext));
        echo ' <select name="solution_productname" class="" id="solution_productname" >';
        for ($i = 0; $i < count($solution_productname); $i++) {
            echo '<option value="' . $solution_productname[$i]->product_name . '"  >' . $solution_productname[$i]->product_name . '</option>';
        }
        echo '</select>';
    }

    function termsandcondition($id) {
        $data['id'] = $id;
        $this->load->view('trems&condition', $data);
    }

    function curriculam($job_id) {
        $data['job_id'] = $job_id;
        $data['file'] = $this->candidate_profile->get_file_name($job_id);
        $data['curriculams'] = $this->candidate_profile->get_curriculan($job_id);
        $this->load->view('curiculam', $data);
    }

}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */