<?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 Branch
 *
 * @author user
 */
require APPPATH . '/libraries/REST_Controller.php';

class Branch extends REST_Controller {

    function __construct() {
        parent::__construct();
        $this->load->database();
        $this->load->model('Branch_modal');
        $this->load->model('Token_modal');
    }
    
    public function getbarnchlistbybank_post() {
        $headers = $this->input->request_headers();
        $valid = $this->Token_modal->exit_token($headers['Token']);
        if ($valid != null) {
            header('Content-type: application/json');
            $object = json_decode(file_get_contents('php://input'), true);
            $data = $object['GetBranchListByAreaRequest']['Bank'];
            $barnch = $this->Branch_modal->get_branch_list_by_bank($data);
            $barnch_list = array("Branch" => $barnch);
            $message = array("Status" => "200",
                "BranchList" => $barnch_list);
            $response_message = array("GetBranchListByAreaResponse" => $message);
            $this->response($response_message);
        } else {
            $message = array("Status" => "1002",
                "Message" => "Invalid token");
            $response_message = array("GetBranchListByAreaResponse" => $message);
            $this->response($response_message);
        }
    }
}