2024-07-10 12:43:19 +00:00
|
|
|
<?php
|
|
|
|
defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
class Reports extends CI_Controller
|
|
|
|
{
|
|
|
|
function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
$this->load->helper("accounts");
|
|
|
|
checkLogin();
|
|
|
|
}
|
|
|
|
public function _remap($alias = "", $params = array())
|
|
|
|
{
|
|
|
|
$data['dataValue'] = $this->session;
|
|
|
|
$data['pageTitle'] = "Account Head";
|
|
|
|
switch ($alias) {
|
|
|
|
case 'accounts':
|
|
|
|
$data['pageTitle'] = "List of Accounts";
|
|
|
|
loadView("accounts/accounts/list", $data);
|
|
|
|
break;
|
|
|
|
case 'ledger':
|
|
|
|
$data['pageTitle'] = "Ledger";
|
|
|
|
$AccountGroups = $this->db->where("status", 1)->get("tbl_acgroups")->result();
|
|
|
|
foreach ($AccountGroups as $AccountGroup) {
|
|
|
|
$AccountGroup->AccountCategories = $this->db->where("status", 1)->where("acgroup_id", $AccountGroup->acgroup_id)->get("tbl_accategories")->result();
|
|
|
|
}
|
|
|
|
$data['AccountGroups'] = $AccountGroups;
|
|
|
|
loadView("accounts/ledger", $data);
|
|
|
|
break;
|
|
|
|
case 'ledgerall':
|
|
|
|
$data['pageTitle'] = "Ledger";
|
|
|
|
$Accounts = $this->db->where("status", 1)->get("tbl_accounts")->result();
|
|
|
|
foreach ($Accounts as $Account) :
|
|
|
|
|
|
|
|
|
|
|
|
endforeach;
|
|
|
|
$AccountGroups = $this->db->where("status", 1)->get("tbl_acgroups")->result();
|
|
|
|
$data['Accounts'] = $Accounts;
|
|
|
|
$data['AccountGroups'] = $AccountGroups;
|
|
|
|
loadView("accounts/ledgerall", $data);
|
|
|
|
break;
|
|
|
|
case 'getledgersummary':
|
|
|
|
$account_id = $this->uri->segment(3);
|
|
|
|
$data['pageTitle'] = "Ledger";
|
|
|
|
$Transactions = $this->db->where("status", 1)->where("account_id", $account_id)->get("tbl_voucherdetails")->result();
|
|
|
|
$Account = $this->db->where("status", 1)->where("account_id", $account_id)->get("tbl_accounts")->row();
|
|
|
|
foreach ($Transactions as $T) {
|
|
|
|
// $T->AccountCategory=$this->db->where("status",1)->where("accategory_id",$AccountGroup->acgroup_id)->get("tbl_accategories")->result();
|
|
|
|
$T->Voucher = $this->db->where("status", 1)->where("voucher_id", $T->voucher_id)->get("tbl_vouchers")->row();
|
|
|
|
}
|
|
|
|
$data['Transactions'] = $Transactions;
|
|
|
|
$data['Account'] = $Account;
|
|
|
|
$data['account_id'] = $account_id;
|
|
|
|
$this->load->view("accounts/ledgersummary", $data);
|
|
|
|
break;
|
|
|
|
case 'trialbalance_old':
|
|
|
|
$data['pageTitle'] = "Trial Balance";
|
|
|
|
$AccountGroups = $this->db->where("status", 1)->get("tbl_acgroups")->result();
|
|
|
|
foreach ($AccountGroups as $AccountGroup) {
|
|
|
|
$AccountGroup->AccountCategories = $this->db->where("status", 1)->where("acgroup_id", $AccountGroup->acgroup_id)->get("tbl_accategories")->result();
|
|
|
|
foreach ($AccountGroup->AccountCategories as $AccountCategory) {
|
|
|
|
$AccountCategory->Accounts = $this->db->where("status", 1)->where("accategory_id", $AccountCategory->accategory_id)->get("tbl_accounts")->result();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$data['AccountGroups'] = $AccountGroups;
|
|
|
|
loadView("accounts/trialbalance", $data);
|
|
|
|
break;
|
|
|
|
case 'trialbalance':
|
2024-08-08 11:50:09 +00:00
|
|
|
$data['fiscalStart'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_from);
|
|
|
|
$data['fiscalEnd'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_to);
|
2024-07-10 12:43:19 +00:00
|
|
|
$data['pageTitle'] = "Trial Balance";
|
|
|
|
loadView("accounts/trialbalance_new", $data);
|
|
|
|
break;
|
|
|
|
case 'trialbalance_raw':
|
|
|
|
$data['pageTitle'] = "Trial Balance";
|
|
|
|
|
|
|
|
|
|
|
|
loadView("accounts/trialbalance_raw", $data);
|
|
|
|
break;
|
|
|
|
case 'trialbalance_table':
|
|
|
|
$data['pageTitle'] = "Trial Balance";
|
|
|
|
|
|
|
|
loadView("accounts/trialbalance_table", $data);
|
|
|
|
break;
|
|
|
|
case 'show_voucher':
|
|
|
|
$data['voucher_id'] = $this->uri->segment(4);
|
|
|
|
loadView("accounts/vouchers/show_voucher", $data);
|
|
|
|
break;
|
|
|
|
case 'balance_by_type':
|
|
|
|
$data['pageTitle'] = "Account Balances By Types";
|
|
|
|
loadView("accounts/balances/bytype", $data);
|
|
|
|
break;
|
|
|
|
case 'balance_by_category':
|
|
|
|
$acgroup_id = 0;
|
|
|
|
$data['pageTitle'] = "Account Balances By Category";
|
|
|
|
if (isset($_GET['group'])) {
|
|
|
|
$acgroup_id = ($_GET['group']) ? $_GET['group'] : 0;
|
|
|
|
}
|
|
|
|
if ($acgroup_id != 0) {
|
|
|
|
$group = getFieldfromValue("tbl_acgroups", "acgroup_name", "acgroup_id", $acgroup_id);
|
|
|
|
$data['pageTitle'] = "Account Balances By " . $group;
|
|
|
|
}
|
|
|
|
$data['acgroup_id'] = $acgroup_id;
|
|
|
|
loadView("accounts/balances/bycategory", $data);
|
|
|
|
break;
|
|
|
|
case 'balance_by_group':
|
|
|
|
$accategory_id = 0;
|
|
|
|
$data['pageTitle'] = "Account Balances By Group";
|
|
|
|
if (isset($_GET['category'])) {
|
|
|
|
$accategory_id = ($_GET['category']) ? $_GET['category'] : 0;
|
|
|
|
}
|
|
|
|
if ($accategory_id != 0) {
|
|
|
|
$group = getFieldfromValue("tbl_accategories", "accategory_name", "accategory_id", $accategory_id);
|
|
|
|
$data['pageTitle'] = "Account Balances By " . $group;
|
|
|
|
}
|
|
|
|
loadView("accounts/balances/bygroup", $data);
|
|
|
|
break;
|
|
|
|
case 'balance_by_ledger':
|
|
|
|
$accategory_id = 0;
|
|
|
|
$data['pageTitle'] = "Account Balances By Group";
|
|
|
|
if (isset($_GET['group'])) {
|
|
|
|
$accategory_id = ($_GET['group']) ? $_GET['group'] : 0;
|
|
|
|
}
|
|
|
|
if ($accategory_id != 0) {
|
|
|
|
$group = getFieldfromValue("tbl_accategories", "accategory_name", "accategory_id", $accategory_id);
|
|
|
|
$data['pageTitle'] = "Account Balances By " . $group;
|
|
|
|
}
|
|
|
|
$data['accategory_id'] = $accategory_id;
|
|
|
|
loadView("accounts/balances/byledger", $data);
|
|
|
|
break;
|
|
|
|
case 'pl_old':
|
|
|
|
$data['pageTitle'] = "Profit & Loss Statement";
|
|
|
|
loadView("accounts/pl", $data);
|
|
|
|
break;
|
|
|
|
case 'pl':
|
2024-08-08 11:50:09 +00:00
|
|
|
$data['fiscalStart'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_from);
|
|
|
|
$data['fiscalEnd'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_to);
|
2024-07-10 12:43:19 +00:00
|
|
|
$data['pageTitle'] = "Profit & Loss Statement";
|
|
|
|
loadView("accounts/pl_new", $data);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'pl_grouped':
|
|
|
|
$data['pageTitle'] = "Profit & Loss Statement";
|
|
|
|
loadView("accounts/bib_pl", $data);
|
|
|
|
break;
|
|
|
|
case 'balance_sheet_old':
|
|
|
|
$data['pageTitle'] = "Balance Sheet";
|
|
|
|
loadView("accounts/balancesheet", $data);
|
|
|
|
break;
|
|
|
|
case 'balance_sheet':
|
2024-08-08 11:50:09 +00:00
|
|
|
$data['fiscalStart'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_from);
|
|
|
|
$data['fiscalEnd'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_to);
|
2024-07-10 12:43:19 +00:00
|
|
|
$data['pageTitle'] = "Balance Sheet";
|
|
|
|
loadView("accounts/balancesheet_new", $data);
|
|
|
|
break;
|
|
|
|
case 'balance_sheet_vertical':
|
|
|
|
$data['pageTitle'] = "Balance Sheet";
|
|
|
|
loadView("accounts/balance_sheet_vertical", $data);
|
|
|
|
break;
|
|
|
|
case 'cash_flow':
|
2024-08-08 11:50:09 +00:00
|
|
|
$data['fiscalStart'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_from);
|
|
|
|
$data['fiscalEnd'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_to);
|
2024-07-10 12:43:19 +00:00
|
|
|
$data['pageTitle'] = "Cash Flow";
|
|
|
|
loadView("accounts/cash_flow", $data);
|
|
|
|
break;
|
|
|
|
case 'receipts_payments':
|
|
|
|
$data['pageTitle'] = "Cash Flow";
|
|
|
|
loadView("accounts/receipts_payments", $data);
|
|
|
|
break;
|
|
|
|
case 'incomes_and_expenses':
|
|
|
|
$data['pageTitle'] = "Cash Flow";
|
|
|
|
loadView("accounts/incomes_expenses", $data);
|
|
|
|
break;
|
|
|
|
case 'receipt_and_payment':
|
2024-08-08 11:50:09 +00:00
|
|
|
$data['fiscalStart'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_from);
|
|
|
|
$data['fiscalEnd'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_to);
|
2024-07-10 12:43:19 +00:00
|
|
|
$data['pageTitle'] = "Cash Flow";
|
|
|
|
loadView("accounts/receipt_and_payment", $data);
|
|
|
|
break;
|
|
|
|
case 'ratio_analysis':
|
|
|
|
$data['pageTitle'] = "Cash Flow";
|
|
|
|
loadView("accounts/ratio_analysis", $data);
|
|
|
|
break;
|
|
|
|
case 'sales_register':
|
|
|
|
$data['pageTitle'] = "Sales Register";
|
|
|
|
loadView("accounts/sales_register", $data);
|
|
|
|
break;
|
|
|
|
case 'purchase_register':
|
|
|
|
$data['pageTitle'] = "Purchase Register";
|
|
|
|
loadView("accounts/purchase_register", $data);
|
|
|
|
break;
|
|
|
|
case 'ajax':
|
|
|
|
$ajaxCommand = $this->uri->segment(4);
|
|
|
|
$this->processAjax($ajaxCommand);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
loadView("accounts/list", $data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private function processAjax($command)
|
|
|
|
{
|
|
|
|
switch ($command) {
|
|
|
|
case 'accountsbycategory':
|
|
|
|
$accategory_id = $this->uri->segment(5);
|
|
|
|
$this->myaccounts->getAccountsTableByCategory($accategory_id);
|
|
|
|
break;
|
|
|
|
case 'getallaccounts':
|
|
|
|
$this->myaccounts->getAllAccountsTable();
|
|
|
|
break;
|
|
|
|
case 'getledgersummary':
|
|
|
|
$account_id = $this->uri->segment(5);
|
|
|
|
$this->myaccounts->showLedger($account_id);
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 'default':
|
|
|
|
//show_404();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|