<?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.
 */

/**
 * Description of tikatoy
 *
 * @author zmq163
 */
class Tikatoy extends CI_Controller{
    //put your code here
    var $tikaToyModelObject;
    public function __construct() {
        parent::__construct();
        $this->load->model('tikatoy_model');
        $this->tikaToyModelObject=new Tikatoy_model();
        
    }
    /**
     * 
     * 
     * 
     * 
     * 
     */
    public function userAuthenticationKey(){
        $userId_password=  $this->getPostData();
        $userLoginDetail=$this->tikaToyModelObject->getRegionIdUserIdPassword($userId_password['userId'],$userId_password['password']);
        if($userLoginDetail){
            print_r(json_encode(array('status'=>TRUE,'message'=>'Success','data'=>array('childList'=>  $this->tikaToyModelObject->getChildImmunizationListModel($userLoginDetail[0]['create_region_id']),'pregnantList'=>  $this->tikaToyModelObject->getPregnantWomenListModel($userLoginDetail[0]['create_region_id'])))));
        }  else {
            print_r(json_encode(array('status'=>FALSE,'message'=>'User authentication fail.')));
        }
    }
    /**
     * 
     * 
     * 
     * 
     */
    public function postChildImmunizationData(){
        
    }
    /**
     * 
     * 
     * 
     * 
     */
    public function postPregnantDataHrp(){
        $postData=array('pregnantId'=>1,'weekId'=>23,'qus_anws'=>array(
            array('q_id'=>1,'ans'=>1),
            array('q_id'=>2,'ans'=>0),
            array('q_id'=>3,'ans'=>0),
            array('q_id'=>4,'ans'=>1),
            array('q_id'=>5,'ans'=>1)
            ));
            print_r(json_encode($postData));
    }

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