<?php

class ACC extends mainController {

    public function __construct() {
        parent::__construct();
        $this->load->model('ACC');
    }

    public function landing() {
        $vars['pageName'] = 'Accounting';
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('accounting_sys');
        preg_match("/\/viewBankAccount$/", $_SERVER['REQUEST_URI'], $matches);
        $vars['IsAdding'] = count($matches) > 0 ? 1 : 0;
        //          $data = $this->_registry->common_scripts->correct_loc_qty_from_trans();
        //            echo"<pre>";print_r($data);
        //            echo'========================';
        //                  $data = $this->_registry->common_scripts->correct_main_prod_qty_from_loc();
        //            echo"<pre>";print_r($data);
        //            die();
        //        $inv_arr = array('invoices'=>array(
        //            array('Invoice_ID'=>1,'Customer_ID'=>3,'date_created'=>'2019-05-01 14:00:00',
        //                'products'=>array(
        //                    array('product_id'=>2,'quantity'=>4,'unit_price'=>'7000','uom_id'=>2),
        //                    array('product_id'=>5,'quantity'=>8,'unit_price'=>'12000','uom_id'=>1),
        //                )),
        //                   array('Invoice_ID'=>2,'Customer_ID'=>12,'date_created'=>'2019-05-01 16:30:00',
        //                'products'=>array(
        //                    array('product_id'=>14,'quantity'=>1,'unit_price'=>'30000','uom_id'=>2),
        //                    array('product_id'=>22,'quantity'=>6,'unit_price'=>'15000','uom_id'=>1),
        //                )
        //                )
        //        ));
        //        die(json_encode($inv_arr));
        //        $fill_rate=$this->_registry->jv->fill_second_rate();
        //        echo"<pre>";
        //        die(print_r($fill_rate));
        //        $vars['pay_arr'] = $this->_registry->jv->update_main_id_type();
        //        die();
        //        echo"<pre>";
        //        die(print_r($vars['pay_arr']));
        //        $update = $this->_registry->payment->reorderPayRecNum('2018-01-01', 1,1);
        //        //bakhour script
        //        $update = $this->_registry->expense->fix_negative_expenses();
        //        die(print_r($update));
        $vars['TypeOrg'] = $this->_registry->Organization->viewOrganizationTypes();
        $vars['EntityOrg'] = $this->_registry->Organization->viewOrganizationLegalEntity();
        $vars['Org_Info'] = $this->_registry->Organization->getOrganizationDetails();
        $vars['today'] = Date::getToday();
        $vars['CountryOrg'] = $this->_registry->countries->viewCountries();
        $vars['vattypes'] = $this->_registry->Organization->viewVATTypes();
        $vars['CanMakeMoreOrg'] = $this->_registry->Count->countRows('tbl_organization') == 0;
        //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC']];
        $vars['menu_blocks'] = array(
            array('msg' => 'organization_settings', 'prmsn' => 'Organization Settings', 'icon' => 'fa fa-cog'
                , 'detail' => array(
                    array('msg' => 'add_organization', 'prmsn' => 'addOrganization', 'mdl' => '#WizardModal', 'icon' => 'fa fa-plus-circle')
                    , array('msg' => 'view_organization', 'prmsn' => 'viewOrganization', 'lnk' => SITE_LINK . 'ACC/viewOrganization', 'icon' => 'fa fa-eye')
                    , array('msg' => 'edit_organization', 'prmsn' => 'amendOrganization', 'mdl' => '#EditModal2', 'icon' => 'fa fa-edit')
                    , array('msg' => 'currency_settings', 'prmsn' => 'CurrencySettings', 'lnk' => SITE_LINK . 'ACC/CurrencySettings', 'icon' => 'fa fa-money')
                    , array('msg' => 'cash_drawer_accounts', 'prmsn' => 'cash_drawer_accounts', 'lnk' => SITE_LINK . 'ACC/cash_drawer_accounts', 'icon' => 'fa fa-list')
                    , array('msg' => 'user_accounts', 'prmsn' => 'addUserAccounts', 'lnk' => SITE_LINK . 'ACC/UserAccAccounts', 'icon' => 'fa fa-list')
                    , array('msg' => 'org_branches', 'prmsn' => 'org_branches', 'lnk' => SITE_LINK . 'ACC/org_branches', 'icon' => 'fa fa-list')
                    , array('msg' => 'group_accounts', 'prmsn' => 'group_accounts', 'lnk' => SITE_LINK . 'ACC/group_accounts', 'icon' => 'fa fa-list')
                    , array('msg' => 'jobs', 'prmsn' => 'job_list', 'lnk' => SITE_LINK . 'ACC/job_list', 'icon' => 'fa fa-list')
                    , array('msg' => 'trans_types', 'prmsn' => 'trans_type_list', 'lnk' => SITE_LINK . 'ACC/trans_type_list', 'icon' => 'fa fa-list')
                    , array('msg' => 'family_accounts', 'prmsn' => 'family_accounts', 'lnk' => SITE_LINK . 'ACC/family_accounts', 'icon' => 'fa fa-list')
                    , array('msg' => 'financial_year', 'prmsn' => 'financial_year', 'lnk' => SITE_LINK . 'ACC/financial_year', 'icon' => 'fa fa-list')
                    , array('msg' => 'create_dynamic_report', 'prmsn' => 'create_dynamic_report', 'lnk' => SITE_LINK . 'ACC/create_dynamic_report', 'icon' => 'fa fa-list')
                    , array('msg' => 'dynamic_report_blocks', 'prmsn' => 'dynamic_report_blocks', 'lnk' => SITE_LINK . 'ACC/dynamic_report_blocks', 'icon' => 'fa fa-list')
                    , array('msg' => 'upload_image', 'prmsn' => 'upload_image', 'mdl' => '#upload_image_form', 'icon' => 'fa fa-edit')
                )
            ),
            array('msg' => 'COA', 'prmsn' => 'Chart of Accounts', 'icon' => 'fa fa-line-chart'
                , 'detail' => array(
                    array('msg' => 'library_COA', 'prmsn' => 'viewlibrary', 'lnk' => SITE_LINK . 'ACC/viewlibrary', 'icon' => 'fa fa-book')
                    , array('msg' => 'organization_COA', 'prmsn' => 'viewlibrary/1', 'lnk' => SITE_LINK . 'ACC/viewlibrary/1', 'icon' => 'fa fa-sitemap')
                    , array('msg' => 'bank_account', 'prmsn' => 'viewBankAccount', 'lnk' => SITE_LINK . 'ACC/viewBankAccount', 'icon' => 'fa fa-bank')
                    , array('msg' => 'close_vat', 'prmsn' => 'closeVAT', 'lnk' => SITE_LINK . 'ACC/closeVAT', 'icon' => 'fa fa-times-circle')
                    , array('msg' => 'close_year', 'prmsn' => 'closeYear', 'lnk' => SITE_LINK . 'ACC/closeYear', 'icon' => 'fa fa-times')
                    , array('msg' => 'close_year_actual', 'prmsn' => 'closeYearActual', 'lnk' => SITE_LINK . 'ACC/closeYear/act', 'icon' => 'fa fa-dollar')
                    , array('msg' => 'exchange_rate', 'prmsn' => 'currencyExchangeRate', 'lnk' => SITE_LINK . 'ACC/currencyExchangeRate', 'icon' => 'fa fa-exchange')
                    , array('msg' => 'exchange_rate_actual', 'prmsn' => 'currencyExchangeRateActual', 'lnk' => SITE_LINK . 'ACC/currencyExchangeRate/act', 'icon' => 'fa fa-dollar')
                //                    , array('msg' => 'merge_accounts', 'prmsn' => 'mergeAccounts', 'lnk' => SITE_LINK . 'ACC/mergeAccounts', 'icon' => 'fa fa-edit')
                )
            ),
            array('msg' => 'payment_account', 'prmsn' => 'Payment Account', 'icon' => 'fa fa-money'
                , 'detail' => array(
                    array('msg' => 'payments', 'prmsn' => 'PaymentList', 'lnk' => SITE_LINK . 'ACC/PaymentList', 'icon' => 'fa fa-usd')
                    , array('msg' => 'actual_payments', 'prmsn' => 'ActualPaymentList', 'lnk' => SITE_LINK . 'ACC/PaymentList/act', 'icon' => 'fa fa-archive')
                    //                    , array('msg' => 'contra', 'prmsn' => 'ContraList', 'lnk' => SITE_LINK . 'ACC/ContraList', 'icon' => 'fa fa-contao')
                    , array('msg' => 'receipt', 'prmsn' => 'ReceiptList', 'lnk' => SITE_LINK . 'ACC/PaymentList/Receipt', 'icon' => 'fa fa-list')
                    , array('msg' => 'actual_receipt', 'prmsn' => 'ActualReceiptList', 'lnk' => SITE_LINK . 'ACC/PaymentList/Receipt/act', 'icon' => 'fa fa-eye')
                    , array('msg' => 'payment_due_dates', 'prmsn' => 'paymentDueDates', 'lnk' => SITE_LINK . 'ACC/paymentDueDates', 'icon' => 'fa fa-eye')
                    , array('msg' => 'receipt_due_dates', 'prmsn' => 'receiptDueDates', 'lnk' => SITE_LINK . 'ACC/paymentDueDates/Receipt', 'icon' => 'fa fa-eye')
                    , array('msg' => 'act_payment_due_dates', 'prmsn' => 'ActualpaymentDueDates', 'lnk' => SITE_LINK . 'ACC/paymentDueDates/act', 'icon' => 'fa fa-eye')
                    , array('msg' => 'act_receipt_due_dates', 'prmsn' => 'ActualreceiptDueDates', 'lnk' => SITE_LINK . 'ACC/paymentDueDates/Receipt/act', 'icon' => 'fa fa-eye')
                    , array('msg' => 'check_due_dates', 'prmsn' => 'check_due_dates_report', 'lnk' => SITE_LINK . 'ACC/check_due_dates_report', 'icon' => 'fa fa-eye')
                    , array('msg' => 'act_check_due_dates', 'prmsn' => 'act_check_due_dates_report', 'lnk' => SITE_LINK . 'ACC/check_due_dates_report/act', 'icon' => 'fa fa-eye')
                    , array('msg' => 'schedule_bills', 'prmsn' => 'new_schedule_bills', 'lnk' => SITE_LINK . 'ACC/schedule_bills', 'icon' => 'fa fa-plus'),
                    array('msg' => 'schedule_bills_list', 'prmsn' => 'schedule_bills_list', 'lnk' => SITE_LINK . 'ACC/schedule_bills_list', 'icon' => 'fa fa-list'),
                    array('msg' => 'payment_due_date_bills', 'prmsn' => 'payment_due_date_bills', 'lnk' => SITE_LINK . 'ACC/payment_due_date_bills', 'icon' => 'fa fa-dollar')
                    , array('msg' => 'collection_list', 'prmsn' => 'collection_list', 'lnk' => SITE_LINK . 'ACC/collection_list', 'icon' => 'fa fa-dollar')
                    , array('msg' => 'act_collection_list', 'prmsn' => 'act_collection_list', 'lnk' => SITE_LINK . 'ACC/collection_list/act', 'icon' => 'fa fa-dollar')
                )
            ),
            array('msg' => 'return_payment_receipt', 'prmsn' => 'return_payment_receipt', 'icon' => 'fa fa-money'
                , 'detail' => array(
                    array('msg' => 'return_payment_list', 'prmsn' => 'return_payment_list', 'lnk' => SITE_LINK . 'ACC/PaymentList/return', 'icon' => 'fa fa-list'),
                    array('msg' => 'actual_return_payment_list', 'prmsn' => 'actual_return_payment_list', 'lnk' => SITE_LINK . 'ACC/PaymentList/return/act', 'icon' => 'fa fa-list'),
                    array('msg' => 'return_receipt_list', 'prmsn' => 'return_receipt_list', 'lnk' => SITE_LINK . 'ACC/PaymentList/Receipt/return', 'icon' => 'fa fa-list'),
                    array('msg' => 'actual_return_receipt_list', 'prmsn' => 'actual_return_receipt_list', 'lnk' => SITE_LINK . 'ACC/PaymentList/Receipt/return/act', 'icon' => 'fa fa-list'),
                )
            ),
            array('msg' => 'expenditures', 'prmsn' => 'Expenses', 'icon' => 'fa fa-calculator'
                , 'detail' => array(
                    array('msg' => 'expenditures', 'prmsn' => 'ExpensesList', 'lnk' => SITE_LINK . 'ACC/ExpensesList', 'icon' => 'fa fa-calculator')
                    , array('msg' => 'actual_expenditures', 'prmsn' => 'ExpensesListActual', 'lnk' => SITE_LINK . 'ACC/ExpensesList/act', 'icon' => 'fa fa-eye')
                    , array('msg' => 'pending_expenditures', 'prmsn' => 'pending_expense_list', 'lnk' => SITE_LINK . 'ACC/ExpensesList/pen', 'icon' => 'fa fa-eye')
                    , array('msg' => 'act_pending_expenditures', 'prmsn' => 'act_pending_expense_list', 'lnk' => SITE_LINK . 'ACC/ExpensesList/act/pen', 'icon' => 'fa fa-eye')
                    , array('msg' => 'cash_expenditures', 'prmsn' => 'cash_expense_list', 'lnk' => SITE_LINK . 'ACC/ExpensesList/cash', 'icon' => 'fa fa-calculator')
                    , array('msg' => 'actual_cash_expenditures', 'prmsn' => 'act_cash_expense_list', 'lnk' => SITE_LINK . 'ACC/ExpensesList/act/cash', 'icon' => 'fa fa-eye')
                    , array('msg' => 'pending_cash_expenditures', 'prmsn' => 'pending_cash_expense_list', 'lnk' => SITE_LINK . 'ACC/ExpensesList/pen/cash', 'icon' => 'fa fa-eye')
                    , array('msg' => 'act_pending_cash_expenditures', 'prmsn' => 'act_pending_cash_expense_list', 'lnk' => SITE_LINK . 'ACC/ExpensesList/act/pen/cash', 'icon' => 'fa fa-eye')
                )
            ),
            array('msg' => 'record_jv', 'prmsn' => 'JV', 'icon' => 'fa fa-calendar-plus-o'
                , 'detail' => array(
                    array('msg' => 'add_jv', 'prmsn' => 'addJV', 'lnk' => SITE_LINK . 'ACC/addJV', 'icon' => 'fa fa-cog')
                    , array('msg' => 'add_actual_jv', 'prmsn' => 'addJVActual', 'lnk' => SITE_LINK . 'ACC/addJV/act', 'icon' => 'fa fa-cog')
                    , array('msg' => 'manual_jv_list', 'prmsn' => 'manual_jv_list', 'lnk' => SITE_LINK . 'ACC/manual_jv_list', 'icon' => 'fa fa-cog')
                    , array('msg' => 'actual_manual_jv_list', 'prmsn' => 'actual_manual_jv_list', 'lnk' => SITE_LINK . 'ACC/manual_jv_list/act', 'icon' => 'fa fa-cog')
                    , array('msg' => 'reorder_jv', 'prmsn' => 'reorder_jv', 'lnk' => SITE_LINK . 'ACC/reorder_jv', 'icon' => 'fa fa-cog')
                    , array('msg' => 'reorder_actual_jv', 'prmsn' => 'reorder_actual_jv', 'lnk' => SITE_LINK . 'ACC/reorder_jv/act', 'icon' => 'fa fa-cog')
                    , array('msg' => 'deposit_withdrawal', 'prmsn' => 'viewDepositeWithDrawal', 'lnk' => SITE_LINK . 'ACC/viewDepositeWithDrawal', 'icon' => 'fa fa-th-large')
                    , array('msg' => 'actual_deposit_withdrawal', 'prmsn' => 'viewDepositeWithDrawalActual', 'lnk' => SITE_LINK . 'ACC/viewDepositeWithDrawal/act', 'icon' => 'fa fa-th-large')
                )
            ),
            array('msg' => 'pre_payments_accruals', 'prmsn' => '', 'icon' => 'fa fa-calendar-plus-o'
                , 'detail' => array(
                    array('msg' => 'prepaid_expenses', 'prmsn' => 'viewPrepaidExpense', 'lnk' => SITE_LINK . 'ACC/viewPrepaidExpense', 'icon' => 'fa fa-list')
                    , array('msg' => 'prepaid_expenses_actual', 'prmsn' => 'viewPrepaidExpenseActual', 'lnk' => SITE_LINK . 'ACC/viewPrepaidExpense/act', 'icon' => 'fa fa-money')
                    , array('msg' => 'prepaid_income', 'prmsn' => 'viewPrepaidIncome', 'lnk' => SITE_LINK . 'ACC/viewPrepaidExpense/Income', 'icon' => 'fa fa-list-alt')
                    , array('msg' => 'prepaid_income_actual', 'prmsn' => 'viewPrepaidIncomeActual', 'lnk' => SITE_LINK . 'ACC/viewPrepaidExpense/Income/act', 'icon' => 'fa fa-list-alt')
                    , array('msg' => 'accrued_expenses', 'prmsn' => 'viewAccruedExpense', 'lnk' => SITE_LINK . 'ACC/viewAccruedExpense', 'icon' => 'fa fa-eye')
                    , array('msg' => 'accrued_expenses_actual', 'prmsn' => 'viewAccruedExpenseActual', 'lnk' => SITE_LINK . 'ACC/viewAccruedExpense/act', 'icon' => 'fa fa-eye')
                )
            ),
            array('msg' => 'credit_debit_note', 'prmsn' => 'ReturnNote', 'icon' => 'fa fa-exclamation-triangle'
                , 'detail' => array(
                    array('msg' => 'credit_note', 'prmsn' => 'CreditNote', 'lnk' => SITE_LINK . 'ACC/DebitNote', 'icon' => 'fa fa-arrow-right')
                    , array('msg' => 'credit_list', 'prmsn' => 'CreditList', 'lnk' => SITE_LINK . 'ACC/DebitList', 'icon' => 'fa fa-eye')
                    , array('msg' => 'debit_note', 'prmsn' => 'DebitNote', 'lnk' => SITE_LINK . 'ACC/DebitNote/vendor', 'icon' => 'fa fa-arrow-left')
                    , array('msg' => 'debit_list', 'prmsn' => 'DebitList', 'lnk' => SITE_LINK . 'ACC/DebitList/vendor', 'icon' => 'fa fa-eye')
                    , array('msg' => 'actual_credit_note', 'prmsn' => 'ActualCreditNote', 'lnk' => SITE_LINK . 'ACC/DebitNote/act', 'icon' => 'fa fa-arrow-right')
                    , array('msg' => 'actual_credit_list', 'prmsn' => 'ActualCreditList', 'lnk' => SITE_LINK . 'ACC/DebitList/act', 'icon' => 'fa fa-eye')
                    , array('msg' => 'actual_debit_note', 'prmsn' => 'ActualDebitNote', 'lnk' => SITE_LINK . 'ACC/DebitNote/act/vendor', 'icon' => 'fa fa-arrow-left')
                    , array('msg' => 'actual_debit_list', 'prmsn' => 'ActualDebitList', 'lnk' => SITE_LINK . 'ACC/DebitList/act/vendor', 'icon' => 'fa fa-eye')
                )
            ),
            array('msg' => 'report', 'prmsn' => 'ReportAcc', 'icon' => 'fa fa-search-plus'
                , 'detail' => array(
                    array('msg' => 'daily_journals', 'prmsn' => 'DailyJournals', 'lnk' => SITE_LINK . 'ACC/dailyJVs', 'icon' => 'fa fa-list')
                    , array('msg' => 'customer_aging_report', 'prmsn' => 'accountStatement', 'lnk' => SITE_LINK . 'ACC/aging_report/cust', 'icon' => 'flaticon-gold3')
                    , array('msg' => 'supplier_aging_report', 'prmsn' => 'suppliersAgingReport', 'lnk' => SITE_LINK . 'ACC/aging_report', 'icon' => 'flaticon-wallet19')
                    , array('msg' => 'customer_aging_report_bydate', 'prmsn' => 'accountStatement', 'lnk' => SITE_LINK . 'ACC/aging_report_bydate/cust', 'icon' => 'flaticon-gold3')
                    , array('msg' => 'supplier_aging_report_bydate', 'prmsn' => 'suppliersAgingReport', 'lnk' => SITE_LINK . 'ACC/aging_report_bydate', 'icon' => 'flaticon-wallet19')
                    , array('msg' => 'exchange_rate_list', 'prmsn' => 'ExchangeRateList', 'lnk' => SITE_LINK . 'ACC/ExchangeRateList', 'icon' => 'flaticon-cash12')
                    , array('msg' => 'expense_report', 'prmsn' => 'expenseReport', 'lnk' => SITE_LINK . 'ACC/expenseReport', 'icon' => 'flaticon-cash12')
                    , array('msg' => 'fixed_assets_register', 'prmsn' => 'FixedAssetsRegister', 'lnk' => SITE_LINK . 'ACC/FixedAssetsRegister', 'icon' => 'fa fa-dollar')
                    , array('msg' => 'top_supp_list', 'prmsn' => 'topSuppliers', 'lnk' => SITE_LINK . 'ACC/topSuppliers', 'icon' => 'fa fa-dollar')
                    , array('msg' => 'top_cust_list', 'prmsn' => 'topCustomers', 'lnk' => SITE_LINK . 'ACC/topCustomers', 'icon' => 'fa fa-dollar')
                    , array('msg' => 'vat_report', 'prmsn' => 'customer_supplier_vat_report', 'lnk' => SITE_LINK . 'ACC/customer_supplier_vat_report', 'icon' => 'fa fa-dollar')
                    , array('msg' => 'view_dynamic_report', 'prmsn' => 'view_dynamic_report', 'lnk' => SITE_LINK . 'ACC/view_dynamic_report', 'icon' => 'fa fa-dollar')
                )
            ),
            array('msg' => 'financial_statements', 'prmsn' => 'ReportAcc', 'icon' => 'fa fa-bars'
                , 'detail' => array(
                    array('msg' => 'view_general_ledger', 'prmsn' => 'ledger', 'lnk' => SITE_LINK . 'ACC/ledger', 'icon' => 'flaticon-scale15')
                    , array('msg' => 'customer_supplier_general_ledger', 'prmsn' => 'customer_supplier_general_ledger', 'lnk' => SITE_LINK . 'ACC/ledger/cust_supp', 'icon' => 'flaticon-scale15')
                    , array('msg' => 'gl_multi', 'prmsn' => 'ledgerMultiAccounts', 'lnk' => SITE_LINK . 'ACC/ledgerMultiAccounts', 'icon' => 'flaticon-scale15')
                    , array('msg' => 'trial_balance', 'prmsn' => 'trialBalance', 'lnk' => SITE_LINK . 'ACC/trialBalance', 'icon' => 'fa fa-table')
                    //                    , array('msg' => 'current_trial_balance', 'prmsn' => 'trialBalanceV2', 'lnk' => SITE_LINK . 'ACC/trialBalanceV2', 'icon' => 'flaticon-business156')
                    , array('msg' => 'statement_of_income', 'prmsn' => 'IncomeStatement', 'lnk' => SITE_LINK . 'ACC/statementOfIncome', 'icon' => 'fa fa-dollar')
                    , array('msg' => 'statement_financial_position', 'prmsn' => 'BalanceSheet', 'lnk' => SITE_LINK . 'ACC/stmtFinancialPosition', 'icon' => 'flaticon-dollar149')
                )
            ),
            array('msg' => 'actual_reports', 'prmsn' => 'ActualReports', 'icon' => 'fa fa-bars'
                , 'detail' => array(
                    array('msg' => 'act_cust_aging_report', 'prmsn' => 'ActualCustomersAgingReport', 'lnk' => SITE_LINK . 'ACC/aging_report/cust/act', 'icon' => 'fa fa-file-text')
                    , array('msg' => 'act_sup_aging_report', 'prmsn' => 'ActualSuppliersAgingReport', 'lnk' => SITE_LINK . 'ACC/aging_report/act', 'icon' => 'fa fa-file-text')
                    , array('msg' => 'act_cust_aging_report_bydate', 'prmsn' => 'ActualCustomersAgingReport', 'lnk' => SITE_LINK . 'ACC/aging_report_bydate/cust/act', 'icon' => 'fa fa-file-text')
                    , array('msg' => 'act_sup_aging_report_bydate', 'prmsn' => 'ActualSuppliersAgingReport', 'lnk' => SITE_LINK . 'ACC/aging_report_bydate/act', 'icon' => 'fa fa-file-text')
                    , array('msg' => 'actual_general_ledger', 'prmsn' => 'ActualLedger', 'lnk' => SITE_LINK . 'ACC/ledger/act', 'icon' => 'fa fa-eye')
                    , array('msg' => 'gl_multi_actual', 'prmsn' => 'ledgerMultiAccountsActual', 'lnk' => SITE_LINK . 'ACC/ledgerMultiAccounts/act', 'icon' => 'flaticon-scale15')
                    , array('msg' => 'actual_trial_balance', 'prmsn' => 'ActualTrialBalance', 'lnk' => SITE_LINK . 'ACC/trialBalance/act', 'icon' => 'fa fa-table')
                    , array('msg' => 'expense_report_actual', 'prmsn' => 'expenseReportActual', 'lnk' => SITE_LINK . 'ACC/expenseReport/act', 'icon' => 'flaticon-cash12')
                    //                    , array('msg' => 'act_current_trial_balance', 'prmsn' => 'ActualTrialBalanceV2', 'lnk' => SITE_LINK . 'ACC/ActualTrialBalanceV2', 'icon' => 'fa fa-table')
                    , array('msg' => 'act_daily_journals', 'prmsn' => 'ActualDailyJournals', 'lnk' => SITE_LINK . 'ACC/dailyJVs/act', 'icon' => 'fa fa-list')
                    , array('msg' => 'act_statement_of_income', 'prmsn' => 'ActualIncomeStatement', 'lnk' => SITE_LINK . 'ACC/statementOfIncome/act', 'icon' => 'fa fa-dollar')
                    , array('msg' => 'act_balance_sheet', 'prmsn' => 'ActualBalanceSheet', 'lnk' => SITE_LINK . 'ACC/stmtFinancialPosition/act', 'icon' => 'fa fa-dollar')
                    , array('msg' => 'act_fixed_assets_register', 'prmsn' => 'FixedAssetsRegisterActual', 'lnk' => SITE_LINK . 'ACC/FixedAssetsRegister/act', 'icon' => 'fa fa-dollar')
                )
            ),
            array('msg' => 'jobs', 'prmsn' => 'jobs', 'icon' => 'fa fa-bars'
                , 'detail' => array(
                    array('msg' => 'statament_of_job', 'prmsn' => 'job_report', 'lnk' => SITE_LINK . 'ACC/statament_of_job', 'icon' => 'fa fa-list')
                    , array('msg' => 'actual_statament_of_job', 'prmsn' => 'actual_job_report', 'lnk' => SITE_LINK . 'ACC/statament_of_job/act', 'icon' => 'fa fa-list')
                    , array('msg' => 'job_trial_balance', 'prmsn' => 'job_trial_balance', 'lnk' => SITE_LINK . 'ACC/job_trial_balance', 'icon' => 'flaticon-scale15')
                    , array('msg' => 'act_job_trial_balance', 'prmsn' => 'act_job_trial_balance', 'lnk' => SITE_LINK . 'ACC/job_trial_balance/act', 'icon' => 'flaticon-scale15')
                )
            ),
            array('msg' => 'projects', 'prmsn' => 'projects', 'icon' => 'fa fa-bars'
                , 'detail' => array(
                    array('msg' => 'projects', 'prmsn' => 'project_list', 'lnk' => SITE_LINK . 'ACC/project_list', 'icon' => 'fa fa-list'),
                    array('msg' => 'activity_tree', 'prmsn' => 'activity_tree', 'lnk' => SITE_LINK . 'ACC/activity_tree', 'icon' => 'fa fa-tree'),
                    array('msg' => 'project_period', 'prmsn' => 'project_period', 'lnk' => SITE_LINK . 'ACC/project_period', 'icon' => 'fa fa-list'),
                    array('msg' => 'activity_budget', 'prmsn' => 'activity_budget', 'lnk' => SITE_LINK . 'ACC/activity_budget', 'icon' => 'fa fa-plus'),
                    array('msg' => 'project_funding_list', 'prmsn' => 'project_funding_list', 'lnk' => SITE_LINK . 'ACC/project_funding_list', 'icon' => 'fa fa-list'),
                    array('msg' => 'project_expense_list', 'prmsn' => 'project_expense_list', 'lnk' => SITE_LINK . 'ACC/project_expense_list', 'icon' => 'fa fa-list'),
                    array('msg' => 'project_period_report', 'prmsn' => 'project_period_report', 'lnk' => SITE_LINK . 'ACC/project_period_report', 'icon' => 'fa fa-list'),
                    array('msg' => 'statament_of_project', 'prmsn' => 'statament_of_project', 'lnk' => SITE_LINK . 'ACC/statament_of_project', 'icon' => 'fa fa-list')
                    , array('msg' => 'act_statament_of_project', 'prmsn' => 'act_statament_of_project', 'lnk' => SITE_LINK . 'ACC/statament_of_project/act', 'icon' => 'fa fa-list')
                    , array('msg' => 'project_trial_balance', 'prmsn' => 'project_trial_balance', 'lnk' => SITE_LINK . 'ACC/project_trial_balance', 'icon' => 'flaticon-scale15')
                    , array('msg' => 'act_project_trial_balance', 'prmsn' => 'act_project_trial_balance', 'lnk' => SITE_LINK . 'ACC/project_trial_balance/act', 'icon' => 'flaticon-scale15')
                    , array('msg' => 'statement_activity', 'prmsn' => 'statement_activity', 'lnk' => SITE_LINK . 'ACC/statement_activity', 'icon' => 'flaticon-scale15')
                    , array('msg' => 'act_statement_activity', 'prmsn' => 'act_statement_activity', 'lnk' => SITE_LINK . 'ACC/statement_activity/act', 'icon' => 'flaticon-scale15')
                    , array('msg' => 'activity_trial_balance', 'prmsn' => 'activity_trial_balance', 'lnk' => SITE_LINK . 'ACC/activity_trial_balance', 'icon' => 'flaticon-scale15')
                    , array('msg' => 'act_activity_trial_balance', 'prmsn' => 'act_activity_trial_balance', 'lnk' => SITE_LINK . 'ACC/activity_trial_balance/actu', 'icon' => 'flaticon-scale15')
                    , array('msg' => 'project_activities_report', 'prmsn' => 'project_activities_report', 'lnk' => SITE_LINK . 'ACC/project_activities_report', 'icon' => 'flaticon-scale15')
                    , array('msg' => 'act_project_activities_report', 'prmsn' => 'act_project_activities_report', 'lnk' => SITE_LINK . 'ACC/project_activities_report/act', 'icon' => 'flaticon-scale15'),
                    array('msg' => 'statement_of_project_per_activity', 'prmsn' => 'statement_of_project_per_activity', 'lnk' => SITE_LINK . 'ACC/statament_of_project/atv', 'icon' => 'fa fa-list')
                    , array('msg' => 'act_statement_of_project_per_activity', 'prmsn' => 'act_statement_of_project_per_activity', 'lnk' => SITE_LINK . 'ACC/statament_of_project/atv/act', 'icon' => 'fa fa-list'),
                    array('msg' => 'activity_daily_journal', 'prmsn' => 'activity_daily_journal', 'lnk' => SITE_LINK . 'ACC/dailyJVs/atv', 'icon' => 'fa fa-list'),
                    array('msg' => 'act_activity_daily_journal', 'prmsn' => 'act_activity_daily_journal', 'lnk' => SITE_LINK . 'ACC/dailyJVs/atv/act', 'icon' => 'fa fa-list')
                )
            ),
            array('msg' => 'pos_customer_report', 'prmsn' => 'pos_customer_report', 'icon' => 'fa fa-bars'
                , 'detail' => array(
                    array('msg' => 'statement_pos_customer', 'prmsn' => 'statement_pos_customer', 'lnk' => SITE_LINK . 'ACC/statement_pos_customer', 'icon' => 'fa fa-list')
                    , array('msg' => 'act_statement_pos_customer', 'prmsn' => 'act_statement_pos_customer', 'lnk' => SITE_LINK . 'ACC/statement_pos_customer/act', 'icon' => 'fa fa-list')
                    , array('msg' => 'pos_customer_trial_balance', 'prmsn' => 'pos_customer_trial_balance', 'lnk' => SITE_LINK . 'ACC/pos_customer_trial_balance', 'icon' => 'flaticon-scale15')
                    , array('msg' => 'act_pos_customer_trial_balance', 'prmsn' => 'act_pos_customer_trial_balance', 'lnk' => SITE_LINK . 'ACC/pos_customer_trial_balance/act', 'icon' => 'flaticon-scale15')
                )
            ),
        );
        $reports = $this->_registry->CommonACC->get_menu_dynamic_reports();
        if (!empty($reports)) {
            $details = array();
            $details_act = array();
            foreach ($reports as $report_id => $report_name) {
                $details[] = array('msg' => $report_name, 'prmsn' => 'dynamic_reports',
                    'lnk' => SITE_LINK . 'ACC/view_dynamic_report/' . $report_id, 'icon' => 'fa fa-dollar');
                $details_act[] = array('msg' => $report_name, 'prmsn' => 'act_dynamic_reports',
                    'lnk' => SITE_LINK . 'ACC/view_dynamic_report/act/' . $report_id, 'icon' => 'fa fa-dollar');
            }
            $vars['menu_blocks'][] = array('msg' => 'dynamic_reports', 'prmsn' => 'dynamic_reports', 'icon' => 'fa fa-bars'
                , 'detail' => $details
            );
            $vars['menu_blocks'][] = array('msg' => 'act_dynamic_reports', 'prmsn' => 'act_dynamic_reports', 'icon' => 'fa fa-bars'
                , 'detail' => $details_act
            );
        }
        $this->load->view('ACC', $vars);
    }

    public function viewlibrary() {
        $url = explode('/', $_SERVER['REQUEST_URI']);
        $vars['is_number'] = $url[count($url) - 1];
        $vars['pageName'] = $vars['is_number'] == '1' ? 'viewlibrary/1' : 'viewlibrary';
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('accounting_sys');
        $vars['currency_list'] = $this->_registry->currency->getAllCurrencies();
        $vars['local_currency'] = $this->_registry->currencyfactory->returnLocalCurrency();
        $vars['Language'] = Session::getUserPreferences();
        $vars['RET'] = $this->_registry->Organization->viewCOA(0, 1);
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('COA'), $vars['is_number'] == '1' ? 'viewlibrary/1' : 'viewlibrary']];
        $this->load->view('Accounting/viewlibrary', $vars);
    }

    //    public function expenses() {
    //
    //        $pageName = 'expenses';
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('expenses');
    //        $this->load->view('expenses', $vars);
    //    }

    public function ledger() {
        $vars['system_name'] = ACCModel::getmsg('general_ledger');
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match_act);
        $vars['is_actual'] = count($match_act) > 0 ? 1 : 0;

        preg_match("/\/cust_supp/", $_SERVER['REQUEST_URI'], $match_cust_supplier);
        preg_match("/\/is_pop/", $_SERVER['REQUEST_URI'], $match_pop_up);
        $vars['is_customer_supplier'] = count($match_cust_supplier) > 0 ? 1 : 0;

        $vars['title'] = ACCModel::getmsg($vars['is_customer_supplier'] ? 'customer_supplier_general_ledger' : ( $vars['is_actual'] ? 'actual_general_ledger' : 'general_ledger'));

        $url = explode('/', $_SERVER['REQUEST_URI']);
        //        if ($vars['is_actual']) {
        //            preg_match("/\/ledger\/act\/(\d+|(.*))$/", $_SERVER['REQUEST_URI'], $matches);
        //        } else {
        //            preg_match("/\/ledger\/(\d+|(.*))$/", $_SERVER['REQUEST_URI'], $matches);
        //        }
        $vars['pageName'] = $vars['is_customer_supplier'] ? 'customer_supplier_general_ledger' : ($vars['is_actual'] ? 'ActualLedger' : 'ledger');
        $vars['users'] = CommonFunctions::CommonView('tbl_common_users');
        $vars['Account_ID'] = is_numeric($url[count($url) - 1]) ? $url[count($url) - 1] : 0;
        //        echo $url[count($url) - 1];
        //        die($vars['Account_ID']);
        $vars['account_name'] = $vars['Account_ID'] > 0 ? $this->_registry->report->returnAccountName($vars['Account_ID']) : '';
        $vars['Ismatches'] = $vars['Account_ID'] > 0 ? true : false;
        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
        $vars['defCurrencyName'] = $this->_registry->currency->getCurrencyNameByID($defCurrency_Id);
        $vars['today'] = Date::getToday();
        //        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today
        $vars['from_day'] = smc_session()['start_date']; //$vars['year'] . '-01-01';
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg($vars['is_customer_supplier'] ? 'customer_supplier_general_ledger' : ($vars['is_actual'] ? 'actual_general_ledger' : 'general_ledger')), $vars['is_customer_supplier'] ? 'ledger/customer_supplier' : ($vars['is_actual'] ? 'ledger/act' : 'ledger')]];
        $this->load->view('Accounting/ledger', $vars);
    }

    public function aging_report() {

        $vars['system_name'] = ACCModel::getmsg('account_statement');
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match_act);
        $vars['is_actual'] = count($match_act) > 0 ? 1 : 0;
        preg_match("/\/cust/", substr($_SERVER['REQUEST_URI'],6), $match_act);
        $vars['is_customer'] = count($match_act) > 0 ? 1 : 0;
        $vars['pageName'] = $vars['is_customer'] ? ($vars['is_actual'] ? 'ActualCustomersAgingReport' : 'accountStatement') : ($vars['is_actual'] ? 'ActualSuppliersAgingReport' : 'suppliersAgingReport');
        $vars['title'] = CommonLanguage::getMessage($vars['is_customer'] ? ($vars['is_actual'] ? 'act_cust_aging_report' : 'customer_aging_report') : ($vars['is_actual'] ? 'act_sup_aging_report' : 'supplier_aging_report'));
        //accountStatement suppliersAgingReport act_cust_aging_report act_sup_aging_report
        //        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
        //        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
        //        $vars['result'] = $this->_registry->report->aging_report(['is_actual'=>0]);
        //        echo"<pre>";die(print_r($vars['result']));
        //        $vars['result'] = $this->_registry->report->agingReport();
        //        $vars['today'] = Date::getToday();
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [$vars['title'], 'aging_report' . ($vars['is_customer'] ? '/cust' : '') . ($vars['is_actual'] ? '/act' : '')]];
        $this->load->view('Accounting/aging_report', $vars);
    }

    public function aging_report_bydate() {

        $vars['system_name'] = ACCModel::getmsg('account_statement');
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match_act);
        $vars['is_actual'] = count($match_act) > 0 ? 1 : 0;
        preg_match("/\/cust/", $_SERVER['REQUEST_URI'], $match_act);
        $vars['is_customer'] = count($match_act) > 0 ? 1 : 0;
        $vars['pageName'] = $vars['is_customer'] ? ($vars['is_actual'] ? 'ActualCustomersAgingReport' : 'accountStatement') : ($vars['is_actual'] ? 'ActualSuppliersAgingReport' : 'suppliersAgingReport');
        $vars['title'] = CommonLanguage::getMessage($vars['is_customer'] ? ($vars['is_actual'] ? 'act_cust_aging_report_bydate' : 'customer_aging_report_bydate') : ($vars['is_actual'] ? 'act_sup_aging_report_bydate' : 'supplier_aging_report_bydate'));
        //accountStatement suppliersAgingReport act_cust_aging_report act_sup_aging_report
        //        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
        //        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
        //        $vars['result'] = $this->_registry->report->aging_report(['is_actual'=>0]);
        //        echo"<pre>";die(print_r($vars['result']));
        //        $vars['result'] = $this->_registry->report->agingReport();
        //        $vars['today'] = Date::getToday();
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [$vars['title'], 'aging_report_bydate' . ($vars['is_customer'] ? '/cust' : '') . ($vars['is_actual'] ? '/act' : '')]];
        $this->load->view('Accounting/aging_report_bydate', $vars);
    }

    //    public function accountStatement() {
    //        $vars['pageName'] = 'accountStatement';
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('account_statement');
    //        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
    //        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
    //        $vars['result'] = $this->_registry->report->aging_report(['is_actual'=>0]);
    //        echo"<pre>";die(print_r($vars['result']));
    ////        $vars['result'] = $this->_registry->report->agingReport();
    ////        $vars['today'] = Date::getToday();
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('account_statement'), 'accountStatement']];
    //        $this->load->view('Accounting/accountStatement', $vars);
    //    }
    //    public function payment() {
    //
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('payments');
    //        $this->load->view('Accounting/payment', $vars);
    //    }

    public function trialBalance() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('trial_balance');
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match);
        $vars['Is_Actual'] = count($match) > 0 ? "1" : "0";
        $defCurrency_Id = !empty($_GET['currency_id']) ? $_GET['currency_id'] : CurrencyFactory::getDefaultCurrency();
        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
        $vars['defCurrencyName'] = $this->_registry->currency->getCurrencyNameByID($defCurrency_Id);
        $vars['today'] = Date::getToday();
        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today 
        $vars['from_day'] = smc_session()['start_date']; //$vars['year'] . '-01-01';
        $vars['pageName'] = $vars['Is_Actual'] ? 'ActualTrialBalance' : 'trialBalance';
        $vars['account'] = !empty($_GET['account']) ? $_GET['account'] : '';
        $vars['from_date'] = !empty($_GET['from_date']) ? $_GET['from_date'] : '';
        $vars['to_date'] = !empty($_GET['to_date']) ? $_GET['to_date'] : '';

        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('trial_balance'), $vars['Is_Actual'] ? 'trialBalance/act' : 'trialBalance']];
        $this->load->view('Accounting/trialBalance', $vars);
    }

    //    public function trialBalanceV2() {
    //
    //        $vars['pageName'] = 'trialBalanceV2';
    //        $vars['title'] = 'Accounting System';
    //        $vars['system_name'] = ACCModel::getmsg('current_trial_balance');
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('current_trial_balance'), 'trialBalance']];
    //        $this->load->view('Accounting/trialBalanceV2', $vars);
    //    }

    public function ExpensesList() {

        $vars['system_name'] = ACCModel::getmsg('expenditures');
        $vars['today'] = Date::getToday();
        //        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match_a);
        $vars['is_actual'] = count($match_a) > 0 ? true : false;
        preg_match("/\/pen/", $_SERVER['REQUEST_URI'], $match_a);
        $vars['is_pending'] = count($match_a) > 0 ? 1 : 0;
        preg_match("/\/cash/", $_SERVER['REQUEST_URI'], $match_a);
        $vars['is_cash'] = count($match_a) > 0 ? 1 : 0;
        $vars['title'] = CommonLanguage::getMessage($vars['is_actual'] ? ($vars['is_pending'] == 1 ? ($vars['is_cash'] == 1 ? 'act_pending_cash_expenditures' : 'act_pending_expenditures') : ($vars['is_cash'] == 1 ? 'act_cash_expenditures' : 'add_act_expenditures')) : ($vars['is_pending'] == 1 ? ($vars['is_cash'] == 1 ? 'pending_cash_expenditures' : 'pending_expenditures') : ($vars['is_cash'] == 1 ? 'cash_expenditures' : 'expenditures')));
        $vars['from_date'] = '';
        $vars['to_date'] = '';
        preg_match("/\/daily/", $_SERVER['REQUEST_URI'], $match_a);
        if (count($match_a) > 0) {
            $vars['from_date'] = $vars['today'];
            $vars['to_date'] = $vars['today'];
        }
        preg_match("/\/monthly/", $_SERVER['REQUEST_URI'], $match_a);
        if (count($match_a) > 0) {
            $vars['from_date'] = date('Y-m-01', strtotime($vars['today']));
            $vars['to_date'] = date('Y-m-t', strtotime($vars['today']));
        }
        $vars['pageName'] = $vars['is_actual'] ? ($vars['is_pending'] == 1 ? ($vars['is_cash'] == 1 ? 'act_pending_cash_expense_list' : 'act_pending_expense_list') : ($vars['is_cash'] == 1 ? 'act_cash_expense_list' : 'ExpensesListActual')) : ($vars['is_pending'] == 1 ? ($vars['is_cash'] == 1 ? 'pending_cash_expense_list' : 'pending_expense_list') : ($vars['is_cash'] == 1 ? 'cash_expense_list' : 'ExpensesList'));
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [$vars['title'], 'ExpensesList' . ($vars['is_actual'] ? '/act' : '') . ($vars['is_pending'] == 1 ? '/pen' : '')]];
        $this->load->view('Accounting/ExpensesList', $vars);
    }

    public function add_expense() {
        $vars['system_name'] = ACCModel::getmsg('expenditures');
        $vars['today'] = Date::getToday();
        $url = explode('/', $_SERVER['REQUEST_URI']);
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match_a);
        $vars['IsEdit'] = (empty($_GET['is_pop']) ? is_numeric($url[count($url) - 1]) : is_numeric(explode("?", $url[count($url) - 1])[0])) ? true : false;
        if (!$vars['IsEdit']) {
//            $vars['unique_id'] = 'exp' . uniqid();
//            smc_session()['duplicate_check'][$vars['unique_id']] = true;
            $vars['unique_id'] = token_unique::generate_token('exp');
        }
        $vars['is_actual'] = count($match_a) > 0 ? true : false;
        preg_match("/\/pen/", $_SERVER['REQUEST_URI'], $match_a);
        $vars['is_pending'] = count($match_a) > 0 ? 1 : 0;
        preg_match("/\/cash/", $_SERVER['REQUEST_URI'], $match_a);
        $vars['is_cash'] = count($match_a) > 0 ? 1 : 0;
        $vars['title'] = ACCModel::getmsg($vars['is_actual'] ? ($vars['is_pending'] ? ($vars['is_cash'] ? 'act_pending_cash_expenditures' : 'act_pending_expenditures') : ($vars['is_cash'] ? 'actual_cash_expenditures' : 'actual_expenditures')) : ($vars['is_pending'] ? ($vars['is_cash'] ? 'pending_cash_expenditures' : 'pending_expenditures') : ($vars['is_cash'] ? 'cash_expenditures' : 'expenditures')));

        $vars['DefaultCurrencyID'] = $this->_registry->currency->getDefaultCurrency();
        $DefaultCurSymbol = CurrencyFactory::getDefaultCurrencySymbol();
        $DefaultCurName = $this->_registry->currency->getCurrencyNameByID($vars['DefaultCurrencyID']);
        $vars['currency_symbol'] = $DefaultCurName . ' -  ' . $DefaultCurSymbol;
        $vars['all_periods'] = $this->_registry->expense->viewDepreciationPeriod();
//        $vars['id'] = $vars['IsEdit'] ? $url[count($url) - 1] : 0;

        if (empty($_GET['is_pop'])) {
            $vars['id'] = $vars['IsEdit'] ? $url[count($url) - 1] : 0;
        } else {
            $vars['id'] = $vars['IsEdit'] ? explode("?", $url[count($url) - 1])[0] : 0;
        }



        $vars['CurList'] = CurrencyFactory::GetLIListCurrency();
        $vars['edit_data'] = $this->_registry->expense->getExpenseByID($vars['id']);
//        echo"<pre>";die(print_r($vars['edit_data']));
        $vars['check_lock'] = $vars['IsEdit'] ? CommonFunctions::check_lock_data(['type' => 'expense', 'start_date' => $vars['edit_data']['Main']['Expense_Date'], 'is_actual' => $vars['is_actual']]) : '';
        $vars['cash_supplier'] = Supplier::get_cash_supplier_acc();

        $vars['pageName'] = $vars['is_actual'] ? ($vars['is_pending'] ? ($vars['is_cash'] ? 'add_act_pending_cash_expense' : 'add_act_pending_expense') : ($vars['is_cash'] ? 'add_act_cash_expense' : 'addExpensesActual')) : ($vars['is_pending'] ? ($vars['is_cash'] ? 'add_pending_cash_expense' : 'add_pending_expense') : ($vars['is_cash'] ? 'add_cash_expense' : 'addExpenses'));
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [CommonLanguage::getMessage('expenditures'), 'ExpensesList' . ($vars['is_actual'] ? '/act' : '') . ($vars['is_pending'] ? '/pen' : '') . ($vars['is_cash'] ? '/cash' : '')], [$vars['title'], 'add_expense' . ($vars['is_actual'] ? '/act' : '') . ($vars['is_pending'] ? '/pen' : '') . ($vars['is_cash'] ? '/cash' : '')]];
        $this->load->view('Accounting/add_expense', $vars);
    }

    public function PaymentList() {
        $vars['system_name'] = ACCModel::getmsg('payments');
        preg_match("/\/Receipt/", $_SERVER['REQUEST_URI'], $match);
        $vars['IsReceipt'] = count($match) > 0 ? true : false;

        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match_actual);
        $vars['is_actual'] = count($match_actual) > 0 ? true : false;

        preg_match("/\/return/", $_SERVER['REQUEST_URI'], $match_return);
        $vars['is_return'] = count($match_return) > 0 ? true : false;

        $vars['title'] = ACCModel::getmsg(
                        $vars['is_return'] ?
                                ($vars['IsReceipt'] ? ($vars['is_actual'] ? 'actual_return_receipt_list' : 'return_receipt_list') : ($vars['is_actual'] ? 'actual_return_payment_list' : 'return_payment_list')) :
                                ($vars['IsReceipt'] ? ($vars['is_actual'] ? 'act_receipt_list' : 'receipt_list') : ($vars['is_actual'] ? 'act_payment_list' : 'payment_list')));
        $vars['today'] = Date::gettoday();
        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today
        $month = date("m", strtotime($vars['today'])); // get the month from today
        $vars['monthName'] = date("F", mktime(0, 0, 0, $month, 10)); // transform the month number to month name
        //                $vars['payment_accounts'] = $this->_registry->payment->viewNeededAccounts();
        $vars['pageName'] = $vars['is_return'] ?
                ($vars['is_actual'] ? ($vars['IsReceipt'] ? 'actual_return_receipt_list' : 'actual_return_payment_list') : ( $vars['IsReceipt'] ? 'return_receipt_list' : 'return_payment_list')) :
                ($vars['is_actual'] ? ($vars['IsReceipt'] ? 'ActualReceiptList' : 'ActualPaymentList') : ( $vars['IsReceipt'] ? 'ReceiptList' : 'PaymentList'));

        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'],
            [ACCModel::getmsg(
                        $vars['is_return'] ?
                                ($vars['is_actual'] ? ($vars['IsReceipt'] ? 'actual_return_receipt_list' : 'actual_return_payment_list') : ( $vars['IsReceipt'] ? 'return_receipt_list' : 'return_payment_list')) :
                                ($vars['is_actual'] ? ($vars['IsReceipt'] ? 'act_receipt_list' : 'act_payment_list') : ( $vars['IsReceipt'] ? 'receipt_list' : 'payment_list'))
                ), 'PaymentList' . ($vars['IsReceipt'] ? '/Receipt' : '') . ($vars['is_return'] ? '/return' : '') . ($vars['is_actual'] ? '/act' : '')]
        ];
        $this->load->view('Accounting/PaymentList', $vars);
    }

    public function addpayment() {
        $vars['system_name'] = ACCModel::getmsg('payments');
        $url = explode('/', $_SERVER['REQUEST_URI']);

        preg_match("/\/Receipt/", $_SERVER['REQUEST_URI'], $match);
        $vars['IsReceipt'] = count($match) > 0 ? true : false;

        preg_match("/\/return/", $_SERVER['REQUEST_URI'], $match_return);
        $vars['is_return'] = count($match_return) > 0 ? true : false;
        preg_match("/\/detail/", $_SERVER['REQUEST_URI'], $match_return);
        $vars['is_detail'] = count($match_return) > 0 ? true : false;

        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match_a);
        $vars['is_actual'] = count($match_a) > 0 ? true : false;
        //        echo $vars['is_return'] ? 'return' : 'not return';die();
        preg_match("/\/copy/", $_SERVER['REQUEST_URI'], $match_a);
        $vars['is_copy'] = count($match_a) > 0 ? true : false;
        preg_match("/\/collect/", $_SERVER['REQUEST_URI'], $match_a);
        $vars['is_collect'] = count($match_a) > 0 ? true : false;

        $vars['currency_list'] = $this->_registry->currency->getAllCurrencies();
        $vars['get_parameters'] = $_GET;
        $vars['today'] = Date::gettoday();
        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today
        $month = date("m", strtotime($vars['today'])); // get the month from today
        $vars['monthName'] = date("F", mktime(0, 0, 0, $month, 10)); // transform the month number to month name
        $vars['IsEdit'] = (empty($_GET['is_pop']) ? is_numeric($url[count($url) - 1]) : is_numeric(explode("?", $url[count($url) - 1])[0])) && !$vars['is_detail'] && !$vars['is_copy'] && !$vars['is_collect'] ? true : false;
        $vars['detail_id'] = !$vars['IsEdit'] && ($vars['is_detail'] || $vars['is_collect']) ? $url[count($url) - 1] : 0;
        if (!$vars['IsEdit']) {
//            $vars['unique_id'] = 'pay' . uniqid();
//            smc_session()['duplicate_check'][$vars['unique_id']] = true;
            $vars['unique_id'] = token_unique::generate_token('pay');
        }
        //        $status = $vars['is_actual'] = count($match_a) > 0 ? 1 : 0;
        //        $is_receipt = count($match) > 0 ? 1 : 0;
        if (empty($_GET['is_pop'])) {
            $vars['id'] = $vars['IsEdit'] || $vars['is_copy'] ? $url[count($url) - 1] : 0;
        } else {
            $vars['id'] = $vars['IsEdit'] || $vars['is_copy'] ? explode("?", $url[count($url) - 1])[0] : 0;
        }

//                        echo $vars['detail_id'].'==='.$vars['id'].'===';die();
        $vars['prefix'] = $vars['IsEdit'] || $vars['is_copy'] ? $url[count($url) - 1] : '';
        $vars['edit_data'] = $vars['IsEdit'] || $vars['is_copy'] ? $this->_registry->payment->viewPaymentsByID($vars['id'], null, $vars['IsReceipt']) : array();
        $vars['edit_data'] = ($vars['is_detail'] || $vars['is_collect']) ? $this->_registry->payment->viewPaymentsByID(null, $vars['detail_id'], null /* $vars['IsReceipt'] */) : $vars['edit_data'];
        $vars['is_readonly'] = ($vars['IsEdit'] && !empty($vars['edit_data']['main']['receipt_detail_id'])) || ($vars['IsEdit'] && $vars['is_return'] && !empty($vars['edit_data']['main']['returned_detail_id'])) || ($vars['is_return'] && $vars['is_detail'] && !$vars['is_copy'] && !$vars['IsEdit']) || $vars['is_collect'] ? true : false;
//                        echo"<pre>";die(print_r($vars['edit_data']));
        $vars['is_main_transfer'] = $vars['IsEdit'] ? (empty($vars['edit_data']['payments'][0]['is_main_transfer']) ? 0 : 1) : 0;
        $vars['DefaultCurrencyID'] = $this->_registry->currency->getDefaultCurrency();
        $DefaultCurSymbol = CurrencyFactory::getDefaultCurrencySymbol();
        $DefaultCurName = $this->_registry->currency->getCurrencyNameByID($vars['DefaultCurrencyID']);
        $vars['currency_symbol'] = $DefaultCurName . ' ' . $DefaultCurSymbol;
        $vars['CurList'] = CurrencyFactory::GetLIListCurrency();
        $vars['payment_type'] = $this->_registry->payment->viewPaymentTypes();
        $vars['Extable'] = $this->_registry->currency->getExchangeRateTable();
        $vars['cash_customer'] = Customer::get_cash_customer_acc();
        $vars['templates'] = CommonFunctions::CommonView('tbl_print_template', ['template_key'], [$vars['IsReceipt'] ? 'receipt' : 'payment']);
        $vars['title'] = ACCModel::getmsg(
                        $vars['is_return'] ?
                                ($vars['IsReceipt'] ? ($vars['is_actual'] ? ($vars['IsEdit'] ? 'edit_actual_return_receipt' : 'add_actual_return_receipt') : ($vars['IsEdit'] ? 'edit_return_receipt' : 'add_return_receipt')) : ($vars['is_actual'] ? ($vars['IsEdit'] ? 'edit_actual_return_payment' : 'add_actual_return_payment') : ($vars['IsEdit'] ? 'edit_return_payment' : 'add_return_payment'))) :
                                ($vars['IsReceipt'] ? ($vars['is_actual'] ? ($vars['IsEdit'] ? 'edit_actual_receipt' : 'add_actual_receipt') : ($vars['IsEdit'] ? 'edit_receipt' : 'add_receipt')) : ($vars['is_actual'] ? ($vars['IsEdit'] ? 'edit_actual_payment' : 'add_act_payment') : ($vars['IsEdit'] ? 'edit_payment' : 'add_payment')))
                        //            $vars['is_actual'] ? ( $vars['IsReceipt'] ? 'actual_receipt' : 'actual_payment') : ( $vars['IsReceipt'] ? 'receipt' : 'payment')
        );
        $vars['check_lock'] = $vars['IsEdit'] ? CommonFunctions::check_lock_data(['type' => 'payment', 'start_date' => $vars['edit_data']['main']['payment_date'], 'is_actual' => ($vars['is_actual'] ? 1 : 0)]) : '';


        //        if ($vars['IsEdit'])
        //            $vars['pageName'] = $vars['is_actual'] ? ( $vars['IsReceipt'] ? 'EditReceiptActual' : 'EditPaymentActual') : ( $vars['IsReceipt'] ? 'EditReceipt' : 'amendPaymentAccount');
        //        else
        //            $vars['pageName'] = $vars['is_actual'] ? ( $vars['IsReceipt'] ? 'addActualReceipt' : 'addActualPayment') : ( $vars['IsReceipt'] ? 'addReceipt' : 'addPaymentAccount');
        $vars['pageName'] = $vars['is_return'] ?
                ($vars['IsReceipt'] ? ($vars['is_actual'] ? ($vars['IsEdit'] ? 'edit_actual_return_receipt' : 'add_actual_return_receipt') : ($vars['IsEdit'] ? 'edit_return_receipt' : 'add_return_receipt')) : ($vars['is_actual'] ? ($vars['IsEdit'] ? 'edit_actual_return_payment' : 'add_actual_return_payment') : ($vars['IsEdit'] ? 'edit_return_payment' : 'add_return_payment'))) :
                ($vars['IsReceipt'] ? ($vars['is_actual'] ? ($vars['IsEdit'] ? 'EditReceiptActual' : 'addActualReceipt') : ($vars['IsEdit'] ? 'EditReceipt' : 'addReceipt')) : ($vars['is_actual'] ? ($vars['IsEdit'] ? 'EditPaymentActual' : 'addActualPayment') : ($vars['IsEdit'] ? 'amendPaymentAccount' : 'addPaymentAccount')));
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'],
            [ACCModel::getmsg(
                        $vars['is_return'] ?
                                ($vars['is_actual'] ? ($vars['IsReceipt'] ? 'actual_return_receipt_list' : 'actual_return_payment_list') : ( $vars['IsReceipt'] ? 'return_receipt_list' : 'return_payment_list')) :
                                ($vars['is_actual'] ? ($vars['IsReceipt'] ? 'act_receipt_list' : 'act_payment_list') : ( $vars['IsReceipt'] ? 'receipt_list' : 'payment_list'))),
                'PaymentList' . ($vars['IsReceipt'] ? '/Receipt' : '') . ($vars['is_return'] ? '/return' : '') . ($vars['is_actual'] ? '/act' : '')
        ]];
        $this->load->view('Accounting/addpayment', $vars);
    }

    public function paymentDueDates() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('payments');
        $url = explode('/', $_SERVER['REQUEST_URI']);
        preg_match("/\/Receipt/", $_SERVER['REQUEST_URI'], $match);
        $vars['IsReceipt'] = count($match) > 0 ? true : false;
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match_a);
        $vars['is_actual'] = count($match_a) > 0 ? 1 : 0;
        $vars['currency_list'] = $this->_registry->currency->getAllCurrencies();
        $vars['pageName'] = $vars['is_actual'] ? ( $vars['IsReceipt'] ? 'ActualreceiptDueDates' : 'ActualpaymentDueDates') : ( $vars['IsReceipt'] ? 'receiptDueDates' : 'paymentDueDates');
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], $vars['is_actual'] ? ($vars['IsReceipt'] ? [ACCModel::getmsg('receipt_due_dates'), 'paymentDueDates/Receipt/act'] : [ACCModel::getmsg('payment_due_dates'), 'paymentDueDates/act']) : ($vars['IsReceipt'] ? [ACCModel::getmsg('receipt_due_dates'), 'paymentDueDates/Receipt'] : [ACCModel::getmsg('payment_due_dates'), 'paymentDueDates'])];
        $this->load->view('Accounting/paymentDueDates', $vars);
    }

    //    public function Contra() {
    //        $vars['pageName'] = 'Contra';
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('contra');
    //        $this->load->view('Accounting/Contra', $vars);
    //    }

    public function viewBankAccount() {
        $vars['pageName'] = 'viewBankAccount';
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('bank');
        $url = $_SERVER['REQUEST_URI'];
        preg_match("/\/viewBankAccount$/", $url, $matches);
        //         print_r($matches);
        $vars['IsAdding'] = count($matches) > 0 ? true : false;
        //        echo $vars['IsAdding'];
        $vars['num'] = intval(substr($url, strrpos($url, '/') + 1));
        //        $vars['id'] = $this->_registry->activity->getEventID($vars['num']);
        $vars['List'] = $this->_registry->bank->displayInfo('53');
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('view_bank_accounts'), 'viewBankAccount']];
        $this->load->view('Accounting/viewBankAccount', $vars);
    }

    //    public function ContraList() {
    ////        $data = $this->_registry->common_scripts->swap_local_second_rate();
    ////        echo"<pre>";die(print_r($data));
    //        $vars['pageName'] = 'ContraList';
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('contra');
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('contra_list'), 'ContraList']];
    //        $vars['today'] = Date::gettoday();
    //        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today
    //        $month = date("m", strtotime($vars['today'])); // get the month from today
    //        $vars['monthName'] = date("F", mktime(0, 0, 0, $month, 10)); // transform the month number to month name
    ////        $vars['payment_accounts'] = $this->_registry->payment->viewNeededAccounts();
    //        $vars['currency_list'] = $this->_registry->currency->getAllCurrencies();
    ////        $vars['contra_acocunts'] = $this->_registry->contra->returnAccounts();
    //        $vars['all_currencies'] = $this->_registry->currency->getAllCurrencies();
    //        $vars['CurrSymbol'] = CurrencyFactory::getDefaultCurrencySymbol();
    //        $this->load->view('Accounting/ContraList', $vars);
    //    }

    public function viewOrganization() {

        $vars['pageName'] = 'viewOrganization';
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('org_system');
        $vars['ListOrg'] = $this->_registry->Organization->getOrganizationDetails();
        $vars['ListHierarchy'] = $this->_registry->Organization->viewHierarchy();
        $vars['ListSahreHolder'] = $this->_registry->Organization->viewShareholders();
        $vars['defCurrencySymbol'] = CurrencyFactory::getLocalCurrencySymbol();
        if (file_exists(upload_path . 'org_logo/logo.png')) {
            $vars['file'] = upload_url . 'org_logo/logo.png';
        } else {
            $vars['file'] = SITE_LINK . 'img/logo_white.png';
        }
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('view_organization'), 'viewOrganization']];
        $this->load->view('Accounting/viewOrganization', $vars);
    }

    //    public function DailyJournals() {
    //        $vars['pageName'] = 'DailyJournals';
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('daily_journals');
    //        $vars['today'] = Date::getToday();
    //        $vars['jvList'] = $this->_registry->report->viewJVs();
    //        $vars['DailyList'] = $this->_registry->report->retrieveDailyJVsByRange($vars['today'], $vars['today']);
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('daily_journal'), 'DailyJournals']];
    //        $this->load->view('Accounting/DailyJournals', $vars);
    //    }
    //    public function EditExpenses() {
    //
    //        $vars['pageName'] = 'amendExpenses';
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('expenditures');
    //        preg_match('/\/(\d+)$/', $_SERVER['REQUEST_URI'], $match);
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('expenditures'), 'ExpensesList'], [ACCModel::getmsg('edit_expense'), 'EditExpenses/' . $match[1]]];
    //        $url = explode('/', $_SERVER['REQUEST_URI']);
    //        $vars['Expense_ID'] = $url[count($url) - 1];
    //        $vars['Viewexpenses_accounts'] = $this->_registry->expense->view(null, $vars['Expense_ID']);
    ////        echo"<pre>";
    ////        die(print_r($vars['Viewexpenses_accounts']));
    //        $this->load->view('Accounting/EditExpenses', $vars);
    //    }

    public function CurrencySettings() {
        $vars['pageName'] = 'CurrencySettings';
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('currency_settings');
        $vars['today'] = Date::gettoday();
        $vars['all_currencies'] = $this->_registry->currency->getAllCurrencies(false);
        $vars['DefaultCurrencyID'] = $this->_registry->currency->getDefaultCurrency();
        $vars['SecondCurrencyID'] = $this->_registry->currency->getSecondCurrency();
        $vars['CurrencyTable'] = $this->_registry->currency->getExchangeRateTable();
        //        echo"<pre>";die(print_r($vars['CurrencyTable']));
        $vars['CurrencyDefaultName'] = $this->_registry->currency->getCurrencyByID($vars['DefaultCurrencyID']);
        $vars['CurrencySecondName'] = $this->_registry->currency->getCurrencyByID($vars['SecondCurrencyID']);
        $vars['list'] = $this->_registry->currency->viewAllDeafultCurrency();
        $vars['number'] = $this->_registry->Count->countRows('tbl_default_currency');
        $vars['Is_Arabic'] = Session::getUserPreferences() == 'ar';
        $vars['list_curr'] = $this->_registry->currency->GetLIListCurrency();
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('currency_settings'), 'CurrencySettings']];
        $this->load->view('Accounting/CurrencySettings', $vars);
    }

    public function DebitNote() {

        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('note_sys');
        $vars['DefaultCurrencySymbol'] = CurrencyFactory::getDefaultCurrencySymbol();
        $vars['today'] = Date::gettoday();
        $vars['Cashes'] = $this->_registry->payment->getPaymentTypesByType('cash');
        $vars['Checks'] = $this->_registry->payment->getPaymentTypesByType('cheque');
        $vars['CreditCards'] = $this->_registry->payment->getPaymentTypesByType('credit_card');
        $url = explode('/', $_GET['url']);
        preg_match("/\/vendor/", $_SERVER['REQUEST_URI'], $match_vendor);
        $vars['IsVendor'] = count($match_vendor) > 0 ? true : false;
        $vars['logged_id'] = Session::getUserID();
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match_act);
        $vars['is_actual'] = count($match_act) > 0 ? 1 : 0;

        $vars['IsEdit'] = is_numeric($url[count($url) - 1]) ? true : false;
        if (!$vars['IsEdit']) {
//            $vars['unique_id'] = 'deb' . uniqid();
//            smc_session()['duplicate_check'][$vars['unique_id']] = true;
            $vars['unique_id'] = token_unique::generate_token('deb');
        }
        $vars['id'] = $vars['IsEdit'] ? $url[count($url) - 1] : 0;
        $vars['edit_arr'] = $vars['IsEdit'] ? $this->_registry->debitnote->getNoteByID($vars['id']) : array();
//                echo"<pre>";die(print_r($vars['edit_arr']));
        $vars['check_lock'] = $vars['IsEdit'] ? CommonFunctions::check_lock_data(['type' => 'note', 'start_date' => $vars['edit_arr']['Main']['Note_Date'], 'is_actual' => $vars['is_actual']]) : '';

        $vars['CurList'] = CurrencyFactory::GetLIListCurrency();
        $vars['DefaultCurrencyID'] = $this->_registry->currency->getDefaultCurrency();
        if ($vars['IsEdit'])
            $vars['pageName'] = $vars['IsVendor'] ? ($vars['is_actual'] ? 'EditActualDebitNote' : 'EditDebitNote' ) : ($vars['is_actual'] ? 'EditActualCreditNote' : 'EditCreditNote' );
        else
            $vars['pageName'] = $vars['IsVendor'] ? ($vars['is_actual'] ? 'ActualDebitNote' : 'DebitNote' ) : ($vars['is_actual'] ? 'ActualCreditNote' : 'CreditNote' );

        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('credit_debit_note'), ('DebitNote' . (($vars['is_actual'] ? '/act' : '') . ($vars['IsVendor'] ? '/vendor' : '')))]];
        $this->load->view('Accounting/DebitNote', $vars);
    }

    public function DebitList() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('note_sys');
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('credit_debit_note'), 'DebitList']];
        if (isset($_GET['url']))
            $vars['id'] = explode('/', $_GET['url']);
        $vars['List'] = new DebitNote();
        $vars['today'] = Date::gettoday();
        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today
        $month = date("m", strtotime($vars['today'])); // get the month from today
        $vars['monthName'] = date("F", mktime(0, 0, 0, $month, 10)); // transform the month number to month name
        $url = explode('/', $_GET['url']);
        $vars['IsVendor'] = strtolower($url[count($url) - 1]) == "vendor";
        $vars['is_arabic'] = Session::getUserPreferences() == 'ar';
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match_act);
        $vars['is_actual'] = count($match_act) > 0 ? 1 : 0;
        $vars['pageName'] = $vars['is_actual'] ? ( $vars['IsVendor'] ? 'ActualDebitList' : 'ActualCreditList') : ($vars['IsVendor'] ? 'DebitList' : 'CreditList');
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('credit_debit_note'), ('DebitList' . (($vars['is_actual'] ? '/act' : '') . ($vars['IsVendor'] ? '/vendor' : '')))]];
        $this->load->view('Accounting/DebitList', $vars);
    }

    public function DebitListPerCustomer() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('note_sys');
        $vars['today'] = Date::getToday();
        $url = explode('/', $_GET['url']);
        $vars['IsVendor'] = strtolower($url[count($url) - 2]) == "vendor";
        $vars['Account_ID'] = $url[count($url) - 1];
        $vars['DebitCreditList'] = $this->_registry->dashboard->viewDebitCreditperCustomer($vars['Account_ID'], $vars['IsVendor']);
        $vars['pageName'] = $vars['IsVendor'] ? 'CreditListPerVendor' : 'DebitListPerCustomer';
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], $vars['IsVendor'] ? [ACCModel::getmsg('credit_list'), 'DebitListPerCustomer/vendor/' . $vars['Account_ID']] : [ACCModel::getmsg('debit_list'), 'DebitListPerCustomer/' . $vars['Account_ID']]];
        $this->load->view('Accounting/DebitListPerCustomer', $vars);
    }

    //    public function TransactionsByJV() {
    //
    //        $vars['pageName'] = 'TransactionByJV';
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('accounting_sys');
    //        $url = explode('/', $_GET['url']);
    //        $vars['jv'] = $url[count($url) - 1];
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('transactions_by_jv'), 'TransactionsByJV']];
    //        $this->load->view('Accounting/TransactionsByJV', $vars);
    //    }
    //	public function addPrepaidExpense() {
    //        
    //        $vars['pageName']		=	'addPrepaidExpense';
    //        $vars['title'] = 'Accounting System';
    //        $vars['system_name'] = 'JV System';
    //        $vars['breadCrumb'] = [['Accounting','ACC'],['JV',''],['Prepaid Expense','addPrepaidExpense']];
    //        $this->load->view('Accounting/addPrepaidExpense', $vars);
    //    }
    //
    //	public function addPrepaidIncome() {
    //        
    //        $vars['pageName']		=	'addPrepaidIncome';
    //        $vars['title'] = 'Accounting System';
    //        $vars['system_name'] = 'JV System';
    //        $vars['breadCrumb'] = [['Accounting','ACC'],['JV',''],['Prepaid Income','addPrepaidIncome']];
    //        $this->load->view('Accounting/addPrepaidIncome', $vars);
    //    }
    //
    //	public function addAccruedExpense() {
    //        
    //        $vars['pageName']		=	'addAccruedExpense';
    //        $vars['title'] = 'Accounting System';
    //        $vars['system_name'] = 'JV System';
    //        $vars['breadCrumb'] = [['Accounting','ACC'],['JV',''],['Accrued Expense','addAccruedExpense']];
    //        $this->load->view('Accounting/addAccruedExpense', $vars);
    //    }
    public function viewPrepaidExpense() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('accounting_sys');
        preg_match("/\/Income/", $_SERVER['REQUEST_URI'], $match);
        $vars['Income'] = count($match) > 0 ? true : false;
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match_act);
        $vars['Is_Actual'] = count($match_act) > 0 ? "1" : "0";
        $vars['today'] = Date::gettoday();
        $vars['payment_types'] = $this->_registry->jv->viewPaymentTypes();
        $vars['DefaultCurrencyID'] = $this->_registry->currency->getDefaultCurrency();
        $vars['DefaultCurrencySymbol'] = $this->_registry->currency->viewCurrencySymbol($vars['DefaultCurrencyID']);
        $vars['pageName'] = $vars['Is_Actual'] ? ($vars['Income'] ? 'viewPrepaidIncomeActual' : 'viewPrepaidExpenseActual') : ($vars['Income'] ? 'viewPrepaidIncome' : 'viewPrepaidExpense');
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], $vars['Income'] ? [ACCModel::getmsg('prepaid_income'), $vars['Is_Actual'] ? 'viewPrepaidExpense/Income/act' : 'viewPrepaidExpense/Income'] : [ACCModel::getmsg('prepaid_expenses'), $vars['Is_Actual'] ? 'viewPrepaidExpense/act' : 'viewPrepaidExpense']];
        $this->load->view('Accounting/viewPrepaidExpense', $vars);
    }

    public function viewAccruedExpense() {

        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('jv_sys');
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match_act);
        $vars['Is_Actual'] = count($match_act) > 0 ? "1" : "0";
        $vars['today'] = Date::gettoday();
        $vars['payment_types'] = $this->_registry->jv->viewPaymentTypes();
        $vars['DefaultCurrencyID'] = $this->_registry->currency->getDefaultCurrency();
        $vars['DefaultCurrencySymbol'] = $this->_registry->currency->viewCurrencySymbol($vars['DefaultCurrencyID']);
        $vars['pageName'] = $vars['Is_Actual'] ? 'viewAccruedExpenseActual' : 'viewAccruedExpense';
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('accrued_expenses'), 'viewAccruedExpense' . ( $vars['Is_Actual'] ? '/act' : '')]];
        $this->load->view('Accounting/viewAccruedExpense', $vars);
    }

    public function viewDepositeWithDrawal() {
        $vars['pageName'] = 'viewDepositeWithDrawal';
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('jv_sys');
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match_act);
        $vars['Is_Actual'] = count($match_act) > 0 ? "1" : "0";
        $vars['today'] = Date::gettoday();
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('deposit_withdrawal'), 'viewDepositeWithDrawal' . ($vars['Is_Actual'] ? '/act' : '')]];
        $this->load->view('Accounting/viewDepositeWithDrawal', $vars);
    }

    public function addDepositWithDrawal() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('jv_sys');
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match_act);
        $vars['Is_Actual'] = count($match_act) > 0 ? 1 : 0;
        $url = explode('/', $_GET['url']);
        $vars['today'] = Date::gettoday();
        $vars['local_currency'] = $this->_registry->currencyfactory->returnLocalCurrency();
        $vars['IsEdit'] = is_numeric($url[count($url) - 1]) ? true : false;
        if (!$vars['IsEdit']) {
//            $vars['unique_id'] = 'dep' . uniqid();
//            smc_session()['duplicate_check'][$vars['unique_id']] = true;
            $vars['unique_id'] = token_unique::generate_token('dep');
        }
        $vars['id'] = $vars['IsEdit'] ? $url[count($url) - 1] : 0;
        $vars['edit_arr'] = $this->_registry->jv->getDWByID($vars['id']);
//        echo"<pre>";die(print_r($vars['edit_arr']));
        $vars['check_lock'] = $vars['IsEdit'] ? CommonFunctions::check_lock_data(['type' => 'deposit', 'start_date' => $vars['edit_arr']['Deposit_WithDrawal_Date'], 'is_actual' => $vars['Is_Actual']]) : '';

        $vars['is_main_transfer'] = $vars['IsEdit'] ? ($vars['edit_arr']['is_main_transfer']) : 0;
        $vars['Extable'] = $this->_registry->currency->getExchangeRateTable();
        $DefaultCurrencyID = $this->_registry->currency->getDefaultCurrency();
        $vars['DefaultCurrencySymbol'] = smc_session()['local_currency_symbol'];
        $vars['currency_list'] = $this->_registry->currency->getAllCurrencies();
        $vars['pageName'] = $vars['Is_Actual'] ? $vars['IsEdit'] ? 'editDepositWithDrawalActual' : 'addDepositWithDrawalActual' : $vars['IsEdit'] ? 'editDepositWithDrawal' : 'addDepositWithDrawal';
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('deposit_withdrawal'), 'viewDepositeWithDrawal' . ( $vars['Is_Actual'] ? '/act' : '')], [ACCModel::getmsg('add_deposit_withdrawal'), 'addDepositWithDrawal' . ( $vars['Is_Actual'] ? ($vars['IsEdit'] ? '/act/' . $vars['id'] : '') : (($vars['IsEdit'] ? '/' . $vars['id'] : '')))]];
        $this->load->view('Accounting/addDepositWithDrawal', $vars);
    }

    public function addJV() {
        $vars['pageName'] = 'addJV';
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('jv_sys');
        $vars['today'] = Date::getToday();
        $url = explode('/', $_SERVER['REQUEST_URI']);
        $vars['IsEdit'] = (empty($_GET['is_pop']) ? is_numeric($url[count($url) - 1]) : is_numeric(explode("?", $url[count($url) - 1])[0])) ? true : false;

        if (!$vars['IsEdit']) {
//            $vars['unique_id'] = 'jv' . uniqid();
//            smc_session()['duplicate_check'][$vars['unique_id']] = true;
            $vars['unique_id'] = token_unique::generate_token('jv');
        }


        if (empty($_GET['is_pop'])) {
            $vars['id'] = $vars['IsEdit'] ? $url[count($url) - 1] : 0;
        } else {
            $vars['id'] = $vars['IsEdit'] ? explode("?", $url[count($url) - 1])[0] : 0;
        }

        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match2);
        $vars['IsActual'] = count($match2) > 0 ? 1 : 0;
        preg_match("/\/copy/", $_SERVER['REQUEST_URI'], $match2);
        $vars['is_copy'] = count($match2) > 0 ? "1" : "0";
        $edit_arr = $this->_registry->jv->viewJVInfo($vars['id'], $vars['IsActual']);
        $vars['edit_arr'] = $edit_arr['data'];
        $vars['totals_arr'] = $edit_arr['totals'];
//                echo "<pre>";die(print_r($edit_arr));
        $vars['check_lock'] = $vars['IsEdit'] ? CommonFunctions::check_lock_data(['type' => 'mjv', 'start_date' => $vars['edit_arr'][0]['Transaction_Date'], 'is_actual' => $vars['IsActual']]) : '';

        $vars['activate_second_currency'] = smc_session()['default_setting']['activate_second_currency'];
        $vars['local_cuurency_id'] = $this->_registry->currencyfactory->returnLocalCurrency();
        $vars['local_cuurency_symbol'] = $this->_registry->currency->viewCurrencySymbol($vars['local_cuurency_id']);
        $vars['DefaultCurrencyID'] = $this->_registry->currency->getDefaultCurrency();
        //        $vars['DefaultCurrencySymbol'] = $this->_registry->currency->viewCurrencySymbol($vars['DefaultCurrencyID']);
        $vars['currency_list'] = $this->_registry->currency->getAllCurrencies();
        $vars['Extable'] = $this->_registry->currency->getExchangeRateTable();
        $second_rate_arr = $this->_registry->currency->returnExchangeRate(smc_session()['local_currency'], smc_session()['second_currency']['id']);
        $vars['second_to_local_rate'] = $second_rate_arr[1] == '*' ? $second_rate_arr[0] : (1 / $second_rate_arr[0]);
        $vars['SecondCurrencySymbol'] = smc_session()['second_currency']['symbol'];
        $vars['pageName'] = $vars['IsActual'] ? $vars['IsEdit'] ? 'editJVActual' : 'addJVActual' : $vars['IsEdit'] ? 'editJV' : 'addJV';
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('add_jv'), $vars['IsActual'] ? ($vars['IsEdit'] ? 'addJV/act/' . $vars['id'] : 'addJV/act') : ($vars['IsEdit'] ? 'addJV/' . $vars['id'] : 'addJV')]];
        $this->load->view('Accounting/addJV', $vars);
    }

    //    public function addBank() {
    //
    //        $vars['pageName'] = 'addBankAccount';
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('bank_sys');
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('add_bank_account'), 'addBankAccount']];
    //        $this->load->view('Accounting/addBank', $vars);
    //    }

    public function ExchangeRateList() {
        $vars['pageName'] = 'ExchangeRateList';
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('exchange_rate_list');
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('exchange_rate_list'), 'ExchangeRateList']];
        $vars['today'] = Date::gettoday();
        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today
        $month = date("m", strtotime($vars['today'])); // get the month from today
        $day = date("d", strtotime($vars['today'])); // get the day from today
        $vars['monthName'] = date("F", mktime(0, 0, 0, $month, 10)); // transform the month number to month name
        $vars['list'] = array();
        $vars['currency_codes'] = $this->_registry->currency->viewCurrenciesCodesWithSymbols();
        $this->load->view('Accounting/ExchangeRateList', $vars);
    }

    public function closeVAT() {
        $vars['pageName'] = 'closeVAT';
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('vat_sys');
        $vars['list'] = $this->_registry->vat->viewVATTransactions(date('Y-m-d'));
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('close_vat'), 'closeVAT']];
        $this->load->view('Accounting/closeVAT', $vars);
    }

    //    public function IncomeStatement() {
    //
    //        $vars['pageName'] = 'IncomeStatement';
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('reports_sys');
    //        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
    //        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
    //        $vars['defCurrencyName'] = $this->_registry->currency->getCurrencyNameByID($defCurrency_Id);
    //        $vars['today'] = Date::gettoday();
    //        $vars['year1'] = date("Y", strtotime($vars['today'])); // get the year from today
    //        $vars['from_day'] = $vars['year1'] . '-01-01';
    //        $vars['list'] = $this->_registry->report->incomeStatement(20, 2, $vars['from_day'], $vars['today']);
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('statement_of_income'), 'IncomeStatement']];
    //        $this->load->view('Accounting/IncomeStatement', $vars);
    //    }

    public function statementOfIncome() {
        $vars['pageName'] = 'IncomeStatement';
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('reports_sys');
        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
        $vars['defCurrencyName'] = $this->_registry->currency->getCurrencyNameByID($defCurrency_Id);
        $vars['today'] = Date::gettoday();
        $vars['year1'] = date("Y", strtotime($vars['today'])); // get the year from today
        $vars['from_day'] = smc_session()['start_date']; // $vars['year1'] . '-01-01';
        $vars['methods'] = CommonFunctions::CommonView('tbl_stock_pricing_methods');
        $vars['org2'] = $this->_registry->Organization->getOrganizationDetails();
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match2);
        $vars['is_actual'] = count($match2) > 0 ? "1" : "0";
        $start = $vars['is_actual'] ? smc_session()['start_date'] : smc_session()['start_date_act'];
        $end = $vars['is_actual'] ? smc_session()['end_date'] : smc_session()['end_date_act'];
        //        $options = [ "Currency_ID" => $defCurrency_Id,
        //                            "From_Date" => $start, "To_Date" => $end, "Opening_Balance" => 0, "Is_Actual" => $vars['is_actual']];
        //        $vars['list'] = $this->_registry->report->statementOfIncome($options);
        $begin_acc = smc_session()['account_setting']['begining_stock_account_id'];
        $vars['begining_acc'] = JV::getAccountNameByID($begin_acc);
        $end_acc = smc_session()['account_setting']['end_stock_account_id'];
        $vars['end_acc'] = JV::getAccountNameByID($end_acc);
        //        $vars['list'] = $this->_registry->report->statementOfIncome(['from_date' => $start, 'to_date' => $end, 'currency' => $defCurrency_Id, 'is_actual' => $vars['is_actual']]);
        $vars['pageName'] = $vars['is_actual'] ? 'ActualIncomeStatement' : 'IncomeStatement';
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('statement_of_income'), 'statementOfIncome' . ( $vars['is_actual'] ? '/act' : '')]];
        $this->load->view('Accounting/statementOfIncome', $vars);
    }

    public function stmtFinancialPosition() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('reports_sys');
        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
        $vars['today'] = Date::gettoday();
        $vars['year1'] = date("Y", strtotime($vars['today'])); // get the year from today
        $vars['from_day'] = smc_session()['start_date']; //$vars['year1'] . '-01-01';
        $vars['org2'] = $this->_registry->Organization->getOrganizationDetails();
        $vars['methods'] = CommonFunctions::CommonView('tbl_stock_pricing_methods');

        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match2);
        $vars['is_actual'] = count($match2) > 0 ? "1" : "0";
        $start = $vars['is_actual'] ? smc_session()['start_date'] : smc_session()['start_date_act'];
        $end = $vars['is_actual'] ? smc_session()['end_date'] : smc_session()['end_date_act'];
        //        $vars['list'] = $this->_registry->report->StmtFinancialPosition(['from_date' => $start, 'to_date' => $end, 'currency' => $defCurrency_Id, 'is_actual' => $vars['is_actual']]);
        $vars['pageName'] = $vars['is_actual'] ? 'ActualBalanceSheet' : 'BalanceSheet';
        $begin_acc = smc_session()['account_setting']['begining_stock_account_id'];
        $vars['begining_acc'] = JV::getAccountNameByID($begin_acc);
        $end_acc = smc_session()['account_setting']['end_stock_account_id'];
        $vars['end_acc'] = JV::getAccountNameByID($end_acc);
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('balance_sheet'), 'stmtFinancialPosition' . ($vars['is_actual'] ? '/act' : '')]];
        $this->load->view('Accounting/stmtFinancialPosition', $vars);
    }

    //    public function ActualPaymentList() {
    //
    //        $vars['pageName'] = 'ActualPaymentList';
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('payments');
    ////        $vars['bread_crumb_title'] = 'Payment';
    ////        $vars['bread_crumb'] = 'Payment';
    ////        $vars['bread_crumb_first_level'] = 'Payment List';
    //        $url = explode('/', $_SERVER['REQUEST_URI']);
    //        $vars['IsReceipt'] = strtolower($url[count($url) - 1]) == "receipt";
    //        $vars['today'] = Date::gettoday();
    //        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today
    //        $month = date("m", strtotime($vars['today'])); // get the month from today
    //        $vars['monthName'] = date("F", mktime(0, 0, 0, $month, 10)); // transform the month number to month name
    //        $ListPayment = $this->_registry->payment->view(0, null, null, $vars['today']);
    //        $ListReceipt = $this->_registry->payment->view(1, null, null, $vars['today']);
    //
    //        $vars['List'] = $vars['IsReceipt'] ? $ListReceipt : $ListPayment;
    //        $vars['payment_accounts'] = $this->_registry->payment->viewNeededAccounts();
    //        $vars['payment_type'] = $this->_registry->payment->viewPaymentTypes();
    //        preg_match("/\/Receipt$/", $_SERVER['REQUEST_URI'], $match);
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], count($match) > 0 ? [ACCModel::getmsg('actual_receipt'), 'ActualPaymentList/Receipt'] : [ACCModel::getmsg('actual_payments'), 'ActualPaymentList']];
    //        $this->load->view('Accounting/ActualPaymentList', $vars);
    //    }

    public function suppliersAgingReport() {
        $vars['pageName'] = 'suppliersAgingReport';
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('reports_sys');
        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
        $vars['result'] = $this->_registry->report->agingReport(true);
        $vars['today'] = Date::getToday();
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('supplier_aging_report'), 'suppliersAgingReport']];
        $this->load->view('Accounting/suppliersAgingReport', $vars);
    }

    //    public function VendorsCredit() {
    //
    //        $vars['pageName'] = 'VendorsCredit';
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('reports_sys');
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('vendors_credit'), 'VendorsCredit']];
    //        $this->load->view('Accounting/VendorsCredit', $vars);
    //    }
    //    public function CustomersDebit() {
    //
    //        $vars['pageName'] = 'CustomersDebit ';
    //        $vars['title'] = ACCModel::getmsg('dashboard');
    //        $vars['system_name'] = ACCModel::getmsg('dashboard');
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('customers_debit'), 'CustomersDebit ']];
    //        $this->load->view('Accounting/CustomersDebit ', $vars);
    //    }

    public function FixedAssetsRegister() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('reports_sys');
        $vars['today'] = Date::gettoday();
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match2);
        $vars['is_actual'] = count($match2) > 0 ? "1" : "0";
        $vars['pageName'] = $vars['is_actual'] ? 'FixedAssetsRegisterActual' : 'FixedAssetsRegister';
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('fixed_assets_register'), 'FixedAssetsRegister' . ( $vars['is_actual'] ? '/act' : '')]];
        $this->load->view('Accounting/FixedAssetsRegister', $vars);
    }

    public function viewDepreciation() {
        $vars['pageName'] = 'viewDepreciation';
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('reports_sys');
        $url = explode('/', $_SERVER['REQUEST_URI']);
        $vars['Dep_ID'] = $url[count($url) - 1];
        $vars['list'] = $this->_registry->report->mainDepreciationData($vars['Dep_ID']);
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('depreciation'), 'viewDepreciation']];
        $this->load->view('Accounting/viewDepreciation', $vars);
    }

    //    public function FixedAssetsRegisterActual() {
    //
    //        $vars['pageName'] = 'FixedAssetsRegisterActual';
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('reports_sys');
    //        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
    //        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
    //        $vars['today'] = Date::gettoday();
    //        $vars['list'] = $this->_registry->report->viewDepreciationMainDetails(null, null, null, $vars['today'], true);
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('act_fixed_assets_register'), 'FixedAssetsRegisterActual']];
    //        $this->load->view('Accounting/FixedAssetsRegisterActual', $vars);
    //    }
    //    public function viewDepreciationActual() {
    //
    //        $vars['pageName'] = 'viewDepreciationActual';
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('reports_sys');
    //        $url = explode('/', $_SERVER['REQUEST_URI']);
    //        $Dep_ID = $url[count($url) - 1];
    //        $vars['list'] = $this->_registry->report->mainDepreciationData($Dep_ID);
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('act_depreciation'), 'viewDepreciationActual']];
    //        $this->load->view('Accounting/viewDepreciationActual', $vars);
    //    }

    public function CashList() {
        $vars['pageName'] = 'CashList';
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('reports_sys');
        $today = Date::gettoday();
        $vars['year'] = date("Y", strtotime($today));
        $vars['CurrSymbole'] = CurrencyFactory::getDefaultCurrencySymbol();
        $url = explode('/', $_SERVER['REQUEST_URI']);
        $vars['cashID'] = $url[count($url) - 1];
        $vars['list'] = $this->_registry->dashboard->viewTransactionsByCode($vars['cashID'], $vars['year']);
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('cash_list'), 'CashList']];
        $this->load->view('Accounting/CashList', $vars);
    }

    public function BankList() {
        $vars['pageName'] = 'BankList';
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('reports_sys');
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('bank_list'), 'BankList']];
        $today = Date::gettoday();
        $vars['year'] = date("Y", strtotime($today));
        $vars['CurrSymbole'] = CurrencyFactory::getDefaultCurrencySymbol();
        $url = explode('/', $_SERVER['REQUEST_URI']);
        $vars['bankID'] = $url[count($url) - 1];
        $vars['len'] = strlen($vars['bankID']);
        $vars['list'] = $this->_registry->dashboard->viewTransactionsByCode(null, $vars['year'], $vars['bankID'], $vars['len']);
        $this->load->view('Accounting/BankList', $vars);
    }

    public function CashBankBalanceDetails() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('reports_sys');
        $today = Date::gettoday();
        $vars['year'] = date("Y", strtotime($today));
        $vars['CurrSymbole'] = CurrencyFactory::getDefaultCurrencySymbol();
        $url = explode('/', $_SERVER['REQUEST_URI']);
        $vars['IsBank'] = strtolower($url[count($url) - 1]) == "bank";
        $vars['list'] = $vars['IsBank'] ? $this->_registry->dashboard->viewCashBankBalance(0, $vars['year']) : $this->_registry->dashboard->viewCashBankBalance(1, $vars['year']);
        $vars['pageName'] = $vars['IsBank'] ? 'BankBalanceDetails' : 'CashBalanceDetails';
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('cash_bank_details'), 'CashBankBalanceDetails']];
        $this->load->view('Accounting/CashBankBalanceDetails', $vars);
    }

    //    public function ActualIncomeStatement() {
    //
    //        $vars['pageName'] = 'ActualIncomeStatement';
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('reports_sys');
    //        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
    //        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
    //        $vars['defCurrencyName'] = $this->_registry->currency->getCurrencyNameByID($defCurrency_Id);
    //        $vars['today'] = Date::gettoday();
    //        $vars['year1'] = date("Y", strtotime($vars['today'])); // get the year from today
    //        $vars['from_day'] = $vars['year1'] . '-01-01';
    //        $vars['list'] = $this->_registry->report->incomeStatement(20, 2, $vars['from_day'], $vars['today'], true);
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('accounting'), 'act_statement_of_income']];
    //        $this->load->view('Accounting/ActualIncomeStatement', $vars);
    //    }
    //    public function ActualBalanceSheet() {
    //
    //        $vars['pageName'] = 'ActualBalanceSheet';
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('reports_sys');
    //        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
    //        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
    //        $vars['today'] = Date::gettoday();
    //        $vars['year1'] = date("Y", strtotime($vars['today'])); // get the year from today
    //        $vars['from_day'] = $vars['year1'] . '-01-01';
    //        $vars['year2'] = $vars['year1'] - 1;
    //        $list = $this->_registry->report->viewBalanceSheet(20, 2, $vars['from_day'], $vars['today'], true);
    //        $vars['assets'] = $list['Assets'];
    //        $vars['liabilities'] = $list['Liabilities'];
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('act_balance_sheet'), 'ActualBalanceSheet']];
    //        $this->load->view('Accounting/ActualBalanceSheet', $vars);
    //    }

    public function ActualSuppliersAgingReport() {
        $vars['pageName'] = 'ActualSuppliersAgingReport';
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('reports_sys');
        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
        $vars['result'] = $this->_registry->report->agingReport(true, true);
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('supplier_aging_report'), 'suppliersAgingReport']];
        $this->load->view('Accounting/ActualSuppliersAgingReport', $vars);
    }

    public function ActualCustomersAgingReport() {
        $vars['pageName'] = 'ActualCustomersAgingReport';
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('reports_sys');
        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
        $vars['result'] = $this->_registry->report->agingReport(false, true);
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('act_cust_aging_report'), 'ActualCustomersAgingReport']];
        $this->load->view('Accounting/ActualCustomersAgingReport', $vars);
    }

    //    public function ActualLedger() {
    //
    //        $vars['pageName'] = 'ActualLedger';
    //        $vars['title'] = 'Accounting System';
    //        $vars['system_name'] = ACCModel::getmsg('actual_general_ledger');
    //        preg_match("/\/ledger\/(\d+|(.*))$/", $_SERVER['REQUEST_URI'], $matches);
    //        $vars['Account_ID'] = count($matches) > 0 ? $matches[1] : 0;
    //        $vars['account_name'] = count($matches) > 0 ? $this->_registry->report->returnAccountName($Account_ID) : '';
    //        $vars['Ismatches'] = count($matches) > 0 ? true : false;
    //        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
    //        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
    //        $vars['defCurrencyName'] = $this->_registry->currency->getCurrencyNameByID($defCurrency_Id);
    //        $vars['today'] = Date::getToday();
    //        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today
    //        $vars['from_day'] = $vars['year'] . '-01-01';
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('actual_general_ledger'), 'ledger']];
    //        $this->load->view('Accounting/ActualLedger', $vars);
    //    }
    //    public function ActualTrialBalance() {
    //
    //        $vars['pageName'] = 'ActualTrialBalance';
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('actual_trial_balance');
    //        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
    //        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
    //        $vars['defCurrencyName'] = $this->_registry->currency->getCurrencyNameByID($defCurrency_Id);
    //        $vars['today'] = Date::getToday();
    //        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today 
    //        $vars['from_day'] = $vars['year'] . '-01-01';
    //        $vars['trialList'] = $this->_registry->report->trialBalanceByDigits(20, 2, $vars['from_day'], $vars['today']);
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('actual_trial_balance'), 'trialBalance']];
    //        $this->load->view('Accounting/ActualTrialBalance', $vars);
    //    }
    //    public function ActualDailyJournals() {
    //
    //        $vars['pageName'] = 'ActualDailyJournals';
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('act_daily_journals');
    //        $vars['today'] = Date::getToday();
    //        
    //        $vars['jvList'] = $this->_registry->report->viewJVs(true);
    //        $vars['DailyList'] = $this->_registry->report->retrieveDailyJVsByRange($vars['today'], $vars['today'], null, null, true);
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('act_daily_journals'), 'DailyJournals']];
    //        $this->load->view('Accounting/ActualDailyJournals', $vars);
    //    }
    //    public function viewDepositeWithDrawalActual() {
    //
    //        $vars['pageName'] = 'viewDepositeWithDrawalActual';
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('jv_sys');
    //        $vars['today'] = Date::gettoday();
    //        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today
    //        $vars['month'] = date("m", strtotime($vars['today'])); // get the month from today
    //        $vars['monthName'] = date("F", mktime(0, 0, 0, $vars['month'], 10)); // transform the month number to month name
    //        $vars['dw_codes'] = $this->_registry->jv->viewAccountsByType("Payment");
    //        $DefaultCurrencyID = $this->_registry->currency->getDefaultCurrency();
    //        $vars['DefaultCurrencySymbol'] = $this->_registry->currency->viewCurrencySymbol($DefaultCurrencyID);
    //        $vars['currency_list'] = $this->_registry->currency->getAllCurrencies($DefaultCurrencyID);
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('actual_deposit_withdrawal'), 'viewDepositeWithDrawalActual']];
    //        $this->load->view('Accounting/viewDepositeWithDrawalActual', $vars);
    //    }
    //    public function addJVActual() {
    //
    //        $vars['pageName'] = 'addJVActual';
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('jv_sys');
    //        $vars['today'] = Date::getToday();
    //        
    //        $vars['DefaultCurrencyID'] = $this->_registry->currencyfactory->returnLocalCurrency();
    //        $vars['DefaultCurrencySymbol'] = $this->_registry->currency->viewCurrencySymbol($vars['DefaultCurrencyID']);
    //        $vars['JVNumber'] = $this->_registry->jv->returnJV(1);
    //        $vars['currency_list'] = $this->_registry->currency->getAllCurrencies();
    //        $vars['Extable'] = $this->_registry->currency->getExchangeRateTable();
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('add_actual_jv'), 'addJVActual']];
    //        $this->load->view('Accounting/addJVActual', $vars);
    //    }
    //    public function transferJVToActual() {
    //
    //        $vars['pageName'] = 'transferJVToActual';
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('jv_sys');
    //        $vars['today'] = Date::getToday();
    //        $vars['JVNumber'] = $this->_registry->jv->returnJV(1);
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('transfer_jv_to_actual'), 'transferJVToActual']];
    //        $this->load->view('Accounting/transferJVToActual', $vars);
    //    }
    //    public function transferJVList() {
    //
    //        $vars['pageName'] = 'transferJVList';
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('jv_sys');
    //        $vars['today'] = Date::gettoday();
    //        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today
    //        $vars['month'] = date("m", strtotime($vars['today'])); // get the month from today
    //        $vars['monthName'] = date("F", mktime(0, 0, 0, $vars['month'], 10));
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('transfer_jv_list'), 'transferJVList']];
    //        $this->load->view('Accounting/transferJVList', $vars);
    //    }

    public function closeYear() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('accounting_sys');
        preg_match("/\/act\b/i", $_SERVER['REQUEST_URI'], $match_act);
        $vars['is_actual'] = count($match_act) > 0 ? 1 : 0;
        $vars['list'] = $this->_registry->report->get_close_year_trans($vars['is_actual']);
        //        echo"<pre>";die(print_r($vars['list']));
        $vars['to_close_years'] = $this->_registry->report->get_financial_years($vars['is_actual']);
        $vars['pageName'] = $vars['is_actual'] ? 'closeYearActual' : 'closeYear';
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('close_year'), 'closeYear' . ($vars['is_actual'] ? '/act' : '')]];
        $this->load->view('Accounting/closeYear', $vars);
    }

    //
    //    public function closeYearActual() {
    //
    //        $vars['pageName'] = 'closeYearActual';
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('accounting_sys');
    //        $vars['list'] = $this->_registry->report->closeYearTransactionsList(true);
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('close_year_actual'), 'closeYearActual']];
    //        $this->load->view('Accounting/closeYearActual', $vars);
    //    }

    public function currencyExchangeRate() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('accounting_sys');
        $vars['today'] = Date::getToday();
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match_a);
        $vars['is_actual'] = count($match_a) > 0 ? 1 : 0;
        $vars['pageName'] = $vars['is_actual'] == 1 ? 'currencyExchangeRateActual' : 'currencyExchangeRate';

        //        $vars['year'] = substr($vars['today'], 0, 4);
        //        $vars['list'] = $this->_registry->currency->selectExchangeRateAccounts(0);
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg($vars['is_actual'] == 1 ? 'act_currency_exchange_rate' : 'currency_exchange_rate'), 'currencyExchangeRate' . ($vars['is_actual'] == 1 ? '/act' : '')]];
        $this->load->view('Accounting/currencyExchangeRate', $vars);
    }

    public function currencyExchangeRateActual() {
        $vars['pageName'] = 'currencyExchangeRateActual';
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('accounting_sys');
        $vars['today'] = Date::getToday();
        $vars['year'] = substr($vars['today'], 0, 4);
        $vars['list'] = $this->_registry->currency->selectExchangeRateAccounts(1);
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('act_currency_exchange_rate'), 'currencyExchangeRateActual']];
        $this->load->view('Accounting/currencyExchangeRateActual', $vars);
    }

    //    public function ActualTrialBalanceV2() {
    //
    //        $vars['pageName'] = 'ActualTrialBalanceV2';
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('act_current_trial_balance');
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('act_current_trial_balance'), 'ActualTrialBalanceV2']];
    //        $this->load->view('Accounting/ActualTrialBalanceV2', $vars);
    //    }

    public function einv_generate_tlv_qr_code($array_tag=array()){
        $index=1;
        $tlv_string='';
        foreach($array_tag as $tag_val){
            $tlv_string.=pack("H*", sprintf("%02X",(string) "$index")).
                         pack("H*", sprintf("%02X",strlen((string) "$tag_val"))).
                         (string) "$tag_val";
            $index++;                              
        }      
        return base64_encode($tlv_string);
    }
    public function ViewReceipt() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('receipt_sys');
        $url = explode('/', $_GET['url']);
        preg_match("/\/Receipt/", $_SERVER['REQUEST_URI'], $match);
        $vars['IsReceipt'] = count($match) > 0 ? true : false;
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match_a);
        $is_actual = count($match_a) > 0 ? 1 : 0;
        $Invoice_ID = $url[count($url) - 1];
        //        echo $Invoice_ID.'==';
        //        $prefix = $url[count($url) - 1];
        $is_receipt = $vars['IsReceipt'] ? 1 : 0;
        $template_id = !empty($_GET['template_id']) ? $_GET['template_id'] : '';

        $vars['pageName'] = $is_actual ? ($is_receipt ? 'ViewReceiptActual' : 'ViewPaymentActual') : ($is_receipt ? 'ViewReceipt' : 'ViewPayment');
        $data = $this->_registry->payment->payment_template_arr($Invoice_ID);
        //$qr_string ='%0A Organization Name: '.' فؤاد مختار  '.' %0 APayment Amount '.$data['details'][0]['Payment_Amount'].'%0A VAT:3002488732000003 %0A C.R: 4030287797  %0A Print Date '.date("Y-m-d h:i:sa");
        $getOrganizationDetails=$this->_registry->Organization->getOrganizationDetails()[0];
        

        $data['main']= array_merge($data['main'],$getOrganizationDetails);

        $data_tlv= $this->einv_generate_tlv_qr_code(array($data['main']['Organization_Name'],$data['main']['Organization_vat_num'],str_replace(' ','T',$data['main']['date_created']),$data['main']['total_amount'],0));
        $data['main']['qrcode'] = SITE_LINK . 'common_controller/GenerateQRCode?code=' . $data_tlv;
        //print_r($data);die();

        if ($is_actual)
            $template_key = $is_receipt ? ['act_receipt', 'receipt', 'act_payment', 'payment'] : ['act_payment', 'payment', 'act_receipt', 'receipt'];
        else
            $template_key = $is_receipt ? ['receipt', 'payment'] : ['payment', 'receipt'];
        if (!empty($template_id))
            $template_key['id'] = $template_id;
        $template_row = Forms::build_print_template($template_key, $data['main'], array('details' => $data['details']));
//          echo"<pre>";print_r($data);exit;
        //$this->load->view_html($template_row['html'], $vars);
        echo $template_row['html'];
        exit;
    }

    public function ViewJV() {
        $vars['pageName'] = 'ViewReceipt';
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('accounting_sys');
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match_a);
        $is_actual = count($match_a) > 0 ? 1 : 0;
        $url = explode('/', $_GET['url']);
        $jv_id = $url[count($url) - 1];
        $data = $this->_registry->jv->viewJVInfo($jv_id, $is_actual)['data'];
        //        echo"<pre>";die(print_r($data));
        $total = $this->_registry->jv->viewJVInfo($jv_id, $is_actual)['totals'];
        $main_data = ['jv_number' => $jv_id, 'trans_nb' => (!empty($data[0]['trans_nb']) ? $data[0]['trans_nb'] : ''),
            'jv_date' => !empty($data[0]['Transaction_Date']) ? $data[0]['Transaction_Date'] : '',
            'branch_name' => !empty($data[0]['branch_name']) ? $data[0]['branch_name'] : '',
            'total_debit_local_formatted' => !empty($total['total_debit_local_formatted']) ? $total['total_debit_local_formatted'] : '',
            'total_credit_local_formatted' => !empty($total['total_credit_local_formatted']) ? $total['total_credit_local_formatted'] : '',
            'local_balance_formatted' => $total['local_balance_formatted']
        ];

        $template_row = Forms::build_print_template('manual_jv', $main_data, array('details' => $data));

        $this->load->view_html($template_row['html'], $vars);
        exit;
    }

    public function expenseReport() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('reports_sys');
        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match_act);
        $vars['Is_Actual'] = count($match_act) > 0 ? "1" : "0";
        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
        $vars['defCurrencyName'] = $this->_registry->currency->getCurrencyNameByID($defCurrency_Id);
        $vars['today'] = Date::getToday();
        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today 
        $vars['from_day'] = smc_session()['start_date']; //$vars['year'] . '-01-01';
        $vars['expense_accounts'] = $this->_registry->report->viewGroupSix();
        $temp = array();
        $vars['expenselist'] = $this->_registry->report->expenseReport($vars['from_day'], $vars['today'], $temp, 1, 0, $vars['Is_Actual']);
        $vars['pageName'] = $vars['Is_Actual'] ? 'expenseReportActual' : 'expenseReport';
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('expense_report'), 'expenseReport' . ($vars['Is_Actual'] ? '/act' : '')]];
        $this->load->view('Accounting/expenseReport', $vars);
    }

    public function ledgerMultiAccounts() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('general_ledger');
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match_act);
        $vars['Is_Actual'] = count($match_act) > 0 ? "1" : "0";
        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
        $vars['defCurrencyName'] = $this->_registry->currency->getCurrencyNameByID($defCurrency_Id);
        $vars['accounts'] = $this->_registry->report->viewAllAccounts();
        $vars['today'] = Date::getToday();
        //        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today
        $vars['from_day'] = smc_session()['start_date']; //$vars['year'] . '-01-01';
        $vars['pageName'] = $vars['Is_Actual'] ? 'ledgerMultiAccountsActual' : 'ledgerMultiAccounts';
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('general_ledger'), 'ledgerMultiAccounts' . ($vars['Is_Actual'] ? '/act' : '')]];
        $this->load->view('Accounting/ledgerMultiAccounts', $vars);
    }

    public function mergeAccounts() {
        $vars['pageName'] = 'mergeAccounts';
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('accounting_sys');
        $vars['accounts'] = $this->_registry->jv->viewAllAccounts();
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('merge_accounts'), 'mergeAccounts']];
        $this->load->view('Accounting/mergeAccounts', $vars);
    }

    //    public function BalanceSheetTotals() {
    //
    //        $vars['pageName'] = 'BalanceSheetTotals';
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('reports_sys');
    //        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
    //        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
    //        $vars['today'] = Date::gettoday();
    //        $vars['year1'] = date("Y", strtotime($vars['today'])); // get the year from today
    //        $vars['from_day'] = $vars['year1'] . '-01-01';
    //        $vars['year2'] = $vars['year1'] - 1;
    //        $list = $this->_registry->report->viewBalanceSheet(20, 2, $vars['from_day'], $vars['today']);
    //        $vars['assets'] = $list['Assets'];
    //        $vars['liabilities'] = $list['Liabilities'];
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('balance_sheet'), 'BalanceSheetTotals']];
    //        $this->load->view('Accounting/BalanceSheetTotals', $vars);
    //    }
    //    public function ActualBalanceSheetTotals() {
    //
    //        $vars['pageName'] = 'ActualBalanceSheetTotals';
    //        $vars['title'] = ACCModel::getmsg('accounting_sys');
    //        $vars['system_name'] = ACCModel::getmsg('reports_sys');
    //        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
    //        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
    //        $vars['today'] = Date::gettoday();
    //        $vars['year1'] = date("Y", strtotime($vars['today'])); // get the year from today
    //        $vars['from_day'] = $vars['year1'] . '-01-01';
    //        $vars['year2'] = $vars['year1'] - 1;
    //        $list = $this->_registry->report->viewBalanceSheet(20, 2, $vars['from_day'], $vars['today'], true);
    //        $vars['assets'] = $list['Assets'];
    //        $vars['liabilities'] = $list['Liabilities'];
    //        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('balance_sheet'), 'ActualBalanceSheetTotals']];
    //        $this->load->view('Accounting/ActualBalanceSheetTotals', $vars);
    //    }

    public function topSuppliers() {
        $vars['pageName'] = 'topSuppliers';
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['accounts'] = $this->_registry->vendor->getSupplierMainAcc();
        $vars['date_to'] = Date::gettoday();
        $year = date("Y", strtotime($vars['date_to']));
        $vars['date_from'] = smc_session()['start_date']; //$year . '-01-01';
        $data = ["is_supplier" => 1, "date_from" => $vars['date_from'], "date_to" => $vars['date_to'], "limit" => 10, "currency" => smc_session()['local_currency'], "type" => "Credit", "is_leb" => 1, "accounts" => array()];
        $vars['result'] = $this->_registry->report->viewTopSuppCust($data);
        $vars['localCurrency'] = CurrencyFactory::getLocalCurrencySymbol();
        $vars['system_name'] = ACCModel::getmsg('accounting');
        $this->load->view('Accounting/topSuppliers', $vars);
    }

    public function topCustomers() {

        $vars['pageName'] = 'topCustomers';
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['date_to'] = Date::gettoday();
        $year = date("Y", strtotime($vars['date_to']));
        $vars['date_from'] = smc_session()['start_date']; // $year . '-01-01';
        $data = ["is_supplier" => 0, "date_from" => $vars['date_from'], "date_to" => $vars['date_to'], "limit" => 10, "currency" => smc_session()['local_currency'], "type" => "Debit", "is_leb" => 1, "accounts" => ["4111"]];
        $vars['result'] = $this->_registry->report->viewTopSuppCust($data);
        $vars['localCurrency'] = CurrencyFactory::getLocalCurrencySymbol();
        $vars['system_name'] = ACCModel::getmsg('accounting');
        $this->load->view('Accounting/topCustomers', $vars);
    }

    public function dailyJVs() {
        $vars['today'] = Date::gettoday();
        //        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today
        //        $vars['month'] = date("m", strtotime($vars['today'])); // get the month from today
        //        $vars['monthName'] = date("F", mktime(0, 0, 0, $vars['month'], 10)); // transform the month number to month name
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match);
        $vars['IsActual'] = count($match) > 0 ? "1" : "0";
        preg_match("/\/atv/", $_SERVER['REQUEST_URI'], $match_activity);
        $vars['is_activity'] = count($match_activity) > 0 ? 1 : 0;
        $url = explode('/', $_GET['url']);
        $vars['jv_id'] = is_numeric($url[count($url) - 1]) ? $url[count($url) - 1] : 0;
        $vars['system_name'] = ACCModel::getmsg('daily_journals');
        $vars['pageName'] = $vars['is_activity'] ? ($vars['IsActual'] ? 'act_activity_daily_journal' : 'activity_daily_journal') : ($vars['IsActual'] ? 'ActualDailyJournals' :'DailyJournals');
        //        echo $vars['pageName'].'<br>';
        //        die('ok');
        $vars['title'] = ACCModel::getmsg($vars['pageName']);

        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [$vars['title'], ACCModel::getmsg('dailyJVs') . ($vars['is_activity'] ? '/atv' : '') . ($vars['IsActual'] ? '/act' : '')]];
        $this->load->view('Accounting/dailyJVs', $vars);
    }

    public function ViewNote() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('receipt_sys');
        $url = explode('/', $_GET['url']);
        preg_match("/\/credit/", $_SERVER['REQUEST_URI'], $match);
        $vars['IsCredit'] = count($match) > 0 ? true : false;
        $ID = $url[count($url) - 1];
        $vars['List'] = $vars['IsCredit'] ? $this->_registry->debitnote->viewCreditNotes($ID) : $this->_registry->debitnote->viewDebitNotes($ID);
        $vars['org_details'] = $this->_registry->Organization->getOrganizationDetails();
        $vars['pageName'] = (!empty($vars['List']) && $vars['List'][0]['is_actual'] == 1) ? ( $vars['IsCredit'] ? 'view_credit_note_actual' : 'view_debit_note_actual') : ($vars['IsCredit'] ? 'view_credit_note' : 'view_debit_note');
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('credit_debit_note'), 'ViewNote/' . ($vars['IsCredit'] ? 'credit/' : '') . $ID]];
        $this->load->view('Accounting/ViewNote', $vars);
    }

    public function UserAccAccounts() {
        $vars['pageName'] = 'addUserAccounts';
        $vars['title'] = inventoryModel::getmsg('accounting_sys');
        $vars['system_name'] = inventoryModel::getmsg('accounting_sys');
        $vars['deposit_account'] = $this->_registry->jv->getSetofAccounts(45);
        $vars['other_accounts'] = $this->_registry->jv->getSetofAccounts(51);
        $vars['is_new'] = !empty($_GET['is_new']) ? 1 : 0;
        $vars['current_user_id'] = !empty($_GET['id']) ? $_GET['id'] : '';
        $vars['current_user_name'] = !empty($_GET['id']) ? CommonFunctions::SpecificAttribute('tbl_common_users', 'User_ID', $_GET['id'], 'User_Name') : '';
        $vars['breadCrumb'] = [[inventoryModel::getmsg('accounting_sys'), 'ACC'], [inventoryModel::getmsg('user_accounts'), 'UserAccAccounts']];
        $this->load->view('Accounting/UserAccAccounts', $vars);
    }

    public function cash_drawer_accounts() {
        $vars['pageName'] = 'cash_drawer_accounts';
        $vars['title'] = inventoryModel::getmsg('accounting_sys');
        $vars['system_name'] = inventoryModel::getmsg('accounting_sys');
        $vars['breadCrumb'] = [[inventoryModel::getmsg('accounting_sys'), 'ACC'], [inventoryModel::getmsg('cash_drawer_accounts'), 'cash_drawer_accounts']];
        $this->load->view('Accounting/cash_drawer_accounts', $vars);
    }

    public function org_branches() {
        $vars['pageName'] = 'org_branches';
        $vars['title'] = inventoryModel::getmsg('accounting_sys');
        $vars['system_name'] = inventoryModel::getmsg('accounting_sys');
        $vars['breadCrumb'] = [[inventoryModel::getmsg('accounting_sys'), 'ACC'], [inventoryModel::getmsg('org_branches'), 'org_branches']];
        $this->load->view('Accounting/org_branches', $vars);
    }

    public function group_accounts() {
        $vars['pageName'] = 'group_accounts';
        $vars['title'] = inventoryModel::getmsg('accounting_sys');
        $vars['system_name'] = inventoryModel::getmsg('accounting_sys');
        $vars['breadCrumb'] = [[inventoryModel::getmsg('accounting_sys'), 'ACC'], [inventoryModel::getmsg('group_accounts'), 'group_accounts']];
        $this->load->view('Accounting/group_accounts', $vars);
    }

    public function reorder_jv() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('jv_sys');
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match2);
        $vars['is_actual'] = count($match2) > 0 ? "1" : "0";
        $vars['pageName'] = $vars['is_actual'] ? 'reorder_actual_jv' : 'reorder_jv';
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg($vars['is_actual'] ? 'reorder_actual_jv' : 'reorder_jv'), $vars['is_actual'] ? 'reorder_jv/act' : 'reorder_jv']];
        $this->load->view('Accounting/reorder_jv', $vars);
    }

    public function view_deposit_withdrawal() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('jv_sys');
        $url = explode('/', $_GET['url']);
        $vars['id'] = $url[count($url) - 1];
        $vars['data'] = $this->_registry->jv->getDWByID($vars['id']);
        // echo "<pre>";die(print_r($vars['data']));
        $vars['pageName'] = $vars['data']['Is_Hidden'] == 1 ? 'viewDepositeWithDrawalActual' : 'viewDepositeWithDrawal';
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('deposit_withdrawal'), 'viewDepositeWithDrawal' . ( $vars['data']['Is_Hidden'] == 1 ? '/act' : '')]];
        $this->load->view('Accounting/view_deposit_withdrawal', $vars);
    }

    public function view_expense() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('view_expense');
        $url = explode('/', $_GET['url']);
        $id = $url[count($url) - 1];
        $data = $this->_registry->expense->getExpenseToPrint($id);
        $vars['pageName'] = $data['main']['Is_Hidden'] == 1 ? 'view_expense_actual' : 'view_expense';
        $template_row = Forms::build_print_template('expense', $data['main'], array('details' => $data['details']));
        $this->load->view_html($template_row['html'], $vars);
        exit;
    }

    public function job_list() {
        $vars['pageName'] = 'job_list';
        $vars['title'] = inventoryModel::getmsg('jobs');
        $vars['system_name'] = inventoryModel::getmsg('jobs');
        $vars['breadCrumb'] = [[inventoryModel::getmsg('accounting_sys'), 'ACC'], [inventoryModel::getmsg('jobs'), 'job_list']];
        $this->load->view('Accounting/job_list', $vars);
    }

    public function trans_type_list() {
        $vars['pageName'] = 'trans_type_list';
        $vars['title'] = inventoryModel::getmsg('trans_types');
        $vars['system_name'] = inventoryModel::getmsg('trans_types');
        $vars['breadCrumb'] = [[inventoryModel::getmsg('accounting_sys'), 'ACC'], [inventoryModel::getmsg('trans_types'), 'trans_type_list']];
        $this->load->view('Accounting/trans_type_list', $vars);
    }

    public function statament_of_job() {
        $vars['title'] = ACCModel::getmsg('statament_of_job');
        $vars['system_name'] = ACCModel::getmsg('statament_of_job');
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match_act);
        $vars['is_actual'] = count($match_act) > 0 ? 1 : 0;
        $vars['users'] = CommonFunctions::CommonView('tbl_common_users');
        $url = explode('/', $_SERVER['REQUEST_URI']);
        $vars['job_id'] = is_numeric($url[count($url) - 1]) ? $url[count($url) - 1] : 0;
        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
        $vars['defCurrencyName'] = $this->_registry->currency->getCurrencyNameByID($defCurrency_Id);
        $vars['today'] = Date::getToday();
        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today
        $vars['from_day'] = smc_session()['start_date']; // $vars['year'] . '-01-01';
        $vars['pageName'] = $vars['is_actual'] ? 'act_statament_of_job' : 'statament_of_job';
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('statament_of_job'), $vars['is_actual'] ? 'statament_of_job/act' : 'statament_of_job']];
        $this->load->view('Accounting/statament_of_job', $vars);
    }

    public function family_accounts() {
        $vars['pageName'] = 'family_accounts';
        $vars['title'] = inventoryModel::getmsg('family_accounts');
        $vars['system_name'] = inventoryModel::getmsg('family_accounts');
        $vars['breadCrumb'] = [[inventoryModel::getmsg('accounting_sys'), 'ACC'], [inventoryModel::getmsg('family_accounts'), 'family_accounts']];
        $this->load->view('Accounting/family_accounts', $vars);
    }

    public function job_trial_balance() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('trial_balance');
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match);
        $vars['Is_Actual'] = count($match) > 0 ? "1" : "0";
        $vars['pageName'] = $vars['Is_Actual'] ? 'act_job_trial_balance' : 'job_trial_balance';
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg($vars['Is_Actual'] ? 'act_job_trial_balance' : 'job_trial_balance'), $vars['Is_Actual'] ? 'job_trial_balance/act' : 'job_trial_balance']];
        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
        $vars['defCurrencyName'] = $this->_registry->currency->getCurrencyNameByID($defCurrency_Id);
        $vars['today'] = Date::getToday();
        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today 
        $vars['from_day'] = smc_session()['start_date']; //$vars['year'] . '-01-01';
        $this->load->view('Accounting/job_trial_balance', $vars);
    }

    public function financial_year() {
        $vars['pageName'] = 'financial_year';
        $vars['title'] = inventoryModel::getmsg('financial_year');
        $vars['system_name'] = inventoryModel::getmsg('financial_year');
        $vars['breadCrumb'] = [[inventoryModel::getmsg('accounting_sys'), 'ACC'], [inventoryModel::getmsg('financial_year'), 'financial_year']];
        $this->load->view('Accounting/financial_year', $vars);
    }

    public function customer_supplier_vat_report() {
        $vars['pageName'] = 'customer_supplier_vat_report';
        $vars['title'] = inventoryModel::getmsg('vat_report');
        $vars['system_name'] = inventoryModel::getmsg('vat_report');
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match);
        $vars['is_actual'] = count($match) > 0 ? "1" : "0";
        $vars['today'] = Date::getToday();
        $vars['breadCrumb'] = [[inventoryModel::getmsg('accounting_sys'), 'ACC'], [inventoryModel::getmsg('vat_report'), 'customer_supplier_vat_report']];
        $this->load->view('Accounting/customer_supplier_vat_report', $vars);
    }

    public function check_due_dates_report() {
        $vars['title'] = ACCModel::getmsg('check_due_dates');
        $vars['system_name'] = ACCModel::getmsg('check_due_dates');
        $url = explode('/', $_SERVER['REQUEST_URI']);
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match_a);
        $vars['is_actual'] = count($match_a) > 0 ? true : false;
        $vars['today'] = Date::getToday();
        $vars['pageName'] = $vars['is_actual'] ? 'act_check_due_dates_report' : 'check_due_dates_report';
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], $vars['is_actual'] ? [ACCModel::getmsg('act_check_due_dates'), 'check_due_dates_report/act'] : [ACCModel::getmsg('check_due_dates'), 'check_due_dates_report']];
        $this->load->view('Accounting/check_due_dates_report', $vars);
    }

    public function manual_jv_list() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['today'] = Date::gettoday();
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match);
        $vars['IsActual'] = count($match) > 0 ? "1" : "0";
        $url = explode('/', $_GET['url']);
        $vars['jv_id'] = is_numeric($url[count($url) - 1]) ? $url[count($url) - 1] : 0;
        $vars['system_name'] = ACCModel::getmsg('daily_journals');
        $vars['pageName'] = $vars['IsActual'] ? 'actual_manual_jv_list' : 'manual_jv_list';
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('manual_jv_list'), 'manual_jv_list' . ($vars['IsActual'] ? '/act' : '')]];
        $this->load->view('Accounting/manual_jv_list', $vars);
    }

    public function create_dynamic_report() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        //        $this->_registry->report->build_dynamic_report(2, '2018-01-01', '2018-12-31', 84,0);
        $vars['system_name'] = ACCModel::getmsg('create_dynamic_report');
        $vars['pageName'] = 'create_dynamic_report';
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('create_dynamic_report'), 'create_dynamic_report']];
        $this->load->view('Accounting/create_dynamic_report', $vars);
    }

    public function view_dynamic_report() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match);

        $vars['is_actual'] = count($match) > 0 ? "1" : "0";
        //get_report_name_by_id
        $url = explode('/', $_SERVER['REQUEST_URI']);
        $vars['report_id'] = is_numeric($url[count($url) - 1]) ? $url[count($url) - 1] : 0;
        $vars['report_name'] = !empty($vars['report_id']) ? $this->_registry->CommonACC->get_report_name_by_id($vars['report_id']) : '';
        //        echo $vars['report_id'].'==='.$vars['report_name'];die();
        //        $this->_registry->report->build_dynamic_report(2, '2018-01-01', '2018-12-31', 84,0);
        $vars['stock_blocks'] = $this->_registry->CommonACC->get_dynamic_report_stock_rows($vars['report_id']);
        $vars['methods'] = CommonFunctions::CommonView('tbl_stock_pricing_methods');
        $begin_acc = smc_session()['account_setting']['begining_stock_account_id'];
        $vars['begining_acc'] = JV::getAccountNameByID($begin_acc);
        $end_acc = smc_session()['account_setting']['end_stock_account_id'];
        $vars['end_acc'] = JV::getAccountNameByID($end_acc);
        $vars['system_name'] = ACCModel::getmsg('view_dynamic_report');
        $vars['pageName'] = 'view_dynamic_report';
        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
        $vars['defCurrencyName'] = $this->_registry->currency->getCurrencyNameByID($defCurrency_Id);
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('view_dynamic_report'), 'view_dynamic_report']];
        $this->load->view('Accounting/view_dynamic_report', $vars);
    }

    public function project_list() {
        $vars['pageName'] = 'project_list';
        $vars['title'] = inventoryModel::getmsg('projects');
        $vars['system_name'] = inventoryModel::getmsg('projects');
        $vars['breadCrumb'] = [[inventoryModel::getmsg('accounting_sys'), 'ACC'],
            [inventoryModel::getmsg('projects'), 'job_list']];
        $this->load->view('Accounting/project_list', $vars);
    }

    public function activity_tree() {
        $vars['pageName'] = 'activity_tree';
        $vars['title'] = inventoryModel::getmsg('activity_tree');
        $vars['system_name'] = inventoryModel::getmsg('activity_tree');
        $vars['breadCrumb'] = [[inventoryModel::getmsg('accounting_sys'), 'ACC'],
            [inventoryModel::getmsg('activity_tree'), 'activity_tree']];
        $this->load->view('Accounting/activity_tree', $vars);
    }

    public function project_period() {
        $vars['pageName'] = 'project_period';
        $vars['title'] = inventoryModel::getmsg('project_period');
        $vars['system_name'] = inventoryModel::getmsg('project_period');
        $vars['breadCrumb'] = [[inventoryModel::getmsg('accounting_sys'), 'ACC'],
            [inventoryModel::getmsg('project_period'), 'project_period']];
        $this->load->view('Accounting/project_period', $vars);
    }

    public function activity_budget() {
        $vars['pageName'] = 'activity_budget';
        $vars['title'] = inventoryModel::getmsg('activity_budget');
        $vars['system_name'] = inventoryModel::getmsg('activity_budget');
        $vars['breadCrumb'] = [[inventoryModel::getmsg('accounting_sys'), 'ACC'],
            [inventoryModel::getmsg('activity_budget'), 'activity_budget']];
        $this->load->view('Accounting/activity_budget', $vars);
    }

    public function project_funding() {
        $url = explode('/', $_SERVER['REQUEST_URI']);
        $vars['is_edit'] = is_numeric($url[count($url) - 1]) ? true : false;
        $vars['project_funding_id'] = $vars['is_edit'] ? $url[count($url) - 1] : 0;
        $vars['edit_arr'] = $vars['is_edit'] ? $this->_registry->project->get_project_funding($vars['project_funding_id']) : array();
        //        echo"<pre>";die(print_r($vars['edit_arr']));
        $vars['pageName'] = $vars['is_edit'] ? 'edit_project_funding' : 'add_project_funding';
        $vars['title'] = inventoryModel::getmsg($vars['is_edit'] ? 'edit_project_funding' : 'add_project_funding');
        $vars['system_name'] = inventoryModel::getmsg($vars['is_edit'] ? 'edit_project_funding' : 'add_project_funding');
        $vars['breadCrumb'] = [[inventoryModel::getmsg('accounting_sys'), 'ACC'],
            [inventoryModel::getmsg($vars['is_edit'] ? 'edit_project_funding' : 'add_project_funding'), 'project_funding' . ($vars['is_edit'] ? ('/' . $vars['project_funding_id']) : '')]];
        $this->load->view('Accounting/project_funding', $vars);
    }

    public function project_funding_list() {
        $vars['pageName'] = 'project_funding_list';
        $vars['title'] = inventoryModel::getmsg('project_funding_list');
        $vars['system_name'] = inventoryModel::getmsg('project_funding_list');
        $vars['breadCrumb'] = [[inventoryModel::getmsg('accounting_sys'), 'ACC'],
            [inventoryModel::getmsg('project_funding_list'), 'project_funding_list']];
        $this->load->view('Accounting/project_funding_list', $vars);
    }

    public function project_expense() {
        $url = explode('/', $_SERVER['REQUEST_URI']);
        $vars['is_edit'] = is_numeric($url[count($url) - 1]) ? true : false;
        $vars['project_expense_id'] = $vars['is_edit'] ? $url[count($url) - 1] : 0;
        $vars['edit_data'] = $vars['is_edit'] ? $this->_registry->project->get_project_expense($vars['project_expense_id']) : array();
        $vars['check_lock'] = $vars['is_edit'] ? CommonFunctions::check_lock_data(['type' => 'project_expense', 'start_date' => $vars['edit_data']['main']['start_date'], 'is_actual' => 0]) : '';
//        echo"<pre>";die(print_r($vars['edit_data']));
        $vars['currency_list'] = $this->_registry->currency->getAllCurrencies();
        $vars['today'] = Date::gettoday();
        $vars['DefaultCurrencyID'] = $this->_registry->currency->getDefaultCurrency();
        $DefaultCurSymbol = CurrencyFactory::getDefaultCurrencySymbol();
        $DefaultCurName = $this->_registry->currency->getCurrencyNameByID($vars['DefaultCurrencyID']);
        $vars['currency_symbol'] = $DefaultCurName . ' ' . $DefaultCurSymbol;
        $vars['CurList'] = CurrencyFactory::GetLIListCurrency();
        $vars['Extable'] = $this->_registry->currency->getExchangeRateTable();

        $vars['pageName'] = $vars['is_edit'] ? 'edit_project_expense' : 'add_project_expense';
        $vars['title'] = inventoryModel::getmsg($vars['is_edit'] ? 'edit_project_expense' : 'add_project_expense');
        $vars['system_name'] = inventoryModel::getmsg($vars['is_edit'] ? 'edit_project_expense' : 'add_project_expense');
        if (!$vars['is_edit']) {
//            $vars['unique_id'] = 'pexp' . uniqid();
//            smc_session()['duplicate_check'][$vars['unique_id']] = true;
            $vars['unique_id'] = token_unique::generate_token('pexp');
        }
        $vars['breadCrumb'] = [[inventoryModel::getmsg('accounting_sys'), 'ACC'],
            [inventoryModel::getmsg($vars['is_edit'] ? 'edit_project_expense' : 'add_project_expense'), 'project_expense' . ($vars['is_edit'] ? ('/' . $vars['project_expense_id']) : '')]];
        $this->load->view('Accounting/project_expense', $vars);
    }

    public function project_expense_list() {
        $vars['pageName'] = 'project_expense_list';
        $vars['title'] = inventoryModel::getmsg('project_expense_list');
        $vars['system_name'] = inventoryModel::getmsg('project_expense_list');
        $vars['breadCrumb'] = [[inventoryModel::getmsg('accounting_sys'), 'ACC'],
            [inventoryModel::getmsg('project_expense_list'), 'project_expense_list']];
        $this->load->view('Accounting/project_expense_list', $vars);
    }

    public function view_project_expense() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('view_project_expense');
        $url = explode('/', $_GET['url']);
        $id = $url[count($url) - 1];
        $data = $this->_registry->project->get_project_expense($id);
//        echo '<pre>';
//        print_r($data);
        $vars['pageName'] = 'view_project_expense';
        $template_row = Forms::build_print_template('project_expense', $data['main'], array('details' => $data['details']));
        $this->load->view_html($template_row['html'], $vars);
        exit;
    }

    public function project_period_report() {
        $vars['pageName'] = 'project_period_report';
        $vars['title'] = inventoryModel::getmsg('project_period_report');
        $vars['system_name'] = inventoryModel::getmsg('project_period_report');
        $vars['breadCrumb'] = [[inventoryModel::getmsg('accounting_sys'), 'ACC'],
            [inventoryModel::getmsg('project_period_report'), 'project_period_report']];
        $this->load->view('Accounting/project_period_report', $vars);
    }

    public function schedule_bills() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match);
        $vars['is_actual'] = count($match) > 0 ? 1 : 0;
        $vars['system_name'] = ACCModel::getmsg('schedule_bills');
        $url = explode('/', $_SERVER['REQUEST_URI']);
        $vars['is_edit'] = is_numeric($url[count($url) - 1]) ? true : false;
        $vars['get_parameters'] = $_GET;
        $vars['bill_id'] = $vars['is_edit'] ? $url[count($url) - 1] : 0;
        //        $this->_registry->payment->import_bills();
        $vars['edit_arr'] = $this->_registry->payment->getScheduleBillsData($vars['bill_id']);
//        echo"<pre>";die(print_r($vars['edit_arr']));
        $vars['check_lock'] = $vars['is_edit'] ? CommonFunctions::check_lock_data(['type' => 'schedule_bill', 'start_date' => $vars['edit_arr']['main']['bill_date'], 'is_actual' => $vars['is_actual']]) : '';

        $vars['pageName'] = 'new_schedule_bills';
        $vars['CurList'] = CurrencyFactory::GetLIListCurrency();
        $vars['default_currency_id'] = CurrencyFactory::getDefaultCurrency();
        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($vars['default_currency_id']);
        $vars['defCurrencyName'] = $this->_registry->currency->getCurrencyNameByID($vars['default_currency_id']);
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('schedule_bills'), 'schedule_bills']];
        $this->load->view('Accounting/schedule_bills', $vars);
    }

    public function schedule_bills_list() {
        $vars['pageName'] = 'schedule_bills_list';
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match);
        $vars['is_actual'] = count($match) > 0 ? "1" : "0";
        $vars['title'] = inventoryModel::getmsg('schedule_bills_list');
        $vars['system_name'] = inventoryModel::getmsg('schedule_bills_list');
        $vars['breadCrumb'] = [[inventoryModel::getmsg('accounting_sys'), 'ACC'], [inventoryModel::getmsg('schedule_bills_list'), 'schedule_bills_list']];
        $this->load->view('Accounting/schedule_bills_list', $vars);
    }

    public function payment_due_date_bills() {
        $vars['pageName'] = 'payment_due_date_bills';
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match);
        $vars['is_actual'] = count($match) > 0 ? "1" : "0";
        $vars['payment_type'] = $this->_registry->payment->viewPaymentTypes();
        $vars['currency_list'] = $this->_registry->currency->getAllCurrencies();
        $vars['Extable'] = $this->_registry->currency->getExchangeRateTable();

        $vars['title'] = inventoryModel::getmsg('payment_due_date_bills');
        $vars['system_name'] = inventoryModel::getmsg('payment_due_date_bills');
        $vars['breadCrumb'] = [[inventoryModel::getmsg('accounting_sys'), 'ACC'], [inventoryModel::getmsg('payment_due_date_bills'), 'payment_due_date_bills']];
        $this->load->view('Accounting/payment_due_date_bills', $vars);
    }

    public function statament_of_project() {
        $vars['system_name'] = ACCModel::getmsg('statament_of_project');
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match_act);
        $vars['is_actual'] = count($match_act) > 0 ? 1 : 0;
        preg_match("/\/atv/", $_SERVER['REQUEST_URI'], $match_activity);
        $vars['is_activity'] = count($match_activity) > 0 ? 1 : 0;
        $vars['users'] = CommonFunctions::CommonView('tbl_common_users');
        $url = explode('/', $_SERVER['REQUEST_URI']);
        $vars['project_id'] = is_numeric($url[count($url) - 1]) ? $url[count($url) - 1] : 0;
        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
        $vars['defCurrencyName'] = $this->_registry->currency->getCurrencyNameByID($defCurrency_Id);
        $vars['today'] = Date::getToday();
        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today
        $vars['from_day'] = smc_session()['start_date']; // $vars['year'] . '-01-01';
        $vars['pageName'] = $vars['is_activity'] ? ($vars['is_actual'] ? 'act_statement_of_project_per_activity' : 'statement_of_project_per_activity') : ($vars['is_actual'] ? 'act_statament_of_project' : 'statament_of_project');
        $vars['title'] = ACCModel::getmsg($vars['pageName']);
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [$vars['title'], 'statament_of_project' . ($vars['is_activity'] ? '/activity' : '') . ($vars['is_actual'] ? '/act' : '')]];
        $this->load->view('Accounting/statament_of_project', $vars);
    }

    public function project_trial_balance() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('trial_balance');
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match);
        $vars['Is_Actual'] = count($match) > 0 ? "1" : "0";
        $vars['pageName'] = $vars['Is_Actual'] ? 'act_project_trial_balance' : 'project_trial_balance';
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg($vars['Is_Actual'] ? 'act_project_trial_balance' : 'project_trial_balance'), $vars['Is_Actual'] ? 'project_trial_balance/act' : 'project_trial_balance']];
        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
        $vars['defCurrencyName'] = $this->_registry->currency->getCurrencyNameByID($defCurrency_Id);
        $vars['today'] = Date::getToday();
        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today 
        $vars['from_day'] = smc_session()['start_date']; //$vars['year'] . '-01-01';
        $this->load->view('Accounting/project_trial_balance', $vars);
    }

    public function view_schedule_bills() {
        $vars['pageName'] = 'view_schedule_bills';

        $vars['title'] = inventoryModel::getmsg('schedule_bills');
        $url = explode('/', $_GET['url']);

        $bill_id = $url[count($url) - 1];
        $data = $this->_registry->payment->getScheduleBillsData($bill_id);
        //        echo '<pre>';
        //        print_r($data);
        //        die('ok');
        $template_key = 'schedule_bills';
        $template_row = Forms::build_print_template($template_key, $data['main'], array('bill_detail' => $data['details']));

        echo $template_row['html'];
        echo '<script src="' . SITE_LINK . '/Theme/plugins/jquery/jquery-2.1.1.js" type="text/javascript"></script>';
        exit;
    }

    public function dynamic_report_blocks() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        //        $this->_registry->report->build_dynamic_report(2, '2018-01-01', '2018-12-31', 84,0);
        $vars['system_name'] = ACCModel::getmsg('dynamic_report_blocks');
        $vars['pageName'] = 'dynamic_report_blocks';
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('dynamic_report_blocks'), 'dynamic_report_blocks']];
        $this->load->view('Accounting/dynamic_report_blocks', $vars);
    }

    public function statement_pos_customer() {
        $vars['title'] = ACCModel::getmsg('statament_pos_customer');
        $vars['system_name'] = ACCModel::getmsg('statament_pos_customer');
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match_act);
        $vars['is_actual'] = count($match_act) > 0 ? 1 : 0;
        $vars['users'] = CommonFunctions::CommonView('tbl_common_users');
        $url = explode('/', $_SERVER['REQUEST_URI']);
        $vars['pos_customer_id'] = is_numeric($url[count($url) - 1]) ? $url[count($url) - 1] : 0;
        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
        $vars['defCurrencyName'] = $this->_registry->currency->getCurrencyNameByID($defCurrency_Id);
        $vars['today'] = Date::getToday();
        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today
        $vars['from_day'] = smc_session()['start_date']; // $vars['year'] . '-01-01';
        $vars['pageName'] = $vars['is_actual'] ? 'act_statement_pos_customer' : 'statement_pos_customer';
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('statement_pos_customer'), $vars['is_actual'] ? 'statement_pos_customer/act' : 'statement_pos_customer']];
        $this->load->view('Accounting/statement_pos_customer', $vars);
    }

    public function pos_customer_trial_balance() {
        $vars['title'] = ACCModel::getmsg('accounting_sys');
        $vars['system_name'] = ACCModel::getmsg('trial_balance');
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match);
        $vars['Is_Actual'] = count($match) > 0 ? "1" : "0";
        $vars['pageName'] = $vars['Is_Actual'] ? 'act_pos_customer_trial_balance' : 'pos_customer_trial_balance';
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg($vars['Is_Actual'] ? 'act_pos_customer_trial_balance' : 'pos_customer_trial_balance'), $vars['Is_Actual'] ? 'pos_customer_trial_balance/act' : 'pos_customer_trial_balance']];
        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
        $vars['defCurrencyName'] = $this->_registry->currency->getCurrencyNameByID($defCurrency_Id);
        $vars['today'] = Date::getToday();
        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today 
        $vars['from_day'] = smc_session()['start_date']; //$vars['year'] . '-01-01';
        $this->load->view('Accounting/pos_customer_trial_balance', $vars);
    }

    public function addPrepaid() {


        preg_match("/\/Income/", $_SERVER['REQUEST_URI'], $match);
        $vars['Income'] = count($match) > 0 ? true : false;
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match_act);
        $vars['Is_Actual'] = count($match_act) > 0 ? "1" : "0";
        $vars['title'] = CommonLanguage::getMessage($vars['Income'] ? ($vars['Is_Actual'] ? 'prepaid_income_actual' : 'addPrepaid') : ($vars['Is_Actual'] ? 'prepaid_expenses_actual' : 'prepaid_expense'));
        $vars['pageName'] = $vars['Income'] ? ($vars['Is_Actual'] ? 'addPrepaidIncomeActual' : 'addPrepaidIncome') : ($vars['Is_Actual'] ? 'addPrepaidActual' : 'addPrepaid');

        $vars['system_name'] = 'JV System';
        $vars['today'] = Date::gettoday();
        $url = explode('/', $_SERVER['REQUEST_URI']);
        $vars['IsEdit'] = is_numeric($url[count($url) - 1]) ? 1 : 0;

        $vars['id'] = $vars['IsEdit'] ? $url[count($url) - 1] : 0;
        $vars['edit_arr'] = $vars['IsEdit'] ? $this->_registry->jv->viewPrepaidByType($vars['Income'] ? 0 : 1, $vars['id']) : array();
        $vars['edit_arr'] = $vars['IsEdit'] && !empty($vars['edit_arr'][0]) ? $vars['edit_arr'][0] : array();
//                echo"<pre>";
//                die(print_r($vars['edit_arr']));
        $vars['check_lock'] = $vars['IsEdit'] ? CommonFunctions::check_lock_data(['type' => 'prepaid', 'start_date' => $vars['edit_arr']['Start_Date'], 'is_actual' => $vars['Is_Actual']]) : '';

        $vars['CurList'] = CurrencyFactory::GetLIListCurrency();

        $vars['payment_types'] = $this->_registry->jv->viewPaymentTypes();
        $vars['DefaultCurrencyID'] = $this->_registry->currency->getDefaultCurrency();
        $vars['DefaultCurrencySymbol'] = $this->_registry->currency->viewCurrencySymbol($vars['DefaultCurrencyID']);

        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('jv'), ''], [$vars['title'], 'addPrepaid' . ($vars['Income'] ? '/Income' : '') . ($vars['Is_Actual'] ? '/act' : '')]];
        $this->load->view('Accounting/addPrepaid', $vars);
    }

    public function collection_list() {
        $vars['system_name'] = ACCModel::getmsg('collection');
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match);
        $vars['is_actual'] = count($match) > 0 ? 1 : 0;
        $vars['title'] = CommonLanguage::getMessage($vars['is_actual'] ? 'act_collection_list' : 'collection_list');
        $vars['pageName'] = $vars['is_actual'] ? 'act_collection_list' : 'collection_list';
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [$vars['title'], 'collection_list' . ($vars['is_actual'] == 1 ? '/act' : '')]];
        $vars['today'] = Date::getToday();
        $vars['currency_list'] = $this->_registry->currency->getAllCurrencies();

        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today 
        $vars['from_day'] = smc_session()['start_date']; //$vars['year'] . '-01-01';
        $this->load->view('Accounting/collection_list', $vars);
    }

    public function statement_activity() {
        $vars['title'] = ACCModel::getmsg('statement_activity');
        $vars['system_name'] = ACCModel::getmsg('statement_activity');
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match_act);
        $vars['is_actual'] = count($match_act) > 0 ? 1 : 0;
        $vars['users'] = CommonFunctions::CommonView('tbl_common_users');
        $url = explode('/', $_SERVER['REQUEST_URI']);
        $vars['activity_id'] = is_numeric($url[count($url) - 1]) ? $url[count($url) - 1] : 0;
        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
        $vars['defCurrencyName'] = $this->_registry->currency->getCurrencyNameByID($defCurrency_Id);
        $vars['today'] = Date::getToday();
        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today
        $vars['from_day'] = smc_session()['start_date']; // $vars['year'] . '-01-01';
        $vars['pageName'] = $vars['is_actual'] ? 'act_statement_activity' : 'statement_activity';
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [ACCModel::getmsg('statement_activity'), $vars['is_actual'] ? 'statement_activity/act' : 'statement_activity']];
        $this->load->view('Accounting/statement_activity', $vars);
    }

    public function activity_trial_balance() {
        $vars['system_name'] = ACCModel::getmsg('trial_balance');
        preg_match("/\/actu/", $_SERVER['REQUEST_URI'], $match);
        $vars['Is_Actual'] = count($match) > 0 ? 1 : 0;
        $vars['title'] = ACCModel::getmsg($vars['Is_Actual'] ? 'act_activity_trial_balance' : 'activity_trial_balance');
        $vars['pageName'] = $vars['Is_Actual'] ? 'act_activity_trial_balance' : 'activity_trial_balance';
        //          echo $vars['pageName'].'<br>';
        //        die('ok');
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [$vars['title'], $vars['Is_Actual'] ? 'activity_trial_balance/act' : 'activity_trial_balance']];
        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
        $vars['defCurrencyName'] = $this->_registry->currency->getCurrencyNameByID($defCurrency_Id);
        $vars['today'] = Date::getToday();
        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today 
        $vars['from_day'] = smc_session()['start_date']; //$vars['year'] . '-01-01';
        $this->load->view('Accounting/activity_trial_balance', $vars);
    }

    public function project_activities_report() {
        $vars['system_name'] = ACCModel::getmsg('project_activities_report');
        preg_match("/\/act/", $_SERVER['REQUEST_URI'], $match);
        $vars['Is_Actual'] = count($match) > 0 ? "1" : "0";
        $vars['title'] = ACCModel::getmsg($vars['Is_Actual'] ? 'act_project_activities_report' : 'project_activities_report');
        $vars['pageName'] = $vars['Is_Actual'] ? 'act_project_activities_report' : 'project_activities_report';
        $vars['breadCrumb'] = [[ACCModel::getmsg('accounting'), 'ACC'], [$vars['title'], $vars['Is_Actual'] ? 'project_activities_report/act' : 'project_activities_report']];
        //        $defCurrency_Id = CurrencyFactory::getDefaultCurrency();
        //        $vars['defCurrencySymbol'] = CurrencyFactory::getCurrencySymbol($defCurrency_Id);
        //        $vars['defCurrencyName'] = $this->_registry->currency->getCurrencyNameByID($defCurrency_Id);
        $vars['today'] = Date::getToday();
        $vars['year'] = date("Y", strtotime($vars['today'])); // get the year from today 
        $vars['from_day'] = smc_session()['start_date']; //$vars['year'] . '-01-01';
        $this->load->view('Accounting/project_activities_report', $vars);
    }

}
