<?php

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

class M_customer extends CI_Model {

    public $table           = "am_customer";
    public $branch          = "am_branch";
    public $journal         = "at_sinvjournal";
    public $currency        = "am_currency";
    public $sord_detail_dp  = "at_sorddetaildp";
    public $employee        = "am_employee";
    public $department      = "am_department";

    // Function Join
    function join_all() {
        //default status untuk keluarin di list.
        $status = array(0, 1);

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

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

        /* ======================================scrol view 1-150======================================= */
        $page = ($this->input->post('page')) ? intval($this->input->post('page')) : 1;
        $rows = ($this->input->post('rows')) ? intval($this->input->post('rows')) : 150;

        $beginning = ($page - 1) * $rows;
        $end = $page * $rows;
        /* ============================================================================================== */

        /* ==========================================by session========================================== */
        $sess_company = $this->session->userdata('company');
        $sess_branch = $this->session->userdata('branch');
        $sess_branch_status = $this->session->userdata('branch_status');
        /* =============================================================================================== */

        $this->db->select('am_customer.CustomerCode, am_customer.CustomerName, am_customer.PhoneNumber, am_customer.OutStanding, am_customer.BranchCode, 
                           am_customer.CustomerCity, am_customer.ContactPerson, am_customer.SalesLimit,
                           am_customer.CurrencyCode, am_customer.TransStatus as Status, am_currency.CurrencyName, am_city.CityName, am_customer.BranchCode, am_termspayment.TermDesc');
        $this->db->from($this->table);
        $this->db->join('am_currency', 'am_currency.CurrencyCode = am_customer.CurrencyCode', 'inner');
        $this->db->join('am_city', 'am_city.CityCode = am_customer.CustomerCity', 'left');
		 $this->db->join('am_termspayment', 'am_termspayment.TermsPaymentID = am_customer.TermsPaymentID', 'inner');
        /*
          get data dari  combobox find di view
         */
        if ($BranchCode != "") {
            $this->db->where('am_customer.BranchCode', $BranchCode);
            $this->db->where('am_currency.CompanyCode', $CompanyCode);
        } else {
            /*
              inisialisasi untuk loading pertama page branch info
             */
            //----------------kondisi 1 untuk branch-------------------------------------//
            /*
              branch status 0 = HO
              branch status 1 = depo/branch
              jangan lupa sesion data di atas untuk setiap kondisi
              jangan lupa tambahin case when trans status
             */
            $this->db->where('am_customer.BranchCode', $sess_branch);
            $this->db->where('am_currency.CompanyCode', $sess_company);
            //-----------------------end-------------------------------------------------//
        }

        if ($Code != "") {
            $this->db->like('am_customer.CustomerCode', $Code);
        }
        if ($Name != "") {
            $this->db->like('am_customer.CustomerName', $Name);
        }
        if ($CurrencyCode != "") {
            $this->db->where('am_customer.CurrencyCode', $CurrencyCode);
        }

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

        $query = $this->db->order_by('am_customer.CustomerCode', 'ASC');
        $query = $this->db->limit($end, $beginning);
        $query = $this->db->get();
        $result = $query->result();
        return $result;
    }

    function get_all_to_print($data_filter) {
        //default status untuk keluarin di list.
        $status = array(0, 1);
        /* ===========================declar post by find================================================ */        
        $CompanyCode    = $data_filter['cmb_company'];
        $BranchCode     = $data_filter['cmb_branch'];
        $Code           = $data_filter['txt_CustomerCode'];
        $Name           = $data_filter['txt_CustomerName'];
        $TransStatus    = $data_filter['chk_TransStatus'];
        $CurrencyCode   = $data_filter['cmb_CurrencyCode'];
        /* ========================================end================================================== */

        /* ==========================================by session========================================== */
        $sess_company = $this->session->userdata('company');
        $sess_branch = $this->session->userdata('branch');
        $sess_branch_status = $this->session->userdata('branch_status');
        /* =============================================================================================== */

        $this->db->select('am_customer.CustomerCode, am_customer.CustomerName, am_customer.PhoneNumber, am_customer.OutStanding, am_customer.BranchCode, 
                           am_customer.CustomerCity, am_customer.ContactPerson, am_customer.SalesLimit,
                           am_customer.CurrencyCode, am_customer.TransStatus as Status, am_currency.CurrencyName, am_city.CityName, am_customer.BranchCode');
        $this->db->from($this->table);
        $this->db->join('am_currency', 'am_currency.CurrencyCode = am_customer.CurrencyCode', 'inner');
        $this->db->join('am_city', 'am_city.CityCode = am_customer.CustomerCity', 'inner');

        /*
          get data dari  combobox find di view
         */
        if ($BranchCode != "") {
            $this->db->where('am_customer.BranchCode', $BranchCode);
            $this->db->where('am_currency.CompanyCode', $CompanyCode);
        } else {
            /*
              inisialisasi untuk loading pertama page branch info
             */
            //----------------kondisi 1 untuk branch-------------------------------------//
            /*
              branch status 0 = HO
              branch status 1 = depo/branch
              jangan lupa sesion data di atas untuk setiap kondisi
              jangan lupa tambahin case when trans status
             */
            $this->db->where('am_customer.BranchCode', $sess_branch);
            $this->db->where('am_currency.CompanyCode', $sess_company);
            //-----------------------end-------------------------------------------------//
        }

        if ($Code != "") {
            $this->db->like('am_customer.CustomerCode', $Code);
        }
        if ($Name != "") {
            $this->db->like('am_customer.CustomerName', $Name);
        }
        if ($CurrencyCode != "") {
            $this->db->where('am_customer.CurrencyCode', $CurrencyCode);
        }

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

        $query = $this->db->order_by('am_customer.CustomerCode', 'ASC');
        $query = $this->db->get();
        $result = $query->result();
        return $result;
    }

    function check_code_exist($txt_customerno) {
        $query = $this->db->get_where($this->table, array('CustomerCode' => $txt_customerno), 1, 0);

        if ($query->num_rows() > 0) {
            return TRUE;
        } else {
            return FALSE;
        }
    }

    function check_code_exist_city($txt_city) {
        $query = $this->db->get_where('am_city', array('CityCode' => $txt_city), 1, 0);

        if ($query->num_rows() > 0) {
            return TRUE;
        } else {
            return FALSE;
        }
    }

    function check_code_exist_term($txt_term_id) {
        $query = $this->db->get_where('am_termspayment', array('TermspaymentID' => $txt_term_id), 1, 0);

        if ($query->num_rows() > 0) {
            return TRUE;
        } else {
            return FALSE;
        }
    }

    function check_code_exist_currency($txt_curr) {
        $query = $this->db->get_where('am_currency', array('CurrencyCode' => $txt_curr), 1, 0);

        if ($query->num_rows() > 0) {
            return TRUE;
        } else {
            return FALSE;
        }
    }

    function check_code_exist_taxes($txt_taxes) {
        $query = $this->db->get_where('am_taxes', array('TaxesCode' => $txt_taxes), 1, 0);

        if ($query->num_rows() > 0) {
            return TRUE;
        } else {
            return FALSE;
        }
    }

    function check_code_exist_tax_type($txt_tax_type) {
        $query = $this->db->get_where('am_taxtype', array('TaxTypeID' => $txt_tax_type), 1, 0);

        if ($query->num_rows() > 0) {
            return TRUE;
        } else {
            return FALSE;
        }
    }

    function check_code_exist_region($txt_region) {
        $query = $this->db->get_where('am_region', array('RegionCode' => $txt_region), 1, 0);

        if ($query->num_rows() > 0) {
            return TRUE;
        } else {
            return FALSE;
        }
    }

    function get_all_currency() {
        $this->db->select('*');
        $this->db->from('am_currency');
        $query = $this->db->get();

        return $query->result();
    }

    function get_by_id($customer_code) {
        $this->db->select('am_customer.CustomerCode,am_customer.TransStatus as CustStatus, am_customer.CustomerStatus,am_customer.CustomerName,am_customer.CustomerAddress,am_customer.CustomerCity, am_customer.TempOutStanding, am_customer.OutStandingFiscal, 
                           am_city.CityCode,am_state.StateCode,am_country.CountryCode, 
                           am_customer.CustomerState,am_customer.CustomerCountry,am_customer.PhoneNumber,am_customer.FacsimileNumber,am_customer.ContactPerson,
                           am_customer.EmailAddress,am_customer.WebAddress,am_customer.TermsPaymentID as TermsID,am_termspayment.TermsPaymentID,am_termspayment.DiscountPercent,am_termspayment.PaidWithin,
                           am_termspayment.NetDueIn,am_customer.SalesLimit,am_customer.CurrencyCode,am_customer.CurrencyMemo,am_customer.Taxes1Code,
                           am_customer.Taxes2Code,am_customer.TaxIncludedStatus,am_customer.TaxesNumber,am_customer.PPKPNumber,am_customer.TaxesTypeID,am_customer.OutStanding,
                           am_customer.RegionCode,am_customer.CustomerDesc,am_customer.CustTaxAddress,am_customer.CustomerPostalCode, am_customer.SaldoDPBalance, am_customer.CurrencyRate, am_customer.SaldoDPRate, am_branch.BranchStatus, am_branch.BranchCode');
        $this->db->from($this->table);
        $this->db->join('am_currency', 'am_currency.CurrencyCode = am_customer.CurrencyCode');
        $this->db->join('am_city', 'am_city.CityCode = am_customer.CustomerCity','left');
        $this->db->join('am_state', 'am_state.StateCode = am_customer.CustomerState','left');
        $this->db->join('am_country', 'am_country.CountryCode = am_customer.CustomerCountry','left');
        $this->db->join('am_termspayment', 'am_termspayment.TermspaymentID = am_customer.TermsPaymentID');
        $this->db->join('am_branch', 'am_branch.BranchCode = am_customer.BranchCode');

        $this->db->where('CustomerCode', $customer_code);
        //$this->db->where('BranchCode', $this->session->userdata('branch'));

        $query = $this->db->get();
        $result = $query->row();

        return $result;
    }

    function insert($data) {
        $this->db->trans_begin();
        $this->db->insert($this->table, $data);

        if ($this->db->trans_status() === FALSE) {
            $this->db->trans_rollback();
            return 0;
        } else {
            $this->db->trans_commit();
            return 1;
        }
    }

    function update($data, $cust_code) {
        $this->db->update($this->table, $data, array('CustomerCode' => $cust_code));

        // if ($this->db->trans_status() === FALSE) {
        //     return 0;
        // }
        // else {
        //     return 1;
        // }
    }

    function update_by_branch($data, $cust_code, $branch_code) {
        $this->db->update($this->table, $data, array('CustomerCode' => $cust_code, 'BranchCode' => $branch_code));

        if ($this->db->trans_status() === FALSE) {
            return 0;
        } else {
            return 1;
        }
    }

    function suspend($data, $customerno) {
        $this->db->trans_begin();
        $this->db->update($this->table, $data, array('CustomerCode' => $customerno));

        if ($this->db->trans_status() === FALSE) {
            $this->db->trans_rollback();
            return 0;
        } else {
            $this->db->trans_commit();
            return 1;
        }
    }

    function get_terms_by_row($terms_id) {
        $this->db->select('*');
        $this->db->from('am_termspayment');
        $this->db->where('TermspaymentID', $terms_id);
        $query = $this->db->get();
        $result = $query->row();

        return $result;
    }

    function get_termspercent_value($terms_id) {
        $this->db->select('*');
        $this->db->from('am_termspayment');
        $this->db->where('TermspaymentID', $terms_id);
        $query = $this->db->get();
        $result = $query->result();

        return $result;
    }

    function get_saldo_balance($id) {
        $this->db->select('(OutStanding - SaldoDPBalance + TempOutStanding) as SaldoBalance, SalesLimit');
        $this->db->from($this->table);
        $this->db->where('CustomerCode', $id);
        $query = $this->db->get();

        return $query->row();
    }

    function get_OustStanding($id) {
        $this->db->select('OutStanding');
        $this->db->from($this->table);
        $this->db->where('CustomerCode', $id);
        $query = $this->db->get();

        if ($query->num_rows() > 0) {
            foreach ($query->result() as $row) {
                $OutStanding = $row->OutStanding;
            }

            return $OutStanding;
        } else {
            return 0;
        }
    }

    function get_OustStanding_fiscal($id) {
        $this->db->select('OutStandingFiscal');
        $this->db->from($this->table);
        $this->db->where('CustomerCode', $id);
        $query = $this->db->get();

        if ($query->num_rows() > 0) {
            foreach ($query->result() as $row) {
                $OutStandingFiscal = $row->OutStandingFiscal;
            }

            return $OutStandingFiscal;
        } else {
            return 0;
        }
    }

    function get_TemOutstanding($id) {
        $this->db->select('TempOutStanding');
        $this->db->from($this->table);
        $this->db->where('CustomerCode', $id);
        $query = $this->db->get();

        if ($query->num_rows() > 0) {
            foreach ($query->result() as $row) {
                $TempOutStanding = $row->TempOutStanding;
            }

            return $TempOutStanding;
        } else {
            return 0;
        }
    }

    function get_latest_pay($id) {
        $this->db->select('LatestPayDate');
        $this->db->from($this->table);
        $this->db->where('CustomerCode', $id);
        $query = $this->db->get();

        if ($query->num_rows() > 0) {
            foreach ($query->result() as $row) {
                $LatestPayDate = $row->LatestPayDate;
            }

            return $LatestPayDate;
        } else {
            return date("Y-m-d");
        }
    }

    function check_cust_status($id) {
        $this->db->select('CustomerStatus');
        $this->db->from($this->table);
        $this->db->where('CustomerCode', $id);
        $query = $this->db->get();

        if ($query->num_rows() > 0) {
            foreach ($query->result() as $row) {
                $CustomerStatus = $row->CustomerStatus;
            }

            return $CustomerStatus;
        } else {
            return 0;
        }
    }

    function get_tax_number($id) {
        $this->db->select('TaxesNumber');
        $this->db->from($this->table);
        $this->db->where('CustomerCode', $id);
        $query = $this->db->get();

        if ($query->num_rows() > 0) {
            foreach ($query->result() as $row) {
                $TaxesNumber = $row->TaxesNumber;
            }

            return $TaxesNumber;
        } else {
            return FALSE;
        }
    }

    function set_balance($id, $amount) {
        $this->db->set('OutStanding', $amount);
        $this->db->where('CustomerCode', $id);
        $this->db->update($this->table);
    }

    function set_latest_pay($id, $date) {
        $this->db->set('LatestPayDate', $date);
        $this->db->where('CustomerCode', $id);
        $this->db->update($this->table);
    }

//    function set_saldo_dp($id, $amount) {
//        $this->db->set('SaldoDP', $amount);
//        $this->db->where('CustomerCode', $id);
//        $this->db->update($this->table);
//    }
//    function get_saldo_dp($id) {
//        $this->db->select('SaldoBalance, SaldoDPBalance, SaldoDPPaid, SaldoDPUsed');
//        $this->db->from($this->table);
//        $this->db->where('CustomerCode', $id);
//        $query = $this->db->get();    
//
//        if ($query->num_rows() > 0) {
//            foreach ($query->result() as $row) {
//                $Saldo_DP = array(
//                $SaldoBalance = $row->SaldoBalance,
//                $SaldoDPBalance = $row->SaldoDPBalance,
//                $SaldoDPPaid = $row->SaldoDPPaid,
//                $SaldoDPUsed = $row->SaldoDPUsed
//            );
//        }   
//
//            return $Saldo_DP;
//        }
//        else {
//            return FALSE;
//        }	
//    }

    function get_all_by_no($customer_number) {
        $this->db->select('TransStatus,OutStanding');
        $this->db->from($this->table);
        $this->db->where('CustomerCode', $customer_number);
        $query = $this->db->get();
        return $query->result();
    }

    function get_last_customer_code($sess_branch) {
        $this->db->select_max('CustomerCode');
        $this->db->from($this->table);
        $this->db->where($this->table . '.BranchCode', $sess_branch);
        $query = $this->db->get();

        return $query->result();
    }

    function preview_all_by_search($sess_company, $sess_branch, $sess_branch_status) {
        $this->db->select($this->table . '.*,am_currency.CurrencyName');
        $this->db->from($this->table);
        $this->db->join('am_currency', 'am_currency.CurrencyCode = ' . $this->table . '.CurrencyCode');
        $this->db->join('am_branch', 'am_branch.BranchCode = ' . $this->table . '.BranchCode');

        if ($sess_branch_status == 0) {
            $this->db->where($this->branch . '.CompanyCode', $sess_company);
        }

        if ($sess_branch_status == 1) {
            $this->db->where($this->table . '.BranchCode', $sess_branch);
        }

        $query = $this->db->get();
        return $query->result();
    }

    function import_customer($data) {
        $this->db->trans_begin();
        $this->db->insert($this->table, $data);

        if ($this->db->trans_status() === FALSE) {
            $this->db->trans_rollback();
            return 0;
        } else {
            $this->db->trans_commit();
            return 1;
        }
    }

    function get_customer_code($CustomerCode) {
        $this->db->select('CustomerCode');
        $this->db->from($this->table);
        $this->db->where($this->table . '.CustomerCode', $CustomerCode);
        $query = $this->db->get();

        if ($query->num_rows() > 0) {
            foreach ($query->result() as $row) {
                $CustomerCode = $row->CustomerCode;
            }

            return $CustomerCode;
        } else {
            return FALSE;
        }
    }

    function get_saldo_by_id($id) {
        $this->db->select('OutStandingFiscal, OutStanding, SaldoDPBalance, SaldoDPPaid, SaldoDPUsed, BranchCode');
        $this->db->from($this->table);
        $this->db->where($this->table . '.CustomerCode', $id);
        $query = $this->db->get();

        return $query->result();
    }

    function get_saldo_by_id_new($id) {
        $this->db->select('OutStanding, SaldoDPBalance, SaldoDPPaid, SaldoDPUsed');
        $this->db->from($this->table);
        $this->db->where($this->table . '.CustomerCode', $id);
        $query = $this->db->get();

        return $query->row();
    }

    function insert_sales_invoice($data_sales_invoice) {
        $this->db->insert('at_salesinvoice', $data_sales_invoice);

        if ($this->db->trans_status() === FALSE) {
            $this->db->trans_rollback();
            return 0;
        } else {
            //$this->db->trans_commit();
            return 1;
        }
    }

    function insert_detail($data_detail_si) {
        $this->db->insert('at_sinvdetail', $data_detail_si);

        if ($this->db->trans_status() === FALSE) {
            $this->db->trans_rollback();
            return 0;
        } else {
            //$this->db->trans_commit();
            return 1;
        }
    }

    function get_no_si($key_2) {
        $this->db->select('SInvNumber');
        $this->db->from('at_salesinvoice');
        $this->db->where('at_salesinvoice.OldSInvNumber', $key_2);
        $query = $this->db->get();

        return $query->row();
    }

    function update_sales_invoice($data_update_total, $key, $branchCode) {
        $this->db->update('at_salesinvoice', $data_update_total, array('OldSInvNumber' => $key, 'BranchCode' => $branchCode));

        if ($this->db->trans_status() === FALSE) {
            return 0;
        } else {
            return 1;
        }
    }

    function update_appfinis($update_appfinis, $key_3, $branchCode) {
        $this->db->update('at_salesinvoice', $update_appfinis, array('OldSInvNumber' => $key_3, 'BranchCode' => $branchCode));

        if ($this->db->trans_status() === FALSE) {
            return 0;
        } else {
            return 1;
        }
    }

    function get_inventories($Item_code) {
        $sess_branch = $this->session->userdata('branch');
        $this->db->select('am_item.ItemCode, am_item.ItemCategoryID');
        $this->db->from('at_inventories');
        $this->db->join('am_item', 'at_inventories.ItemCode = am_item.ItemCode');
        $this->db->where('at_inventories.ItemCode', $Item_code);
        $this->db->where('at_inventories.BranchCode', $sess_branch);
        $query = $this->db->get();

        return $query->row();
    }

    function insert_journal($data) {
        $this->db->insert($this->journal, $data);

        if ($this->db->trans_status() === FALSE) {
            return 0;
        } else {
            return 1;
        }
    }

    function insert_transsaction($trans_data) {

        $this->db->trans_start();

        /* ================= insert group transaction ============================== */
        $this->insert($trans_data['insert_group']['data']);

        $this->db->trans_complete();

        if ($this->db->trans_status() === FALSE) {
            return false;
        } else {
            return true;
        }
    }

    function update_transsaction($trans_data) {

        $this->db->trans_start();

        /* ====================== update group ==================== */
        $this->update($trans_data['update_group']['data'], $trans_data['update_group']['TransNumber']);

        for ($x = 0; $x < $trans_data['detail_si']['total']; $x++) {
            $this->insert_sales_invoice($trans_data['insert_sales_invoice']['data'][$x]);
            $this->insert_detail($trans_data['insert_detail']['data'][$x]);
            $this->m_sales_invoice->insert_sinv_receipt($trans_data['insert_sinv_receipt']['data'][$x]);

            for ($i = 0; $i < count($trans_data['insert_journal'][$x]['data']); $i++) {
                $this->insert_journal($trans_data['insert_journal'][$x]['data'][$i]);
            }

            $this->m_sales_invoice->update_sinv_receipt_2($trans_data['update_sinv_receipt_2']['data'][$x], $trans_data['update_sinv_receipt_2']['key'][$x]);
            $this->update_sales_invoice($trans_data['update_sales_invoice']['data'][$x], $trans_data['update_sales_invoice']['key'][$x], $trans_data['update_sales_invoice']['BranchCode'][$x]);
            $this->update_appfinis($trans_data['update_appfinis']['data'][$x], $trans_data['update_appfinis']['key'][$x], $trans_data['update_appfinis']['BranchCode'][$x]);
        }

        for ($x = 0; $x < $trans_data['detail_dp']['total']; $x++) {
            $this->m_period_end->insert_group_jvb($trans_data['insert_dp_group']['data'][$x]);
            $this->insert_sord_detail_dp($trans_data['insert_sord_detail_dp']['data'][$x]);

            for ($i = 0; $i < count($trans_data['insert_dp_detail'][$x]['data']); $i++) {
                $this->m_period_end->insert_detail_jvb($trans_data['insert_dp_detail'][$x]['data'][$i]);
                $this->m_period_end->insert_journal_jvb($trans_data['insert_dp_journal'][$x]['data'][$i]);
            }

            $this->m_period_end->update_group_jvb($trans_data['update_group_jv']['TransNumber'][$x], $trans_data['update_group_jv']['data'][$x]);
        }

        /* ===================== end insert journal =============================== */
        $this->db->trans_complete();

        if ($this->db->trans_status() === FALSE) {
            return false;
        } else {
            return true;
        }
    }

    function insert_sord_detail_dp($data_sord_detail_dp) {
        $this->db->insert($this->sord_detail_dp, $data_sord_detail_dp);
    }

    function get_list_salesman($branch){
        $this->db->select('em.EmployeeCode,em.EmployeeName');
        $this->db->from($this->employee.' as em');
        $this->db->join($this->department.' as dp','dp.DepartmentCode=em.DepartmentCode','inner');
        $this->db->where('dp.DepartmentName','SALES');
        $this->db->where('em.BranchCode',$branch);
        // $this->db->where('em.TransStatus',1);

        $query = $this->db->get()->result();
        return $query;
    }

    function get_employee_code($EmployeeName,$branch){
        $this->db->select('em.EmployeeCode');
        $this->db->from($this->employee.' as em');
        $this->db->where('em.EmployeeName',trim($EmployeeName));
        $this->db->where('em.BranchCode',$branch);
        $this->db->limit(1);

        $query = $this->db->get();

        if($query->num_rows()>0){
            $row = $query->row();
            return $row->EmployeeCode;
        }else{
            return false;
        }
    }

}

/* End of file m_customer.php */
/* Location: ./application/models/m_customer.php */