<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
defined('BASEPATH') OR exit('No direct script access allowed');

// This can be removed if you use __autoload() in config.php OR use Modular Extensions
/** @noinspection PhpIncludeInspection */
require APPPATH . '/libraries/REST_Controller.php';

// use namespace

use Restserver\Libraries\REST_Controller;

/**
 * Description of Admin_car
 *
 * @author zmq163
 */
class Temp extends REST_Controller {

    //put your code here
    public function __construct($config = 'rest') {
        parent::__construct($config);
        $this->load->model('Temp_model', 't_model');
    }

    /**
     * 
     * 
     * 
     * 
     * 
     */
    public function preQuestion_post() {
        $postData = array();
        $getPostData = $this->getData();
        $postData['preQuestionId'] = $getPostData['preQuestionId'];
        $postData['userId'] = $getPostData['userId'];
        $postData['sessionId'] = $getPostData['sessionId'];
        $postData['questionNo'] = $getPostData['questionNo'];
        $postData['selectedAnswer'] = $getPostData['selectedAnswer'];
        $postData['dateAndTime'] = date('Y-m-d H:i:s', strtotime($getPostData['dateAndTime']));
        $this->set_response($this->t_model->preQuestionTempModel($postData), REST_Controller::HTTP_OK);
    }

    /**
     * 
     * 
     * 
     * 
     * 
     */
    public function recapQuestion_post() {
        $postData = array();
        $getPostData = $this->getData();
        $postData['recapId'] = $getPostData['recapId'];
        $postData['userId'] = $getPostData['userId'];
        $postData['sessionId'] = $getPostData['sessionId'];
        $postData['moduleId'] = $getPostData['moduleId'];

        $postData['questionNo'] = $getPostData['questionNo'];
        $postData['rating'] = $getPostData['rating'];
        $postData['feedback'] = $getPostData['feedback'];



        $postData['selectedAnswer'] = $getPostData['selectedAnswer'];
        $postData['dateAndTime'] = date('Y-m-d H:i:s', strtotime($getPostData['dateAndTime']));
        $this->set_response($this->t_model->recapQuestionTempModel($postData), REST_Controller::HTTP_OK);
    }

/**
     * 
     * 
     * 
     * 
     * 
     */

    public function userRegistrationTemp_post() {
        $postData = array();
        $getPostData = $this->getData();

        $postData['district'] = $getPostData['district'];
        $postData['block'] = $getPostData['block'];
        $postData['centerNo'] = $getPostData['centerNo'];
        $postData['village'] = $getPostData['village'];
        
        
        $postData['userId'] = $getPostData['userId'];
        $postData['userType'] = $getPostData['userType'];
        $postData['userName'] = $getPostData['userName'];
        $postData['userLoginId'] = $getPostData['userLoginId'];
        $postData['userPassword'] = $getPostData['userPassword'];
        $postData['userGender'] = $getPostData['userGender'];
        $postData['registerDateAndTime'] = date('Y-m-d h:i:sa', strtotime($getPostData['registerDateAndTime']));
        $postData['mobileUserId'] = $getPostData['userId'];
        $this->set_response($this->t_model->userRegistrationTempModel($postData), REST_Controller::HTTP_OK);
    }

    /**
     * 
     * 
     * 
     * 
     */
    public function endUserRegistration_post() {
        $postData = array();
        $getPostData = $this->getData();
        
        $postData['singleModeId'] = $getPostData['singleModeId'];
        $postData['userId'] = $getPostData['userId'];
        $postData['sessionId'] = $getPostData['sessionId'];
        $postData['singleUserName'] = $getPostData['singleUserName'];
        $postData['singleModeGender'] = $getPostData['singleModeGender'];
        $postData['mobileSingleModeId'] = $getPostData['singleModeId'];
        $postData['audienceType'] = $getPostData['audienceType'];
        $postData['singleModeDateAndTime'] = date('Y-m-d h:i:sa', strtotime($getPostData['singleModeDateAndTime']));
        $this->set_response($this->t_model->endUserRegistrationModel($postData), REST_Controller::HTTP_OK);
    }

    /**
     * 
     * 
     * 
     * 
     */
    public function endUserGroupRegistration_post() {
        $postData = array();
        $getPostData = $this->getData();
        
        $postData['groupModeId'] = $getPostData['groupModeId'];
        $postData['mobileGroupId'] = $getPostData['groupModeId'];
        $postData['userId'] = $getPostData['userId'];
        $postData['sessionId'] = $getPostData['sessionId'];
        $postData['groupModeName'] = $getPostData['groupModeName'];
        $postData['noOfMale'] = $getPostData['noOfMale'];
        $postData['noOfFemale'] = $getPostData['noOfFemale'];
        $postData['noOfGirl'] = $getPostData['noOfGirl'];
        $postData['noOfBoy'] = $getPostData['noOfBoy'];
        $postData['audienceType'] = $getPostData['audienceType'];
        $postData['groupModeDateAndTime'] = date('Y-m-d h:i:sa', strtotime($getPostData['groupModeDateAndTime']));
        $this->set_response($this->t_model->endUserGroupRegistrationModel($postData), REST_Controller::HTTP_OK);
    }

    /**
     * 
     * 
     * 
     * 
     */
    public function sessionPlayData_post() {
        $postData = array();
        $getPostData = $this->getData();

        $postData['moduleId'] = $getPostData['moduleId'];
        //$postData['mobileModuleId'] = $getPostData['mobileModuleId'];
        $postData['sessionName'] = $getPostData['sessionName'];
        $postData['userId'] = $getPostData['userId'];
        $postData['sessionId'] = $getPostData['sessionId'];
        $postData['moduleNo'] = $getPostData['moduleNo'];
        $postData['subModuleNo'] = $getPostData['subModuleNo'];
        $postData['status'] = $getPostData['status'];
        
        
        $postData['storyStartTime'] = date('H:i:sa', (int)$getPostData['storyStartTime']);
        $postData['storyEndTime'] = date('H:i:sa', (int)$getPostData['storyEndTime']);
        
        $postData['storyViewDate'] = date('Y-m-d', strtotime($getPostData['storyViewDate']));
        $this->set_response($this->t_model->sessionPlayDataModel($postData), REST_Controller::HTTP_OK);
    }

    /**
     * 
     * 
     * 
     * 
     * 
     */
    public function endUserImageUploadTemp_post() {
        $getPostData['userType'] = $this->input->post('userType');
        $getPostData['id'] = $this->input->post('id');
        

        $this->set_response($this->t_model->endUserImageUploadTempModel($getPostData), REST_Controller::HTTP_OK);
    }

    /**
     * 
     * 
     * 
     * 
     * 
     */
    public function endUserGroupImageUploadTemp_post() {
        
    }

    /**
     * 
     * 
     * 
     * 
     * 
     */
    public function insertData_post() {

        $this->t_model->insertDataModel();
        $this->set_response(array('status' => TRUE, 'message' => 'user data get success.'), REST_Controller::HTTP_OK);
    }

    /**
     * 
     * 
     * 
     */
    private function getData() {
        return json_decode(file_get_contents('php://input'), TRUE);
    }

}
