<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');
/* 	
 * 	Author 	: Herpan \ 30-09-2014	
 * 	Revisi 	: Ferry \ 07-01-2015
 * 	Revisi 	: Fachri \ 27-08-2015
 */

class Bank extends CI_Controller {

    public $menu_id = 253;
    public $menu_model = array('m_bank', 'm_coa','login/m_login');
    public $code = "Bank Code";
    public $name = "Bank Name";

    public function __construct() {
        parent::__construct();

        $this->load->model($this->menu_model);
        $this->load->helper('regex');
        $this->load->helper('message');
        $this->load->helper('status');
        $this->load->helper('custom_string_helper');
		
		$is_login = $this->m_login->get_session_id($this->session->userdata('session_id'),$this->session->userdata('username'));
        if($is_login){

        }else{
            $username       = $this->session->userdata('username');
            $session_id     = $this->session->userdata('session_id');
            $this->m_login->delete_session($username,$session_id);
            $this->session->sess_destroy();

            $uri_func = $this->uri->segment(3);
            if(($uri_func === FALSE) || ($uri_func =='add') || ($uri_func =='edit')){
                redirect(base_url() . 'login', 'refresh');
            }else if(in_array($uri_func,array('approve_data','approved_mgr','approved_dir','approve','approve_transsaction','reverse_data','reversed_data','reverse_transsaction','save','save_data','insert','update','update_data','suspend','suspend_data','suspend_transsaction','suspend_mgr','suspend_dir'))){
                $result['status']   = 'session';
                $result['message']  = get_notification('session_destroy',0);
                echo json_encode($result);
                die();
            }
        }
    }

    public function index() {
        if ($this->session->userdata("login") == TRUE) {
            $group_menu = $this->session->userdata('group_menu');
            $arr_group_id = $this->m_menu->get_menu_by_group($group_menu, $this->menu_id);
            if (!empty($arr_group_id)) {
                $data['available_menu'] = array_unique($arr_group_id);
                if (!in_array($this->menu_id, $data['available_menu'])) {
                    redirect(base_url() . 'error', 'refresh');
                } else {
                    $group_menu = $this->session->userdata('group_menu');

                    $data['menu_link'] = $this->m_menu->get_menulink($this->menu_id);
                    $data['menu_label'] = $this->m_menu->get_menulabel($this->menu_id);

                    //panggil model hak akses untuk autoriti
                    $data['group_user'] = $this->m_menu->group_user_autority($this->menu_id, $group_menu);

                    $this->load->view('v_header');
                    $this->load->view('bank/v_bank', $data);
                    $this->load->view('v_footer');
                }
            } else {
                redirect(base_url() . 'error', 'refresh');
            }
        } else {
            redirect(base_url() . 'login', 'refresh');
        }
    }

    public function add() {
        if ($this->session->userdata("login") == TRUE) {
            $group_menu = $this->session->userdata('group_menu');
            /*
              untuk di index/list = get_menu_by_group,
              untuk di add = get_menu_by_group_add
              untuk di edit = get_menu_by_group_edit
             */
            $arr_group_id = $this->m_menu->get_menu_by_group_add($group_menu, $this->menu_id);
            //--------------------------end-----------------------------------------------------------
            if (!empty($arr_group_id)) {
                $data['available_menu'] = array_unique($arr_group_id);
                if (!in_array($this->menu_id, $data['available_menu'])) {
                    redirect(base_url() . 'error', 'refresh');
                } else {
                    /*
                      modul untuk akses add masing masing modul berebda
                      jangan lupa copy $data nya (jika dia bener langsung ke add)
                     */
                    $data['branch_code'] = "";
                    $group_menu = $this->session->userdata('group_menu');

                    $data['menu_link'] = $this->m_menu->get_menulink($this->menu_id);
                    $data['menu_label'] = $this->m_menu->get_menulabel($this->menu_id);

                    //panggil model hak akses untuk autoriti
                    $data['group_user'] = $this->m_menu->group_user_autority($this->menu_id, $group_menu);

                    $this->load->view('v_header');
                    $this->load->view('bank/v_add_bank', $data);
                    $this->load->view('v_footer');
                    //----------------------end--------------------------------------------------------		
                }
            } else {
                redirect(base_url() . 'error', 'refresh');
            }
        } else {
            redirect(base_url() . 'login', 'refresh');
        }
    }

    public function insert() {
        try {
            $dataSend = [];
            $dataSend['data_insert'] = [];
            $company_code = $this->session->userdata("company");
            $branch_code = $this->input->post('cmb_branch_code');
            $txt_bank_code = $this->input->post('txt_bank_code');
            $txt_bank_name = $this->input->post('txt_bank_name');
            $txt_bank_number = $this->input->post('txt_bank_number');
            $txt_bank_address = $this->input->post('txt_bank_address');
            $cmb_city = $this->input->post('cmb_city');
            $cmb_state = $this->input->post('cmb_state');
            $cmb_country = $this->input->post('cmb_country');
            $txt_bank_description = $this->input->post('txt_bank_description');
			$BankInCode = $this->input->post('txt_bank_in_code');
			$BankOutCode = $this->input->post('txt_bank_out_code');
			
            //$BankInCode = substr($txt_bank_code, 0, 2) . 'M-' . $txt_bank_number;
            //$BankOutCode = substr($txt_bank_code, 0, 2) . 'K-' . $txt_bank_number;
            $CurrencyCode = $this->input->post('cmb_currency');
			
			$get_company_by_number = $this->m_bank->get_company_bank_number($txt_bank_code, $company_code);
            if (!empty($get_company_by_number->BankCode)) {
                throw new Exception('Bank Code yang dimasukan telah ada, untuk ' . $get_company_by_number->CompanyName . ', silahkan masukan dengan nomor lainnya');
            } else {
                $dataSend['data_insert'][] = array(
                    'CompanyCode' => $company_code,
                    'BranchCode' => $branch_code,
                    'BankCode' => strtoupper($txt_bank_code),
                    'BankName' => strtoupper($txt_bank_name),
                    'BankNumber' => $txt_bank_number,
                    'BankAddress' => strtoupper($txt_bank_address),
                    'BankCity' => $cmb_city,
                    'BankState' => $cmb_state,
                    'BankCountry' => $cmb_country,
                    'BankDesc' => strtoupper($txt_bank_description),
                    'BankInCode' => strtoupper($BankInCode),
                    'BankOutCode' => strtoupper($BankOutCode),
                    'CurrencyCode' => $CurrencyCode,
                    'TransStatus' => 1,
                    'LastUser' => $this->session->userdata("username")
                );
                //$result_insert = $this->m_bank->insert($data);

                $rstDataSend = $this->m_bank->data_send_bank_insert($dataSend);
                if ($rstDataSend) {
                    $result['status'] = true;
                    $result['message'] = get_notification('insert', 1);
                } else {
                    $result['status'] = false;
                    $result['message'] = get_notification('insert', 0);
                }
                echo json_encode($result);
            }
        } catch (Exception $e) {
            $result['status'] = false;
            $result['message'] = $e->getMessage();
            echo json_encode($result);
        }
    }

    public function insert_LAMA() {
        $company_code = $this->session->userdata("company");
        $branch_code = $this->input->post('cmb_branch_code');
        $txt_bank_code = $this->input->post('txt_bank_code');
        $txt_bank_name = $this->input->post('txt_bank_name');
        $txt_bank_number = $this->input->post('txt_bank_number');
        $txt_bank_address = $this->input->post('txt_bank_address');
        $cmb_city = $this->input->post('cmb_city');
        $cmb_state = $this->input->post('cmb_state');
        $cmb_country = $this->input->post('cmb_country');
        $txt_bank_description = $this->input->post('txt_bank_description');
        $BankInCode = substr($txt_bank_code, 0, 2) . 'M-' . $txt_bank_number;
        $BankOutCode = substr($txt_bank_code, 0, 2) . 'K-' . $txt_bank_number;
        $CurrencyCode = $this->input->post('cmb_currency');

        if ($this->m_bank->check_number_exist($txt_bank_code) == TRUE) {

            $get_company_by_number = $this->m_bank->get_company_bank_number($txt_bank_code);
            foreach ($get_company_by_number as $row_bank) {
                $result['status'] = false;
                $result['message'] = 'Bank Code yang dimasukan telah ada, untuk ' . $row_bank->CompanyName . ', silahkan masukan dengan nomor lainnya';
            }
        } else {
            $data = array(
                'CompanyCode' => $company_code,
                'BranchCode' => $branch_code,
                'BankCode' => strtoupper($txt_bank_code),
                'BankName' => strtoupper($txt_bank_name),
                'BankNumber' => $txt_bank_number,
                'BankAddress' => strtoupper($txt_bank_address),
                'BankCity' => $cmb_city,
                'BankState' => $cmb_state,
                'BankCountry' => $cmb_country,
                'BankDesc' => strtoupper($txt_bank_description),
                'BankInCode' => strtoupper($BankInCode),
                'BankOutCode' => strtoupper($BankOutCode),
                'CurrencyCode' => $CurrencyCode,
                'TransStatus' => 1,
                'LastUser' => $this->session->userdata("username")
            );

            $this->db->trans_begin();
            $result_insert = $this->m_bank->insert($data);

            if ($result_insert == 0) {
                $this->db->trans_rollback();
                $result['status'] = false;
                $result['message'] = get_notification('insert', 0);
            } else {
                $this->db->trans_commit();
                $result['status'] = true;
                $result['message'] = get_notification('insert', 1);
            }
        }


        echo json_encode($result);
    }

    public function edit() {
        if ($this->session->userdata("login") == TRUE) {
            $group_menu = $this->session->userdata('group_menu');
            /*
              untuk di index/list = get_menu_by_group,
              untuk di add = get_menu_by_group_add
              untuk di edit = get_menu_by_group_edit
             */
            $arr_group_id = $this->m_menu->get_menu_by_group_edit($group_menu, $this->menu_id);
            //--------------------------end-----------------------------------------------------------
            if (!empty($arr_group_id)) {
                $data['available_menu'] = array_unique($arr_group_id);
                if (!in_array($this->menu_id, $data['available_menu'])) {
                    redirect(base_url() . 'error', 'refresh');
                } else {
                    /*
                      modul untuk akses add masing masing modul berebda
                      jangan lupa copy $data nya (jika dia bener langsung ke add)
                     */
                    $id = $this->uri->segment(4);
                    $group_menu = $this->session->userdata('group_menu');

                    $data['detail'] = $this->m_bank->get_detail($id);
                    $data['menu_link'] = $this->m_menu->get_menulink($this->menu_id);
                    $data['menu_label'] = $this->m_menu->get_menulabel($this->menu_id);

                    //panggil model hak akses untuk autoriti
                    $data['group_user'] = $this->m_menu->group_user_autority($this->menu_id, $group_menu);

                    $this->load->view('v_header');
                    $this->load->view('bank/v_edit_bank', $data);
                    $this->load->view('v_footer');
                    //----------------------end--------------------------------------------------------		
                }
            } else {
                redirect(base_url() . 'error', 'refresh');
            }
        } else {
            redirect(base_url() . 'login', 'refresh');
        }
    }

    public function update() {
        try {
            $dataSend = [];
            $dataSend['data_bank_update'] = [];

            $company_code = $this->session->userdata("company");
            $branch_code = $this->input->post("cmb_branch_code");
            $txt_bank_id = $this->input->post('txt_bank_id');
            $txt_bank_code = $this->input->post('txt_bank_code');
            $txt_bank_name = $this->input->post('txt_bank_name');
            $txt_bank_number = $this->input->post('txt_bank_number');
            $txt_bank_address = $this->input->post('txt_bank_address');
            $cmb_city = $this->input->post('cmb_city');
            $cmb_state = $this->input->post('cmb_state');
            $cmb_country = $this->input->post('cmb_country');
            $txt_bank_description = $this->input->post('txt_bank_description');
            $BankInCode = $this->input->post('txt_bank_in_code');
            $BankOutCode = $this->input->post('txt_bank_out_code');
            $CurrencyCode = $this->input->post('cmb_currency');

            $dataSend['data_bank_update'][] = array(
                'CompanyCode' => $company_code,
                'BranchCode' => $branch_code,
                'BankCode' => strtoupper($txt_bank_code),
                'BankName' => strtoupper($txt_bank_name),
                'BankNumber' => $txt_bank_number,
                'BankAddress' => strtoupper($txt_bank_address),
                'BankCity' => $cmb_city,
                'BankState' => $cmb_state,
                'BankCountry' => $cmb_country,
                'BankDesc' => strtoupper($txt_bank_description),
                'BankInCode' => strtoupper($BankInCode),
                'BankOutCode' => strtoupper($BankOutCode),
                'CurrencyCode' => $CurrencyCode,
                'TransStatus' => 1,
                'LastUser' => $this->session->userdata("username"),
                'idcode' => $txt_bank_id //untuk parameter update di model
            );
//            $result_edit = $this->m_bank->update($data, $txt_bank_id);

            $rstDataSend = $this->m_bank->data_send_bank_update($dataSend);
            if ($rstDataSend) {
                $result['status'] = true;
                $result['message'] = get_notification('update', 1);
            } else {
                $result['status'] = false;
                $result['message'] = get_notification('update', 0);
            }
            echo json_encode($result);
        } catch (Exception $e) {
            $result['status'] = false;
            $result['message'] = $e->getMessage();
            echo json_encode($result);
        }
    }

    public function update_LAMA() {
        $company_code = $this->session->userdata("company");
        $branch_code = $this->input->post("cmb_branch_code");

        $txt_bank_id = $this->input->post('txt_bank_id');
        $txt_bank_code = $this->input->post('txt_bank_code');
        $txt_bank_name = $this->input->post('txt_bank_name');
        $txt_bank_number = $this->input->post('txt_bank_number');
        $txt_bank_address = $this->input->post('txt_bank_address');
        $cmb_city = $this->input->post('cmb_city');
        $cmb_state = $this->input->post('cmb_state');
        $cmb_country = $this->input->post('cmb_country');
        $txt_bank_description = $this->input->post('txt_bank_description');
        $BankInCode = $this->input->post('txt_bank_in_code');
        $BankOutCode = $this->input->post('txt_bank_out_code');
        $CurrencyCode = $this->input->post('cmb_currency');

        $data = array(
            'CompanyCode' => $company_code,
            'BranchCode' => $branch_code,
            'BankCode' => strtoupper($txt_bank_code),
            'BankName' => strtoupper($txt_bank_name),
            'BankNumber' => $txt_bank_number,
            'BankAddress' => strtoupper($txt_bank_address),
            'BankCity' => $cmb_city,
            'BankState' => $cmb_state,
            'BankCountry' => $cmb_country,
            'BankDesc' => strtoupper($txt_bank_description),
            'BankInCode' => strtoupper($BankInCode),
            'BankOutCode' => strtoupper($BankOutCode),
            'CurrencyCode' => $CurrencyCode,
            'TransStatus' => 1,
            'LastUser' => $this->session->userdata("username")
        );

        $this->db->trans_begin();
        $result_edit = $this->m_bank->update($data, $txt_bank_id);

        if ($result_edit == 0) {
            $this->db->trans_rollback();
            $result['status'] = false;
            $result['message'] = get_notification('update', 0);
        } else {
            $this->db->trans_commit();
            $result['status'] = true;
            $result['message'] = get_notification('update', 1);
        }

        echo json_encode($result);
    }

    public function suspend_data() {
        try {
            $id = $this->input->post('id');
            $company_code = $this->session->userdata('company');
            $branch_code = $this->session->userdata('branch');
            $status_branch_company = $this->session->userdata('branch_status');

            $dataSend = [];
            $dataSend['data_bank_suspend'] = [];
            $dataSend['idcode'] = $id;
            $status_suspend = 0;

            $dataSend['data_bank_suspend'] = array(
                'TransStatus' => 3,
                'LastUser' => $this->session->userdata("username")
            );

            //========= cek bank opening balance for suspen master bank ======//
            $check_data = $this->m_bank->check_data_by_company_from_bank($id, $company_code, $branch_code);
            if (($check_data->GLSaldoBalance == 0) && ($check_data->TransStatus == 3)) {
//                $this->m_bank->update($data, $id);   // masuk ke model             
                $status_suspend = 1;
            } else if (($check_data->GLSaldoBalance == NULL) && ($check_data->TransStatus == NULL)) {
//                $this->m_bank->update($data, $id);// masuk ke model                             
                $status_suspend = 1;
            }
            //========= end cek bank opening balance for suspen master bank ==//

            if ($status_suspend == 1) {
                $rstDataSend = $this->m_bank->data_send_bank_suspend($dataSend);
                if ($rstDataSend) {
                    $result['status'] = true;
                    $result['message'] = get_notification('suspend', 1);
                } else {
                    $result['status'] = false;
                    $result['message'] = get_notification('suspend', 0);
                }
                echo json_encode($result);
            } else {
                throw new Exception('Maaf Bank tidak bisa di suspend, karena Period Balance/Saldo masi ada nilai atau Bank di COA belum disuspend');
            }
        } catch (Exception $e) {
            $result['status'] = false;
            $result['message'] = $e->getMessage();
            echo json_encode($result);
        }
    }

    public function suspend_data_LAMA() {
        $id = $this->input->post('id');
        $company_code = $this->session->userdata('company');
        $branch_code = $this->session->userdata('branch');
        $status_branch_company = $this->session->userdata('branch_status');

        $data = array(
            'TransStatus' => 3,
            'LastUser' => $this->session->userdata("username")
        );

        $this->db->trans_begin();
        //-----------------------------cek bank opening balance for suspen master bank-----------------------------------------//
        $check_data = $this->m_bank->check_data_by_company_from_bank($id, $company_code, $branch_code);
        if (($check_data->GLSaldoBalance == 0) && ($check_data->TransStatus == 3)) {
            $this->m_bank->update($data, $id);
        } else if (($check_data->GLSaldoBalance == NULL) && ($check_data->TransStatus == NULL)) {
            $this->m_bank->update($data, $id);
        } else {
            $result['status'] = false;
            $result['message'] = 'Maaf Bank tidak bisa di suspend, karena Period Balance/Saldo masi ada nilai atau Bank di COA belum disuspend';

            echo json_encode($result);
            die;
        }
        //--------------------------------end------------------------------------------------------------------------------------//


        if ($this->db->trans_status() == FALSE) {
            $this->db->trans_rollback();
            $result['status'] = false;
            $result['message'] = get_notification('suspend', 0);
        } else {
            $this->db->trans_commit();
            $result['status'] = true;
            $result['message'] = get_notification('suspend', 1);
        }

        echo json_encode($result);
    }

    function to_preview($obj_string = null) {
//        $data['list'] = $this->m_bank->get_all_print($BranchCode);        
        $data['menu_id'] = $this->menu_id;
        $data['menu_label'] = $this->m_menu->get_menulabel($this->menu_id);
        $data['menu_link'] = $this->m_menu->get_menulink($this->menu_id);

        $data_filter = arrayParamInUrlToStr($obj_string);
        $data['company_code'] = $data_filter['cmb_company'];
        $data['branch_code'] = $data_filter['cmb_branch'];
        $data['list'] = $this->m_bank->get_all_to_print($data_filter);

        $this->load->view('v_header');
        $this->load->view('bank/v_preview_bank', $data);
        $this->load->view('v_footer');
    }

    function to_preview_LAMA() {
        $CompanyCode = $this->uri->segment(4);
        $BranchCode = $this->uri->segment(5);
        // set data
        $data['company_code'] = $CompanyCode;
        $data['branch_code'] = $BranchCode;

        $data['menu_link'] = $this->m_menu->get_menulink($this->menu_id);
        $data['menu_label'] = $this->m_menu->get_menulabel($this->menu_id);
        $data['list'] = $this->m_bank->get_all_print($BranchCode);

        $this->load->view('v_header');
        $this->load->view('bank/v_preview_bank', $data);
        $this->load->view('v_footer');
    }

    function to_print() {
        $data['menu_link'] = $this->m_menu->get_menulink($this->menu_id);
        $data['menu_label'] = $this->m_menu->get_menulabel($this->menu_id);
        $data['list'] = $this->m_bank->get_all();

        $this->load->view('v_header');
        $this->load->view('bank/v_print_bank', $data);
        $this->load->view('v_footer');
    }

    public function ajax() {
        $page = ($this->input->post('page')) ? intval($this->input->post('page')) : 1;
        $rows = ($this->input->post('rows')) ? intval($this->input->post('rows')) : 150;

        $hasil = array();
        /* ===========rows*page tidak boleh melebihi dari jumlah data======= */

        /* ===========================declar post by find================================================ */
        $Code = ($this->input->post('BankCode')) ? $this->input->post('BankCode') : '';
        $Name = ($this->input->post('BankName')) ? $this->input->post('BankName') : '';

        $BranchCode = ($this->input->post('BranchCode')) ? $this->input->post('BranchCode') : '';
        $CompanyCode = ($this->input->post('CompanyCode')) ? $this->input->post('CompanyCode') : '';
        $TransStatus = ($this->input->post('TransStatus')) ? $this->input->post('TransStatus') : '';
        /* ========================================end================================================== */

        /* ========================jika kondisi tidak sama dengan kosong di find========================= */
        if ($BranchCode != "") {
            $this->db->where('BranchCode', $BranchCode);
        } else {
            $this->db->where('BranchCode', $this->session->userdata('branch'));
        }

        if ($Code != "") {
            $this->db->like('BankCode', $Code);
        }
        if ($Name != "") {
            $this->db->like('BankName', $Name);
        }

        if ($TransStatus != '') {
            $this->db->where_in('TransStatus', $TransStatus);
        } else {
            /*
              trans status 0,1 adalah aktif
             */
            $this->db->where_in('TransStatus', array(0, 1));
        }
        /* ==========================end================================================================= */

        /* untuk memastikan bahwa data yang ditampilkan selalu sama dengan virtual scrolling */
        $count_data = $this->db->count_all_results('am_bank');
        $offset = $count_data - ($rows * $page);
        if ($offset > 0) {
            $rows = $rows;
        } else if ($offset < 0) {
            $rows = $count_data - ($rows * ($page - 1));
        }
        /* ========================end======================================= */

        $result = $this->m_bank->get_all();


        for ($i = 0; $i <= ($rows - 1); $i++) {
            $TransStatus = get_status_master($result[$i]->TransStatus);

            $hasil[] = array(
                'BranchName' => $result[$i]->BranchName,
                'TransNumber' => $result[$i]->BankID,
                'BankCode' => $result[$i]->BankCode,
                'BankName' => $result[$i]->BankName,
                'BankInCode' => $result[$i]->BankInCode,
                'BankOutCode' => $result[$i]->BankOutCode,
                'BankNumber' => $result[$i]->BankNumber,
                'TransStatus' => $TransStatus,
            );
        }

        if ($hasil == "") {
            $result = array();
            echo json_encode($result);
        } else {
            $result = array();
            $result['total'] = $count_data;
            $result['rows'] = $hasil;
            echo json_encode($result);
        }
    }

    public function account_gl($branch_code) {
        $data = $this->m_coa->get_all();
        header('Content-Type: text/json');

        ob_clean();
        flush();
        echo json_encode($data);
    }

    public function suspend() {
        $id = $this->input->post('id');

        $cek_master_coa = $this->m_bank->get_master_coa_from_bank();
        foreach ($cek_master_coa as $row_coa) {
            
        }
        $data = array(
            'TransStatus' => 3,
            'LastUser' => $this->session->userdata('user')
        );

        $hasil = $this->m_bank->update($data, $id);

        if ($hasil == 1) {
            $result['status'] = true;
            $result['message'] = get_notification('delete', $hasil);
        } else {
            $result['status'] = false;
            $result['message'] = get_notification('delete', $hasil);
        }
        echo json_encode($result);
    }

    //function bank book terpakai saat transaksi yang berhubungan dengan bank
    function bank_book_data($txt_amount, $akun_number, $txt_branch_code, $txt_opening_balance_period) {
        if ($txt_amount >= 0) {
            $saldo_debit = $txt_opening_balance_period + $txt_amount - 0;
            $saldo_credit = 0;
        } else {
            $saldo_debit = 0;
            $saldo_credit = $txt_opening_balance_period + 0 - $txt_amount;
        }

        $bank_book = array(
            'BranchCode' => $txt_branch_code,
            'TransDate' => date("Y-m-d"),
            'TransNumber' => "Opening Balance",
            'BankAccount' => $akun_number,
            'SaldoDebet' => $saldo_debit,
            'SaldoCredit' => $saldo_credit,
            'SaldoBalance' => $txt_opening_balance,
            'PrimeBalance' => $txt_opening_balance
        );

        $check_bank_book_by_branch = $this->m_coa->check_bank_book($akun_number, $txt_branch_code);

        if ($check_bank_book_by_branch == FALSE) {
            $result_edit = $this->m_coa->insert_bank_book($bank_book, $id);
            if ($result_edit == 0) {
                $this->trans_rollback('approval');
            }
        } else {
            $result_edit = $this->m_coa->update_bank_book($bank_book, $id);
            if ($result_edit == 0) {
                $this->trans_rollback('approval');
            }
        }
    }

    //end bank book
}

/* End of file bank.php */
/* Location: ./application/modules_core/list/controllers/bank.php */
	