BBnepal-Accounts/account/application/controllers/accounts/Ledger.php

157 lines
8.0 KiB
PHP
Raw Normal View History

2024-07-10 12:43:19 +00:00
<?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;
2024-09-29 11:14:27 +00:00
// echo "<pre>"; print_r($_GET['accategory_id']);die();
2024-07-10 12:43:19 +00:00
$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) {
2024-09-29 11:14:27 +00:00
// $AccountGroup->AccountCategories = $this->db->where("status", 1)->where("acgroup_id", $AccountGroup->acgroup_id)->get("tbl_accategories")->result();
$AccountGroup->AccountCategories = $this->db->where("status", 1)->where("accategory_id ", ($_GET['accategory_id'] ?? ""))->get("tbl_accategories")->result();
2024-07-10 12:43:19 +00:00
}
$data['AccountGroups'] = $AccountGroups;
2024-09-29 11:14:27 +00:00
// echo "<pre>"; print_r($data['AccountGroups']);die();
2024-07-10 12:43:19 +00:00
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':
2024-09-29 11:14:27 +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
// $_GET['show_ledger'];
2024-09-29 11:14:27 +00:00
if (!isset($_GET['from_date'])) {
$data['from_date'] = null;
}
if (!isset($_GET['to_date'])) {
$data['to_date'] = null;
}
if (isset($_GET)) {
2024-10-07 05:56:27 +00:00
$data = $_GET;
2024-09-29 11:14:27 +00:00
}
$data['pageTitle'] = "View Party Ledger";
$data['fiscalStart'] = NepaliToEnglishDate($data['fromDate'] ?? $this->session->userdata['FiscalYear']->fiscalyear_from);
$data['fiscalEnd'] = NepaliToEnglishDate($data['toDate'] ?? $this->session->userdata['FiscalYear']->fiscalyear_to);
2024-07-10 12:43:19 +00:00
if (isset($_GET['show_ledger'])) {
2024-09-29 11:14:27 +00:00
$fromDate_Nepali=$data['from_date'];
$toDate_Nepali =$data['to_date'];
2024-07-10 12:43:19 +00:00
$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;
2024-09-29 11:14:27 +00:00
case 'print':
2024-07-10 12:43:19 +00:00
$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':
2024-09-29 11:14:27 +00:00
if (!isset($_POST['fromDate'])) {
$data['fromDate'] = null;
}
if (!isset($_POST['toDate'])) {
$data['toDate'] = null;
}
if (isset($_POST)) {
$data = $_POST;
}
$data['fiscalStart'] = NepaliToEnglishDate($data['fromDate'] ?? $this->session->userdata['FiscalYear']->fiscalyear_from);
$data['fiscalEnd'] = NepaliToEnglishDate($data['toDate'] ?? $this->session->userdata['FiscalYear']->fiscalyear_to);
// $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'] = "Bank Book";
loadView("accounts/ledger_bankbook", $data);
break;
case 'cash_book':
2024-09-29 11:14:27 +00:00
if (!isset($_POST['fromDate'])) {
$data['fromDate'] = null;
}
if (!isset($_POST['toDate'])) {
$data['toDate'] = null;
}
if (isset($_POST)) {
$data = $_POST;
}
$data['fiscalStart'] = NepaliToEnglishDate($data['fromDate'] ?? $this->session->userdata['FiscalYear']->fiscalyear_from);
$data['fiscalEnd'] = NepaliToEnglishDate($data['toDate'] ?? $this->session->userdata['FiscalYear']->fiscalyear_to);
// $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 Book";
loadView("accounts/ledger_cashbook", $data);
break;
case 'receiveables':
2024-08-12 10:36:46 +00:00
$data['pageTitle'] = "Accounts Receivables";
2024-07-10 12:43:19 +00:00
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;
}
}
}