BBnepal-Accounts/account/application/controllers/accounts/Ledger.php
2024-08-14 21:39:12 +05:45

112 lines
5.6 KiB
PHP

<?php
defined('BASEPATH') or exit('No direct script access allowed');
class Ledger 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 'navigate':
$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/navigate", $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 'partyledger':
$data['pageTitle'] = "View Party Ledger";
// $_GET['show_ledger'];
if (isset($_GET['show_ledger'])) {
$fromDate_Nepali = $_GET['from_date'];
$toDate_Nepali = $_GET['to_date'];
$data['fromDate'] = NepaliToEnglishDate($fromDate_Nepali);
$data['toDate'] = NepaliToEnglishDate($toDate_Nepali);
$data['fromDate_Nepali'] = $fromDate_Nepali;
$data['toDate_Nepali'] = $toDate_Nepali;
$data['account_id'] = $_GET['account_id'];
}
loadView("accounts/ledger/partywise", $data);
break;
case 'print':
$account_id = $this->uri->segment(4);
$fromDate=(isset($_GET['from_date'])?$_GET['from_date']:NepaliDate(($this->session->userdata('FiscalYear'))->fiscalyear_from));
$toDate=(isset($_GET['to_date'])?$_GET['to_date']:NepaliDate(($this->session->userdata('FiscalYear'))->fiscalyear_to));
$LedgerPDF=$this->myaccounts->ledgerPDF($account_id,NepaliToEnglishDate($fromDate), NepaliToEnglishDate($toDate));
$data['PDFFile']=site_url("pdf/ledgers/".$LedgerPDF);
if(isset($_GET['modal']))
$this->load->view("accounts/pdfviewer",$data);
else
loadView("accounts/pdfviewer",$data);
break;
case 'getaccountbalance':
$account_id = $this->uri->segment(4);
$AccountDetails=$this->myaccounts->getAccountDetails($account_id);
$AccountDetails->BalanceRaw=$AccountDetails->Balance;
$AccountDetails->Balance=myCurrency($AccountDetails->Balance);
echo json_encode($AccountDetails);
break;
case 'day_book':
$data['pageTitle'] = "Day Book";
loadView("accounts/daybook", $data);
break;
case 'bank_book':
$data['fiscalStart'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_from);
$data['fiscalEnd'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_to);
$data['pageTitle'] = "Bank Book";
loadView("accounts/ledger_bankbook", $data);
break;
case 'cash_book':
$data['fiscalStart'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_from);
$data['fiscalEnd'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_to);
$data['pageTitle'] = "Cash Book";
loadView("accounts/ledger_cashbook", $data);
break;
case 'receiveables':
$data['pageTitle'] = "Accounts Receivables";
loadView("accounts/ledger_receiveables", $data);
break;
case 'payables':
$data['pageTitle'] = "Accounts Payables";
loadView("accounts/ledger_payables", $data);
break;
default:
$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;
}
}
}