Compare commits

..

40 Commits

Author SHA1 Message Date
7008ec0310 New changes in BBNepal 2024-10-17 17:06:13 +05:45
4ac5a5e491 bbnepal new changes 2024-10-08 15:47:07 +05:45
ad3e5eb1ec account categories removed 2024-10-07 16:35:08 +05:45
318998d272 changes for bbnepal data 2024-10-07 13:59:13 +05:45
967642f2be changes for bbnepal 2024-10-07 11:41:27 +05:45
e3c8a3b5fe correction of error for purchase and sales 2024-10-04 16:31:02 +05:45
ec6bfaf7ff export excel second 2024-09-30 17:25:58 +05:45
4683fe67a7 export excel 2024-09-30 16:09:29 +05:45
60f4c75eb0 changes for print 2024-09-29 17:46:26 +05:45
684e01bf48 changes for filter and print 2024-09-29 16:59:27 +05:45
497f567cba balancesheet 2024-08-26 17:17:43 +05:45
31e7f8de87 edit 2024-08-26 13:39:34 +05:45
a5d29a202e Merge branch 'main' of http://bibgit.com/sampanna/BBnepal-Accounts 2024-08-26 13:37:02 +05:45
4109787bc4 cash flow 2024-08-26 13:36:59 +05:45
b1c6bad445 profitloss 2024-08-26 13:08:50 +05:45
15b3e542a3 edit balance sheet 2024-08-26 13:04:47 +05:45
cd361f79aa edit profit and loss 2024-08-26 12:35:45 +05:45
759b97e1f0 edit profti and loss 2024-08-26 12:29:38 +05:45
161703be17 edit css 2024-08-25 18:37:52 +05:45
78670b1b95 edit 2024-08-25 16:19:29 +05:45
8c5bfd147b edit css 2024-08-25 16:17:28 +05:45
f488c286bd daterangefix and vouchertextremove 2024-08-21 13:47:09 +05:45
5df46f007d voucher 2024-08-18 12:32:21 +05:45
c9e54804c8 toggle change in randp 2024-08-15 16:14:22 +05:45
cb443cd551 datepicker and toggle buttons changes 2024-08-14 21:39:12 +05:45
ee30970d1f toggle 2024-08-14 13:56:37 +05:45
fe8786f03f changes 2024-08-12 16:21:46 +05:45
16246fbdeb changes 2024-08-11 17:29:32 +05:45
0f5bafdf3e byledger 2024-08-09 17:57:49 +05:45
c64472a21e changes 2024-08-09 15:37:11 +05:45
2ebd3a2ea9 edit 2024-08-09 15:07:46 +05:45
c08ed22b78 edit action column 2024-08-09 14:22:36 +05:45
9ebdd5a858 edit 2024-08-09 12:41:25 +05:45
213be12e2a edit css 2024-08-09 11:53:11 +05:45
e9fc0b8270 edit css and table 2024-08-09 10:00:40 +05:45
169a49c376 edit css 2024-08-09 09:39:49 +05:45
b06ce0569a edit css 2024-08-08 19:07:57 +05:45
e47ff3321d edit css 2024-08-08 18:41:24 +05:45
114e7aa4c2 css edit 2024-08-08 18:27:34 +05:45
c30c5ddcb2 edit css 2024-08-08 18:24:25 +05:45
1398 changed files with 43636 additions and 76382 deletions

4
.env
View File

@ -3,7 +3,7 @@ APP_URL=http://localhost/bbnepal/School-With-Accounts/account/
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3309
DATABASE_OPTIONS=bbnepal_accounting,myurlsco_accounts1,myurlsco_accounts2,myurlsco_accounts3
DB_DATABASE=bbnepal_accounting
DATABASE_OPTIONS=bbnepal_accounting,myurlsco_accounts1,myurlsco_accounts2,myurlsco_accounts3,myurlsco_bbnepal_acc #given
DB_DATABASE=bbnepal_accounting # given
DB_USERNAME=root
DB_PASSWORD=

View File

@ -241,5 +241,8 @@ class Welcome extends CI_Controller
if ($query->num_rows() == 0) {
$this->db->query("ALTER TABLE tbl_accounts ADD COLUMN account_bank VARCHAR(50)");
}
$this->db->query("ALTER TABLE tbl_translations MODIFY COLUMN nepali VARCHAR(255) COLLATE utf8_unicode_ci");
}
}

View File

@ -10,8 +10,8 @@ class Ledger extends CI_Controller
}
public function _remap($alias = "", $params = array())
{
$data['dataValue'] = $this->session;
// echo "<pre>"; print_r($_GET['accategory_id']);die();
$data['pageTitle'] = "Account Head";
switch ($alias) {
@ -19,9 +19,13 @@ class Ledger extends CI_Controller
$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();
// $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();
}
$data['AccountGroups'] = $AccountGroups;
// echo "<pre>"; print_r($data['AccountGroups']);die();
loadView("accounts/ledger/navigate", $data);
break;
case 'getledgersummary':
@ -39,11 +43,27 @@ class Ledger extends CI_Controller
$this->load->view("accounts/ledgersummary", $data);
break;
case 'partyledger':
$data['pageTitle'] = "View Party Ledger";
// $data['fiscalStart'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_from);
// $data['fiscalEnd'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_to);
// $_GET['show_ledger'];
if (!isset($_GET['from_date'])) {
$data['from_date'] = null;
}
if (!isset($_GET['to_date'])) {
$data['to_date'] = null;
}
if (isset($_GET)) {
$data = $_GET;
}
$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);
if (isset($_GET['show_ledger'])) {
$fromDate_Nepali = $_GET['from_date'];
$toDate_Nepali = $_GET['to_date'];
$fromDate_Nepali=$data['from_date'];
$toDate_Nepali =$data['to_date'];
$data['fromDate'] = NepaliToEnglishDate($fromDate_Nepali);
$data['toDate'] = NepaliToEnglishDate($toDate_Nepali);
$data['fromDate_Nepali'] = $fromDate_Nepali;
@ -75,15 +95,44 @@ class Ledger extends CI_Controller
loadView("accounts/daybook", $data);
break;
case 'bank_book':
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);
$data['pageTitle'] = "Bank Book";
loadView("accounts/ledger_bankbook", $data);
break;
case 'cash_book':
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);
$data['pageTitle'] = "Cash Book";
loadView("accounts/ledger_cashbook", $data);
break;
case 'receiveables':
$data['pageTitle'] = "Accounts Receiveables";
$data['pageTitle'] = "Accounts Receivables";
loadView("accounts/ledger_receiveables", $data);
break;
case 'payables':

View File

@ -52,6 +52,25 @@ class Reports extends CI_Controller
$data['account_id'] = $account_id;
$this->load->view("accounts/ledgersummary", $data);
break;
case 'ledgerCashBook':
// $data = $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;
$data['fiscalStart'] = NepaliToEnglishDate($data['fromDate'] ?? $this->session->userdata['FiscalYear']->fiscalyear_from);
$data['fiscalEnd'] = NepaliToEnglishDate($data['toDate'] ?? $this->session->userdata['FiscalYear']->fiscalyear_to);
$this->load->view("accounts/ledger/ledger_cash_book_details",$data);
break;
case 'trialbalance_old':
$data['pageTitle'] = "Trial Balance";
$AccountGroups = $this->db->where("status", 1)->get("tbl_acgroups")->result();
@ -65,8 +84,20 @@ class Reports extends CI_Controller
loadView("accounts/trialbalance", $data);
break;
case 'trialbalance':
$data['fiscalStart'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_from);
$data['fiscalEnd'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_to);
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);
// echo "<pre>"; print_r($data); die();
$data['pageTitle'] = "Trial Balance";
loadView("accounts/trialbalance_new", $data);
break;
@ -116,7 +147,7 @@ class Reports extends CI_Controller
break;
case 'balance_by_ledger':
$accategory_id = 0;
$data['pageTitle'] = "Account Balances By Group";
$data['pageTitle'] = "Account Balances By Ledgers";
if (isset($_GET['group'])) {
$accategory_id = ($_GET['group']) ? $_GET['group'] : 0;
}
@ -132,8 +163,17 @@ class Reports extends CI_Controller
loadView("accounts/pl", $data);
break;
case 'pl':
$data['fiscalStart'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_from);
$data['fiscalEnd'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_to);
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['pageTitle'] = "Profit & Loss Statement";
loadView("accounts/pl_new", $data);
break;
@ -147,8 +187,20 @@ class Reports extends CI_Controller
loadView("accounts/balancesheet", $data);
break;
case 'balance_sheet':
$data['fiscalStart'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_from);
$data['fiscalEnd'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_to);
// $data['fiscalStart'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_from);
// $data['fiscalEnd'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_to);
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['pageTitle'] = "Balance Sheet";
loadView("accounts/balancesheet_new", $data);
break;
@ -157,8 +209,20 @@ class Reports extends CI_Controller
loadView("accounts/balance_sheet_vertical", $data);
break;
case 'cash_flow':
$data['fiscalStart'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_from);
$data['fiscalEnd'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_to);
// $data['fiscalStart'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_from);
// $data['fiscalEnd'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_to);
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['pageTitle'] = "Cash Flow";
loadView("accounts/cash_flow", $data);
break;
@ -171,8 +235,22 @@ class Reports extends CI_Controller
loadView("accounts/incomes_expenses", $data);
break;
case 'receipt_and_payment':
$data['fiscalStart'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_from);
$data['fiscalEnd'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_to);
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);
$data['pageTitle'] = "Cash Flow";
loadView("accounts/receipt_and_payment", $data);
break;
@ -209,8 +287,6 @@ class Reports extends CI_Controller
case 'getledgersummary':
$account_id = $this->uri->segment(5);
$this->myaccounts->showLedger($account_id);
break;
case 'default':
//show_404();

View File

@ -26,6 +26,8 @@ class Vouchers extends CI_Controller
break;
case 'listvouchers':
$data['pageTitle'] = "Vouchers";
$data['fiscalStart'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_from);
$data['fiscalEnd'] = NepaliDate($this->session->userdata['FiscalYear']->fiscalyear_to);
$fromDate_bs = isset($_GET['from_date']) ? $_GET['from_date'] : firstDayOfNepaliMonth();
$todate_bs = isset($_GET['to_date']) ? $_GET['to_date'] : NepaliDate(Today());
$fromDate_ad = NepaliToEnglishDate($fromDate_bs);

View File

@ -50,6 +50,7 @@ class Purchases extends CI_Controller
'items_id' => $item,
'qty' => $_POST['quantity'][$a],
'rate' => $_POST['rate'][$a],
'vat' => $_POST['vat'][$a],
'created_on' => date('Y-m-d H:i:s'),
'created_by' => 'admin',
'remarks' => '',
@ -76,8 +77,8 @@ class Purchases extends CI_Controller
'remarks' => filter_var($_POST['remarks']),
'status' => 1,
);
pre($_POST);
die;
// pre($_POST);
// die;
//$this->db->insert('tbl_purchases', $TableData);
redirect("inventory/purchases/list");
}
@ -93,7 +94,21 @@ class Purchases extends CI_Controller
redirect("inventory/purchases/list");
break;
case 'purchase_register':
$data['PurchaseRecords'] = $this->MPurchases->getPurchaseRecords();
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['pageTitle'] = "Sales & Register";
$data['PurchaseRecords'] = $this->MPurchases->getPurchaseRecords($data['fiscalStart'],$data['fiscalEnd']);
loadView("inventory/purchases/register", $data);
break;

View File

@ -12,14 +12,17 @@ class Reports extends CI_Controller
}
public function _remap($alias = "", $params = array())
{
// dd($this->session);
$data['dataValue'] = $this->session;
$data['pageTitle'] = "Sales";
$datas['fiscalStart'] =NepaliDate($this->session->FiscalYear->fiscalyear_from);
$datas['fiscalEnd'] =NepaliDate($this->session->FiscalYear->fiscalyear_to);
switch ($alias) {
case 'purchase_vs_sales':
$data['StockRecords']=$this->MStocks->getStockRecords();
$data['PurchaseDetails'] = $this->MPurchases->getItemPurchases();
$data['SalesDetails'] = $this->MSales->getItemSales();
$data['StockItems'] = $this->MStocks->getStockSummary();
$data['StockItems'] = $this->MStocks->getStockSummary($datas);
loadview("inventory/reports/purchase_vs_sales", $data);
break;
default:

View File

@ -44,12 +44,13 @@ class Sales extends CI_Controller
// print_r($_POST);die;
foreach ($_POST['item_id'] as $item) {
if ($item != 0 || $_POST['qty'][$i] != 0 || $_POST['rate'][$i] != 0) :
if ($item != 0 || $_POST['qty'][$i] != 0 || $_POST['rate'][$i] != 0 || $_POST['vat'][$i] != 0) :
$TableData = array(
'sales_id' => $sales_id,
'items_id' => $item,
'qty' => $_POST['qty'][$i],
'rate' => $_POST['rate'][$i],
'vat' => $_POST['vat'][$i],
'created_on' => date('Y-m-d H:i:s'),
'created_by' => 'admin',
'status' => 1,
@ -67,7 +68,21 @@ class Sales extends CI_Controller
redirect("inventory/sales/list");
break;
case 'sales_register':
$data['SalesRecords'] = $this->MSales->getSalesRecords();
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['pageTitle'] = "Sales & Register";
$data['SalesRecords'] = $this->MSales->getSalesRecords($data['fiscalStart'],$data['fiscalEnd']);
loadView("inventory/sales/register", $data);
break;
case 'details':
@ -114,7 +129,6 @@ class Sales extends CI_Controller
$data['SalesRecords'] = $this->MSales->getSalesRecords();
loadView("inventory/sales/list", $data);
}
}

View File

@ -6,10 +6,18 @@ class Stocks extends CI_Controller
{
parent::__construct();
$this->load->model('MStocks');
checkLogin();
$this->load->helper('form');
// checkLogin();
}
public function _remap($alias = "", $params = array())
{
// echo "<pre>"; var_dump($alias = "", $params = array()); die();
// echo "<pre>"; var_dump($alias,$this->input->post('fromDate'),$this->input->post('stocklocations_id'),$this->input->post('toDate')); die();
// var_dump(($_POST['stocklocations_id']));die();
$data['dataValue'] = $this->session;
$data['pageTitle'] = "Inventory Stock";
switch ($alias) {
@ -57,8 +65,28 @@ class Stocks extends CI_Controller
loadView("inventory/stocks/add", $data);
break;
case 'summary':
$data['StockRecords'] = $this->MStocks->getStockSummary();
// pre($data['StockRecords']);
if (!isset($_POST['stocklocations_id'])) {
$data['stocklocations_id'] = null;
}
if (!isset($_POST['fromDate'])) {
$data['fromDate'] = null;
}
if (!isset($_POST['toDate'])) {
$data['toDate'] = null;
}
if (isset($_POST)) {
$data = $_POST;
}
$data['pageTitle'] = "Inventory Stock";
$data['fiscalStart'] = NepaliToEnglishDate($data['fromDate'] ?? $this->session->userdata['FiscalYear']->fiscalyear_from);
$data['fiscalEnd'] = NepaliToEnglishDate($data['toDate'] ?? $this->session->userdata['FiscalYear']->fiscalyear_to);
$data['StockRecords'] = $this->MStocks->getStockSummary($data);
loadView("inventory/stocks/summary", $data);
break;
case 'delete':
@ -68,8 +96,24 @@ class Stocks extends CI_Controller
redirect("inventory/stocks/list");
break;
default:
// var_dump("hello");
// die();
// echo '<pre>';
// var_dump($_POST['fromDate'], $_POST['toDate']);
// die();
$data['StockRecords'] = $this->MStocks->getStockRecords();
loadView("inventory/stocks/list", $data);
}
}
// public function summary()
// {
// var_dump("hello");
// die();
// echo '<pre>';
// var_dump($_POST['stocklocations_id'], $_POST['fromDate'], $_POST['toDate']);
// die();
// $data['StockRecords'] = $this->MStocks->getStockSummary($_POST['stocklocations_id'] = 0, $_POST['fromDate'], $_POST['toDate']);
// // echo "<pre>", var_dump($data['StockRecords']); die();
// loadView("inventory/stocks/summary", $data);
// }
}

View File

@ -5,7 +5,6 @@ function generateACCategoryCode($group_id)
$acgroup_code = $ci->db->where("acgroup_id=$group_id")->get("tbl_acgroups")->row()->acgroup_code;
$lastACCategoryCode = $ci->db->select_max("accategory_code")->where("acgroup_id=$group_id")->get("tbl_accategories")->row()->accategory_code;
$category_part = substr($lastACCategoryCode, 1);
$category_part = (float)$category_part + 1;
//if($category_part<10)$category_part="00".$category_part;
if ($category_part < 10) $category_part = "00" . $category_part;
@ -18,7 +17,6 @@ function generateAccountCode($category_id)
$accategory_code = $ci->db->where("accategory_id=$category_id")->get("tbl_accategories")->row()->accategory_code;
$lastAccountCode = $ci->db->select_max("account_code")->where("accategory_id=$category_id")->get("tbl_accounts")->row()->account_code;
$account_part = substr($lastAccountCode, 4);
$account_part = (float)$account_part + 1;
//if($category_part<10)$category_part="00".$category_part;
if ($account_part < 10) $account_part = "00" . $account_part;
@ -54,13 +52,10 @@ function showAccountCategoriesSelector($fieldName, $fieldID, $condition = "1=1",
$html .= " required";
}
$html .= ">";
$html .= "<option value='' " . (($selectedID == '') ? "SELECTED" : "") . ">Select Account Category</option>";
foreach ($AccountCategories as $AccountCategory) {
$html .= "<option value='$AccountCategory->accategory_id'" . (($selectedID == $AccountCategory->accategory_id) ? "selected" : "") . ">" . getFieldfromValue("tbl_acgroups", "acgroup_name", "acgroup_id", $AccountCategory->acgroup_id) . " >> $AccountCategory->accategory_name</option>";
}
$html .= "</select>";
echo $html;
}
@ -68,7 +63,6 @@ function showAccountCategoriesByIds($AccountCategories = array())
{
// pre($AccountCategories); //die;
$ci = &get_instance();
if ($AccountCategories) {
$AccountCategories_a = $ci->db->where("status", 1);
$AccountCategories_a = $AccountCategories_a->where_in("accategory_id", $AccountCategories);
@ -80,22 +74,19 @@ function showAccountCategoriesByIds($AccountCategories = array())
echo implode(", ", $html);
}
}
function linkVoucher($voucher_id)
{
if ($voucher_id != 0) {
$ci = &get_instance();
$Voucher = $ci->db->where("voucher_id", $voucher_id)->get("tbl_vouchers")->row();
$Name = $ci->db->where("vouchertype_id", $Voucher->voucher_type)->get("tbl_vouchertypes")->row()->voucher_type . " Voucher # " . $Voucher->voucher_no;
echo "<a class='link' target='_blank' href='" . site_url("accounts/vouchers/show_voucher/" . $voucher_id) . "'>$Name</a>";
echo "<a class='open-modal' target='_blank' href='" . site_url("accounts/vouchers/show_voucher/" . $voucher_id) . "'>$Name</a>";
} else {
echo "";
}
}
function linkLedger($Account)
{
$ci = &get_instance();
echo "<a class='link' target='_blank' href='" . site_url("accounts/ledger/partyledger?from_date=" . FYStart() . "&to_date=" . FYEnd() . "&account_id=" . $Account->account_id . "&show_ledger=true") . "'>$Account->account_name</a>";
}
@ -143,15 +134,11 @@ function generateVoucherNo($vouchertype_id = "")
{
$ci = &get_instance();
$voucherTypeCondition = ($vouchertype_id != "") ? " WHERE voucher_type = '$vouchertype_id'" : "";
$query = $ci->db->query("SELECT MAX(voucher_no) AS voucher_no FROM tbl_vouchers" . $voucherTypeCondition);
$row = $query->row();
$newVoucherNo = ($row->voucher_no !== null) ? $row->voucher_no + 1 : 1;
return $newVoucherNo;
}
function countChildCategories($acgroup_id)
{
$ci = &get_instance();

View File

@ -44,8 +44,8 @@ function createNepaliDateInput($name, $display, $id, $default = "", $class = "")
<?php if ($display != "") : ?>
<label for="datepicker<?php echo $id; ?>"><?php echo function_exists("myLang") ? myLang($display) : $display; ?></label>
<?php endif; ?>
<div class="input-group" id="ass_date" data-target-input="nearest">
<input id="<?php echo $id; ?>" name="<?php echo $name; ?>" type="text" class="form-control nepaliDatePicker <?php echo $class; ?>" autocomplete="off" value="<?php echo ($default == "") ? NepaliDate() : $default; ?>">
<div class="input-group ass_date" id="ass_date" data-target-input="nearest">
<input id="<?php echo $id; ?>" name="<?php echo $name; ?>" type="text" class="form-control <?php echo $class; ?>" autocomplete="off" value="<?php echo ($default == "") ? NepaliDate() : $default; ?>">
</div>
<?php
}
@ -95,14 +95,14 @@ function getFieldfromValue($tableName, $fieldName, $lookupField, $referenceValue
return "N/A";
}
}
function fillComboWithValue($fieldName, $displayName, $fieldID, $tableName, $displayField, $valueField, $default = "", $CSSclass = "", $multiple = false, $condition = "")
function fillComboWithValue($fieldName, $displayName, $fieldID, $tableName, $displayField, $valueField, $default = "", $CSSclass = "", $multiple = false, $condition = "", $required=false)
{
$ci = &get_instance();
?>
<?php if ($displayName != "") : ?>
<label for="<?php echo $fieldID; ?>"><?php echo function_exists("myLang") ? myLang($displayName) : $displayName; ?></label>
<?php endif; ?>
<select name="<?php echo $fieldName; ?><?php echo ($multiple) ? "[]" : ""; ?>" <?php if ($CSSclass != "none") : ?>class="form-control select2 <?php echo $CSSclass; ?>" <?php else : ?> class="form-control" <?php endif; ?> id="<?php echo $fieldID; ?>" <?php echo ($multiple) ? "multiple" : ""; ?>>
<select name="<?php echo $fieldName; ?><?php echo ($multiple) ? "[]" : ""; ?>" <?php if ($CSSclass != "none") : ?>class="form-control select2 <?php echo $CSSclass; ?>" <?php else : ?> class="form-control" <?php endif; ?> id="<?php echo $fieldID; ?>" <?php echo ($multiple) ? "multiple" : ""; ?><?php echo ($required) ? "required" : ""; ?>>
<option value="">Select <?php echo function_exists("myLang") ? myLang($displayName) : $displayName; ?></option>
<?php
$q = "select * from $tableName";

View File

@ -98,6 +98,68 @@ class bibaccounts
return $result;
}
// new function
function getAccountGroupsWithBalancesNew($acgroup_id = null, $fiscalStart = null, $fiscalEnd = null)
{
$CI = &get_instance();
$result = [];
$whereClause = "";
if ($acgroup_id !== null) {
$whereClause = "WHERE acgroup_id = '$acgroup_id' AND status=1 AND created_on >= '$fiscalStart' AND created_on >= '$fiscalEnd' ";
}
$t = "SELECT * FROM `tbl_acgroups` $whereClause";
$accountGroups = $CI->db->query($t)->result();
foreach ($accountGroups as $group) {
$t = "SELECT * FROM tbl_accounts
WHERE (accategory_id IN (SELECT accategory_id FROM tbl_accategories WHERE acgroup_id = '{$group->acgroup_id}')
OR accategory_id IN (SELECT parent_category_id FROM tbl_accategories WHERE accategory_id IN (SELECT accategory_id FROM tbl_accategories WHERE acgroup_id = '{$group->acgroup_id}')))
AND status <> -1";
$accounts = $CI->db->query($t)->result();
$group->dr_total = 0;
$group->cr_total = 0;
$group->regular_balance_dr = 0;
$group->regular_balance_cr = 0;
$group->opening_balance_dr = 0;
$group->opening_balance_cr = 0;
foreach ($accounts as $account) {
$accountBalances = $this->getAccountBalances($account->account_id);
// pre($accountBalances);die;
$group->opening_balance_dr += $accountBalances['opening_balance_dr'];
$group->opening_balance_cr += $accountBalances['opening_balance_cr'];
$group->dr_total += $accountBalances['dr_total'];
$group->cr_total += $accountBalances['cr_total'];
$group->regular_balance_dr += $accountBalances['regular_balance_dr'];
$group->regular_balance_cr += $accountBalances['regular_balance_cr'];
$account->balances = $accountBalances;
}
if (
$group->dr_total > 0 &&
$group->cr_total > 0 &&
$group->regular_balance_dr > 0 &&
$group->regular_balance_cr > 0 &&
$group->opening_balance_dr > 0 &&
$group->opening_balance_cr > 0
) $group->isZero = 1;
else $group->isZero = 0;
$group->opening_balance = ($group->posting_side == "DR") ? $group->opening_balance_dr - $group->opening_balance_cr : $group->opening_balance_cr - $group->opening_balance_dr;
$group->closing_balance = ($group->posting_side == "DR") ? $group->dr_total - $group->cr_total : $group->cr_total - $group->dr_total;
$group->regular_balance = ($group->posting_side == "DR") ? $group->regular_balance_dr - $group->regular_balance_cr : $group->regular_balance_cr - $group->regular_balance_dr;
$group->accounts = $accounts;
$result[] = $group;
}
// pre($result);die;
return $result;
}
// new function ends
function getAccountCategoriesWithBalances($acgroup_id = null, $accategory_id = null)
{
@ -578,7 +640,51 @@ class bibaccounts
'regular_balance_cr' => $regularBalanceCr,
);
}
function getAccountBalancesNew($account_id, $fiscal_year_id = "", $branch_id = "",$fiscalStart = null, $fiscalEnd = null)
{
$fiscal_year_id = ($fiscal_year_id == "") ? $this->FY : $fiscal_year_id;
$branch_id = ($branch_id == "") ? $this->Branch : $branch_id;
$CI = &get_instance();
$query = $CI->db->query("SELECT SUM(dr) AS dr_total, SUM(cr) AS cr_total FROM tbl_voucherdetails WHERE account_id='$account_id' AND status=1 AND fiscalyear_id='$fiscal_year_id' AND branch_id='$branch_id' AND created_on >= '$fiscalStart' AND created_on >= '$fiscalEnd' ");
$result = $query->row();
echo "<pre>";print_r($result);die();
$drTotal = $result->dr_total;
$crTotal = $result->cr_total;
$posting_side = $CI->db->query("SELECT posting_side FROM tbl_acgroups WHERE acgroup_id=(SELECT acgroup_id FROM tbl_accategories WHERE accategory_id=(SELECT accategory_id FROM tbl_accounts WHERE account_id='$account_id'))")->row()->posting_side;
$drBalance = 0;
$crBalance = 0;
if ($posting_side == "DR") {
$drBalance = $drTotal - $crTotal;
} else {
$crBalance = $crTotal - $drTotal;
}
$openingBalanceQuery = $CI->db->query("SELECT SUM(dr) AS opening_balance_dr, SUM(cr) AS opening_balance_cr FROM tbl_voucherdetails WHERE account_id='$account_id' AND voucher_id=0 AND status=1 AND fiscalyear_id='$fiscal_year_id' AND branch_id='$branch_id'");
$openingBalanceResult = $openingBalanceQuery->row();
$openingBalanceDr = $openingBalanceResult->opening_balance_dr;
$openingBalanceCr = $openingBalanceResult->opening_balance_cr;
$regularBalanceQuery = $CI->db->query("SELECT SUM(dr) AS regular_balance_dr, SUM(cr) AS regular_balance_cr FROM tbl_voucherdetails WHERE account_id='$account_id' AND voucher_id<>0 AND status=1 AND fiscalyear_id='$fiscal_year_id' AND branch_id='$branch_id'");
$regularBalanceResult = $regularBalanceQuery->row();
$regularBalanceDr = $regularBalanceResult->regular_balance_dr;
$regularBalanceCr = $regularBalanceResult->regular_balance_cr;
return array(
'dr_total' => $drTotal,
'cr_total' => $crTotal,
'dr_balance' => $drBalance,
'cr_balance' => $crBalance,
'opening_balance_dr' => $openingBalanceDr,
'opening_balance_cr' => $openingBalanceCr,
'regular_balance_dr' => $regularBalanceDr,
'regular_balance_cr' => $regularBalanceCr,
);
}
//////
@ -586,7 +692,7 @@ class bibaccounts
{
if (!isset($ReportOptions['AmountColWidth'])) $ReportOptions['AmountColWidth'] = 180;
?>
<table class="table table-sm table-accounts">
<table id='myTable'class="table table-sm table-accounts">
<?php if ($displayHeadings) { ?>
<thead>
<tr>
@ -608,7 +714,8 @@ class bibaccounts
<?php } ?>
<tbody>
<?php foreach ($accountCategories as $accountCategory) : ?>
<?php //print_r($accountCategory);die; ?>
<?php //print_r($accountCategory);die;
?>
<?php if ($ReportOptions['showZeroBalances'] && $accountCategory->isZero == true) continue; ?>
<tr class="<?php echo ($accountCategory->isParent) ? ' parent-row' : ''; ?>" data-toggle="collapse" data-target="#accategory_<?php echo $accountCategory->accategory_id; ?>">
<td class="group-name">
@ -770,13 +877,12 @@ class bibaccounts
<td class="group-total "><?php echo myCurrency(($Account->posting_side == 'CR') ? $Account->opening_balance : 0); ?></td>
<?php endif; ?>
<?php if ($ReportOptions['showPeriod']) : ?>
<td class="group-total"><i><?php echo myCurrency(($Account->posting_side == 'DR') ? $Account->regular_balance : 0); ?></i></td>
<td class="group-total"><?php echo myCurrency(($Account->posting_side == 'CR') ? $Account->regular_balance : 0); ?><?php //pre($Account);
?></td>
<?php endif; ?>
<?php if ($ReportOptions['showClosing']) : ?>
<td class="group-total"><?php echo myCurrency(($Account->posting_side == 'DR') ? $Account->closing_balance : 0); ?></td>
<td class="group-total"><?php echo myCurrency(($Account->posting_side == 'CR') ? $Account->closing_balance : 0); ?></td>
<td class="group-total col-2"><?php echo myCurrency(($Account->posting_side == 'DR') ? $Account->closing_balance : 0); ?></td>
<td class="group-total col-2"><?php echo myCurrency(($Account->posting_side == 'CR') ? $Account->closing_balance : 0); ?></td>
<?php endif; ?>
</tr>
<?php endforeach; ?>
@ -818,14 +924,14 @@ class bibaccounts
/*
* Retrieves the account groups and accounts with balances that has cash/bank in debit side
*/
function getIncomeAndExpenditure()
function getIncomeAndExpenditure($fiscalStart,$fiscalEnd)
{
$CI = &get_instance();
#2 >> Bank Accounts
#3 >> Cash Accounts
$Incomes = array();
$Expenses = array();
$t = "select * from tbl_voucherdetails where voucher_id in (select voucher_id from tbl_voucherdetails where voucher_id<>0 and account_id in (select account_id from tbl_accounts where accategory_id=2 or accategory_id=3)) and account_id not in (select account_id from tbl_accounts where accategory_id=2 or accategory_id=3)";
$t = "select * from tbl_voucherdetails where voucher_id in (select voucher_id from tbl_voucherdetails where voucher_id<>0 and account_id in (select account_id from tbl_accounts where accategory_id=2 or accategory_id=3)) AND created_on >= '$fiscalStart' AND created_on >= '$fiscalEnd' and account_id not in (select account_id from tbl_accounts where accategory_id=2 or accategory_id=3)";
$accounts = $CI->db->query($t)->result();
foreach ($accounts as $account) {
$account->details = $CI->db->query("select * from tbl_accounts where account_id=" . $account->account_id)->row();
@ -960,9 +1066,9 @@ class bibaccounts
return $sides;
}
function prepareIncomeExpenses()
function prepareIncomeExpenses($fiscalStart,$fiscalEnd)
{
$cashFlow = $this->getIncomeAndExpenditure();
$cashFlow = $this->getIncomeAndExpenditure($fiscalStart,$fiscalEnd);
$a = 0;
foreach ($cashFlow as $side) :
$Groups = array();

View File

@ -801,8 +801,4 @@ class bibaccounts
<?php
}
//////
}

View File

@ -70,6 +70,7 @@ class myaccounts
$crTotal = 0;
$drTotal = 0;
$fields = array();
// print_r($VoucherDetails);die;
foreach ($VoucherDetails as $VoucherDetail) :
$i++;
$fields['account_name_' . $i] = $VoucherDetail->account_name;
@ -90,6 +91,9 @@ class myaccounts
$fields['amount_in_words'] = trim($CI->numbertoword->nepali_word($crTotal));
else
$fields['amount_in_words'] = trim($CI->numbertoword->english_word($crTotal));
// $fields['narration_' . $i] = $VoucherDetail->narration;
$file = APPPATH . "/../pdf/e_voucher1.pdf";
$pdf = new FPDM($file);
//pre($pdf->getContent($file,"PDF"));
@ -125,7 +129,8 @@ class myaccounts
{
$CI = &get_instance();
$Account = $CI->db->query("select * from tbl_accounts where account_id='$account_id'")->row();
$Account->Balance = $this->getBalance($account_id);
// $Account->Balance = $this->getBalance($account_id);
// echo"<pre>";print_r($Account); die();
return $Account;
}
function getBalance($account_id)
@ -175,18 +180,17 @@ class myaccounts
$Account->Category = $CI->db->query("select * from tbl_accategories where accategory_id = $Account->accategory_id")->row();
}
//$q=$CI->db->get_compiled_select();
//print($q);
?>
<div class="row mb-3">
<?php if ($accategory_id == "") : ?>
<div class="col">
<form method="get">
<div class="row">
<div class="col-5">
<div class="col-3">
<?php $this->showAccountsCategoriesCombo("accategory_id", "", "accategory_id"); ?>
</div>
<div class="col-3">
<input type="submit" value="Show Accounts" class="form-control btn btn-success">
<input type="submit" value="Show Accounts" class=" btn btn-success btn-sm">
</div>
</div>
</form>
@ -197,7 +201,7 @@ class myaccounts
$html = "";
$html .= "<table class='table table-bordered table-striped longdataTable'>";
$html .= "<thead>";
$html .= "<tr><th>Account</th><th class='text-center'>Account Group</th><th class='text-center'>Dr</th><th class='text-center'>Cr</th><th class='text-center'>Action</th></tr>";
$html .= "<tr><th>Account</th><th class='text-center'>Account Group</th><th class='text-center'>Dr</th><th class='text-center'>Cr</th><th class='text-center'>Balance</th><th class='text-center col-1'>Action</th></tr>";
$html .= "</thead><tbody>";
$sn = 0;
$BalanceTotal = 0;
@ -205,12 +209,12 @@ class myaccounts
$balance = getBalance($Account->account_id);
$BalanceTotal += $balance;
// pre($Account);
$html .= "<tr><td><a href='#' onClick='showLedger(" . $Account->account_id . ")'>" . $Account->account_name . "</a></td><td class='col-2'>" . $Account->Category->accategory_name . "</td><td class='col-1'>" . (($balance >= 0) ? myCurrency($balance) : "") . "</td><td class='col-1'>" . (($balance < 0) ? myCurrency(abs($balance)) : "") . "</td><td class='col-2 text-center'><a title='Show Ledger' class='btn btn-info btn-xs ' onClick='showLedger(" . $Account->account_id . ")'><i class='fa fa-eye'></i></a></td></tr>";
$html .= "<tr><td><a href='#' onClick='showLedger(" . $Account->account_id . ")'>" . $Account->account_name . "</a></td><td class='col-2'>" . $Account->Category->accategory_name . "</td><td class='col-1'>" . (($balance >= 0) ? myCurrency($balance) : "") . "</td><td class='col-1'>" . (($balance < 0) ? myCurrency(abs($balance)) : "") . "</td><td class='text-right col-1'>" . myCurrency($balance) . "</td><td class='text-center'><a title='Show Ledger' class='btn btn-info btn-xs ' onClick='showLedger(" . $Account->account_id . ")'><i class='fa fa-eye'></i></a></td></tr>";
endforeach;
$html .= "</tbody><tfoot>";
if ($full==""){
$html .= "<tr><th colspan=2 class='text-right '>Total</th><th class='text-right'>" . myCurrency($BalanceTotal) . "</th><th class='text-right'>" . myCurrency($BalanceTotal) . "</th><th></th><th></th></tr>";
}
// if ($full == "") {
$html .= "<tr><th colspan=2 class='text-right '>Total</th><th class='text-right'>" . (($BalanceTotal > 0) ? myCurrency(abs($BalanceTotal)) : "") . "</th><th class='text-right'>" . (($BalanceTotal < 0) ? myCurrency(abs($BalanceTotal)) : "") . "</th><th>" . myCurrency($BalanceTotal) . "</th><th></th></tr>";
// }
$html .= "</tfoot></table>\n";
$html .= " <div class=\"modal fade\" id=\"ledgerdetails_box\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"ledgerdetails_box\" aria-hidden=\"true\">
<div class=\"modal-dialog modal-xl\" role=\"document\">
@ -543,7 +547,6 @@ class myaccounts
<tr>
<!-- <th class="col-1.5" rowspan="2"><?php //myLang(" Category");
?></th> -->
<th class="col-1.5" rowspan="2"><?php myLang("Ledger"); ?></th>
<th class="col-1.5" rowspan="2"><?php myLang(" Group"); ?></th>
<th colspan="2" class="col-3 text-center">Opening Balance</th>
@ -662,15 +665,13 @@ class myaccounts
$data['oldBalance'] = $oldBalance;
return $data;
}
function showLedger($account_id, $fromDate = "", $toDate = "")
function showLedger($account_id, $fromDate = "", $toDate = "", $fiscalStart = "", $fiscalEnd = "")
{
$oldBalance = $this->getOldBalance($account_id, FYStart());
$fromDate = ($fromDate == "") ? NepaliToEnglishDate(FYStart()) : $fromDate;
$toDate = ($toDate == "") ? Today() : $toDate;
$ci = &get_instance();
$Transactions = $ci->db->where("transaction_date between '$fromDate' AND '$toDate'")->where("status", 1)->where("account_id", $account_id)->get("tbl_voucherdetails")->result();
$Account = $ci->db->where("status", 1)->where("account_id", $account_id)->get("tbl_accounts")->row();
foreach ($Transactions as $T) {
$T->Voucher = $ci->db->where("status", 1)->where("voucher_id", $T->voucher_id)->get("tbl_vouchers")->row();
@ -681,14 +682,19 @@ class myaccounts
?>
<div class="card-primary card-outline ">
<div class="card-header">
<h5 class="m-0">Leger for Account : <?php echo $Account->account_name; ?> <a href="<?php echo site_url("accounts/ledger/print/" . $Account->account_id . "/?" . $_SERVER['QUERY_STRING']); ?>" class="btn btn-success btn-sm float-right">Print</a></h5>
<h5 class="m-0">Leger for Account : <?php echo $Account->account_name; ?>
<!-- <a href="<?php echo site_url("accounts/ledger/print/" . $Account->account_id . "/?" . $_SERVER['QUERY_STRING']); ?>" class="btn btn-success btn-sm float-right">Print</a> -->
<button type="submit" id="downloadCsv1" class="btn btn-warning btn-sm ">
Export csv
</button>
</h5>
</div>
<div class="card-body p-0 mb-20" id="printableDiv">
<h3 class="text-center"><?php echo $ci->session->userdata("CompanyName"); ?></h3>
<h5 class="text-center">Ledger Details for <?php echo $Account->account_name; ?> </h5>
<?php $TableData = $Transactions; ?>
<?php $TotalCols = 7; ?>
<table class="table table-bordered table-head-fixed text-nowrap table-striped ">
<table id='myTable1' class="table table-bordered table-head-fixed text-nowrap table-striped ">
<thead>
<tr>
<th class="col-1"><?php myLang("Date"); ?></th>
@ -699,6 +705,7 @@ class myaccounts
<th class="col-1 text-right"><?php myLang("Debit"); ?></th>
<th class="col-1 text-right"><?php myLang("Credit"); ?></th>
<th class="col-1"><?php myLang("Balance"); ?></th>
<input type="hidden" id="refdate" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>">
</tr>
</thead>
<tbody>
@ -706,12 +713,10 @@ class myaccounts
$drTotal = 0;
$crTotal = 0;
$balance = 0;
foreach ($TableData as $TableRow) : $r++;
?>
<tr>
<td><?php echo NepaliDate(($TableRow->transaction_date)); ?></td>
<td>
<?php
if ($TableRow->voucher_id != 0) :
@ -721,9 +726,7 @@ class myaccounts
echo $T->account_name;
break;
}
endforeach;
// pre($Tr);
else :
echo "Opening Balance";
@ -733,7 +736,6 @@ class myaccounts
?></td> -->
<td>
<?php linkVoucher($TableRow->voucher_id); ?>
</td>
<td><?php echo myCurrency($TableRow->dr);
$drTotal += $TableRow->dr; ?></td>
@ -766,6 +768,74 @@ class myaccounts
</tr>
</tfoot>
</table>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="myModalLabel">Modal Title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body" id="modal-body">
<!-- Content loaded via AJAX will go here -->
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
<!-- pdf document -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.0/xlsx.full.min.js"></script>
<script>
$(document).ready(function() {
$('.open-modal').click(function(e) {
e.preventDefault(); // Prevent the default link behavior
const url = $(this).attr('href'); // Get the URL from the link
$('#modal-body').load(url, function() {
$('#myModal').modal('show'); // Show the modal after loading content
});
});
});
</script>
<script>
document.getElementById('downloadCsv1').addEventListener('click', function() {
const table = document.getElementById('myTable1');
const rows = Array.from(table.rows);
const data = [];
rows.forEach((row) => {
const cells = Array.from(row.cells);
const rowData = [];
cells.forEach((cell) => {
// Handle colspan
const colspan = cell.colSpan || 1;
for (let i = 0; i < (colspan - 1); i++) {
rowData.push(''); // Fill empty cells for merged columns
}
for (let i = 0; i < 1; i++) {
rowData.push(cell.innerText.trim());
}
// Fill empty cells for colspan
});
data.push(rowData);
});
// Create a worksheet
const worksheet = XLSX.utils.aoa_to_sheet(data);
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
// Export to Excel
XLSX.writeFile(workbook, 'table.xlsx');
});
</script>
<!-- pdf document ends-->
<!-- <div class="container ">
<div class="row mt-100 ">
<div class="col-2"><span class="underline-text"><?php echo $ci->session->userdata("loggedUser"); ?></span></div>
@ -782,13 +852,30 @@ class myaccounts
</div>
</div>
<?php
function footerfunctions()
{
?>
<script>
$(".ass_date").nepaliDatePicker({
dateFormat: "%y-%m-%d",
closeOnDateSelect: true,
minDate: $('#refdate').data('start'),
maxDate: $('#refdate').data('end'),
});
</script>
<?php
}
?>
<?php
}
function ledgerPDF_FPDM($account_id, $fromDate, $toDate)
{
$CI = &get_instance();
$CI->load->library("numbertoword");
$ledgerData = $this->getLedgerData($account_id, $fromDate, $toDate);
$file = APPPATH . "/../pdf/e_ledger1.pdf";
$file = APPPATH . "/../pdf/
.pdf";
$pdf = new FPDM($file);
$i = 0;
$crTotal = 0;
@ -931,7 +1018,7 @@ class myaccounts
// $pdf->Output("F", $OutputFileLocation . $OutputFile);
// return $OutputFile;
}
function listVouchers($fromDate = "", $toDate = "", $account_id = "", $vouchertype_id = "", $showAccounts = false, $showVoucherTypes = false)
function listVouchers($fromDate = "", $toDate = "", $account_id = "", $vouchertype_id = "", $showAccounts = false, $showVoucherTypes = false, $fiscalStart = "", $fiscalEnd = "")
{
// echo $toDate;
$ci = &get_instance();
@ -967,13 +1054,14 @@ class myaccounts
<th width="90"><?php myLang("Dr"); ?></th>
<th width="90"><?php myLang("Cr"); ?></th>
<!--<th><?php myLang("Voucher State"); ?></th> -->
<th class="table-col col-2">Action</th>
<th class="table-col col-1 text-center">Action</th>
</tr>
</thead>
<tbody>
<?php $a = 0; $drTotal=0;$crTotal=0;
<?php $a = 0;
$drTotal = 0;
$crTotal = 0;
foreach ($TableData as $TableRow) : $a++; ?>
<tr data-id="<?php echo $TableRow->voucher_id; ?>" class="<?php echo ($TableRow->voucher_state == "Reversed") ? "table-danger" : ""; ?>">
<!-- <td><?php echo $TableRow->voucher_id; ?></td> -->
<td><?php echo $TableRow->voucher_no; ?></td>
@ -988,9 +1076,7 @@ class myaccounts
</td>
<?php if ($showVoucherTypes) : ?>
<td>
<?php echo $TableRow->VoucherType->voucher_name; ?>
</td>
<?php endif; ?>
<td>
@ -1005,10 +1091,16 @@ class myaccounts
</td>
<!-- <td><?php echo $TableRow->voucher_type; ?></td> -->
<!-- <td><?php echo $TableRow->voucher_state; ?></td> -->
<td class="col-1">
<td class="col-1 text-center">
<a onClick="javascript:showDetails(<?php echo $TableRow->voucher_id; ?>);" class="btn btn-success btn-xs" title="View Details"><i class="fa fa-eye"></i></a>
<!-- <a onClick="javascript:showDetails(<?php //echo $TableRow->voucher_id;
?>);" class="btn btn-info btn-xs" title="View Details"><i class="fas fa-edit"></i></a> -->
<a onClick="javascript:showPDF(<?php echo $TableRow->voucher_id; ?>);" class="btn btn-primary btn-xs" title="View PDF"><i class="fa fa-file-pdf"></i></a>
<?php //print_r($ci->session->userdata());die;
?>
<?php if ($ci->session->userdata('LoggedUser') != 'admin'): ?>
<a onClick="javascript:deleteVoucher(<?php echo $TableRow->voucher_id; ?>);" class="btn btn-danger btn-xs" title="Delete Voucher"><i class="fa fa-trash"></i></a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
@ -1043,6 +1135,7 @@ class myaccounts
<button type="button" onClick='reversalEntry()' id="reversalBtn" class="btn btn-secondary" data-dismiss="modal" data-id="">Revarsal Entry</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
<input type="hidden" id="refdate" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>">
</div>
</div>
</div>
@ -1125,6 +1218,15 @@ class myaccounts
}
}
</script>
<script>
$(".ass_date").nepaliDatePicker({
dateFormat: "%y-%m-%d",
closeOnDateSelect: true,
minDate: $('#refdate').data('start'),
maxDate: $('#refdate').data('end'),
});
</script>
<?php
}
?>
@ -1217,7 +1319,7 @@ class myaccounts
<td><?php echo myCurrency($drTotal); ?></td>
</tr>
<tr>
<td colspan="<?php echo $TotalCols; ?>" class="text-left" height=100>Narration: <?php echo $TableRow->narration; ?></td>
<td colspan="<?php echo $TotalCols; ?>" class="text-left" height=100><i>Narration: <?php echo $TableRow->narration; ?></i></td>
</tr>
<tr>
<td colspan="<?php echo $TotalCols; ?>" class="text-center" height=200>
@ -1303,13 +1405,8 @@ class myaccounts
</option>
<?php endif; ?>
<?php endforeach; ?>
</select>
<button type="button" class="btn input-group-text addplus" data-toggle="modal" data-target="#exampleModal"><i class="fas fa-plus"></i></button>
<?php
}
function showAccountsCategoriesCombo($fieldName, $displayName, $fieldID, $condition = "", $default = "", $CSSclass = "")
@ -1321,7 +1418,8 @@ class myaccounts
<?php endif; ?>
<select name="<?php echo $fieldName; ?>" class="form-control select2 <?php echo $CSSclass; ?>" id="<?php echo $fieldID; ?>">
<option value="">Select </option>
<!-- <option value="">Select <?php //echo function_exists("myLang") ? myLang($displayName) : $displayName; ?></option> -->
<!-- <option value="">Select <?php //echo function_exists("myLang") ? myLang($displayName) : $displayName;
?></option> -->
<?php
$q = "select *,(select acgroup_name from tbl_acgroups where tbl_accategories.acgroup_id=tbl_acgroups.acgroup_id) as acgroup_name from tbl_accategories";
$q .= ($condition != "") ? " where $condition" : " where status=1";
@ -1343,21 +1441,15 @@ class myaccounts
<?php $current_acgroup = $value->acgroup_name;
endif;
endforeach;
*/
foreach ($Values as $value) : ?>
<option value="<?php echo $value->accategory_id; ?>" <?php echo ($value->accategory_id == $default) ? 'SELECTED' : ''; ?>>
<?php echo $value->accategory_name; ?>
</option>
<?php
endforeach;
?>
</select>
<?php
}
function showFixedAccountsCategoriesCombo($fieldName, $displayName, $fieldID, $condition = "", $default = "", $CSSclass = "")
@ -1367,9 +1459,10 @@ class myaccounts
<?php if ($displayName != "") : ?>
<label for="<?php echo $fieldID; ?>"><?php echo function_exists("myLang") ? myLang($displayName) : $displayName; ?></label>
<?php endif; ?>
<select name="<?php echo $fieldName; ?>" class="form-control select2 <?php echo $CSSclass; ?>" id="<?php echo $fieldID; ?>">
<select name="<?php echo $fieldName; ?>" class="form-control select2 <?php echo $CSSclass; ?>" id="<?php echo $fieldID; ?> " required>
<option value="">Select </option>
<!-- <option value="">Select <?php //echo function_exists("myLang") ? myLang($displayName) : $displayName; ?></option> -->
<!-- <option value="">Select <?php //echo function_exists("myLang") ? myLang($displayName) : $displayName;
?></option> -->
<?php
$q = "select *,(select acgroup_name from tbl_acgroups where tbl_accategories.acgroup_id=tbl_acgroups.acgroup_id) as acgroup_name from tbl_accategories";
$q .= ($condition != "") ? " where $condition" : " where status=1";
@ -1392,21 +1485,15 @@ class myaccounts
<?php $current_acgroup = $value->acgroup_name;
endif;
endforeach;
*/
foreach ($Values as $value) : ?>
<option value="<?php echo $value->accategory_id; ?>" <?php echo ($value->accategory_id == $default) ? 'SELECTED' : ''; ?>>
<?php echo $value->accategory_name; ?>
</option>
<?php
endforeach;
?>
</select>
<?php
}
function showAccountsCategoriesWithParentsCombo($fieldName, $displayName, $fieldID, $condition = "", $default = "", $CSSclass = "", $extras = "")
@ -1549,7 +1636,6 @@ class myaccounts
$ci->dbforge->add_column('tbl_vouchertypes', array('default_debits' => array('type' => 'VARCHAR', 'constraint' => 255)));
}
}
function hasTransaction($type, $id)
{
switch ($type) {

View File

@ -39,9 +39,9 @@ class MPurchases extends CI_Model
}
return $PurchaseRecords;
}
public function getPurchaseRecords()
public function getPurchaseRecords($fromDate, $toDate)
{
$PurchaseRecords = $this->db->where("status", 1)->get("tbl_purchases")->result();
$PurchaseRecords = $this->db->where("status", 1)->where("created_on between '$fromDate' AND '$toDate'")->get("tbl_purchases")->result();
foreach ($PurchaseRecords as $PurchaseRecord) {
$PurchaseRecord->Details = $this->getPurchaseDetails($PurchaseRecord->purchase_id);
$PurchaseRecord->TotalPurchase = $this->getTotalPurchaseAmount($PurchaseRecord->purchase_id);

View File

@ -39,9 +39,9 @@ class MSales extends CI_Model
}
return $SalesRecords;
}
public function getSalesRecords()
public function getSalesRecords($fromDate, $toDate)
{
$SalesRecords = $this->db->where("status", 1)->get("tbl_sales")->result();
$SalesRecords = $this->db->where("status", 1)->where("created_on between '$fromDate' AND '$toDate'")->get("tbl_sales")->result();
foreach ($SalesRecords as $SalesRecord) {
$SalesRecord->Details = $this->getSalesDetails($SalesRecord->sales_id);
$SalesRecord->totalsales = $this->getTotalSalesAmount($SalesRecord->sales_id);

View File

@ -151,8 +151,9 @@ class MStocks extends CI_Model
$Item->Closing = $this->getClosingStock($item_id);
return $Item;
}
public function getStockSummary($stocklocation_id = 0)
public function getStockSummary($data)
{
$stocklocation_id = $data['stocklocation_id'] ?? null;
$this->db->where("status", 1);
if ($stocklocation_id != 0) {
$this->db->where("stocklocations_id", $stocklocation_id);
@ -160,9 +161,19 @@ class MStocks extends CI_Model
$StockRecords = $this->db->select("distinct(items_id) as items_id")->get("tbl_stocks")->result();
foreach ($StockRecords as $StockRecord) {
$StockRecord->Summary = $this->getStockItemSummary($StockRecord->items_id);
// $StockRecord->StockLocation = $this->db->where("stocklocation_id", $StockRecord->stocklocations_id)->get("tbl_stocklocations")->row();
$StockRecord->Item = $this->db->where("item_id", $StockRecord->items_id)->get("tbl_items")->row();
$this->db->where("stocklocation_id ", $StockRecord->Summary->stocklocations_id);
$query1 = $this->db->get("tbl_stocklocations");
$result2 = $query1->result();
$StockRecord->StockLocation = $result2;
//tbl_items
$this->db->where('created_on >=', date('Y-m-d', (strtotime($data['fiscalStart']))));
$this->db->where('created_on <=', date('Y-m-d', (strtotime($data['fiscalEnd']))));
$this->db->where('item_id', $StockRecord->items_id);
$query3 = $this->db->get('tbl_items');
$result3 = $query3->result();
$StockRecord->Item = $result3;
}
return $StockRecords;
}
public function getStockRecords($stocklocation_id = 0)
@ -215,6 +226,5 @@ class MStocks extends CI_Model
$Item = $this->db->where("item_id", $id)->get("tbl_items")->row();
$Unit = $this->db->where("unit_id", $Item->units_id)->get("tbl_units")->row();
return $Unit;
}
}

View File

@ -5,7 +5,7 @@
<div class="col-3">
<div class="card card-primary card-outline">
<div class="card-header">
<h5 class="m-0"><?php echo isset($AccountCategory) ? 'Edit' : 'Create'; ?>
<h5 class="m-0 card-title"><?php echo isset($AccountCategory) ? 'Edit' : 'Create'; ?>
<?php echo $pageTitle; ?>
<!-- <a href="<?php //echo site_url("master/accategories/list");
?>" class="btn btn-sm btn-primary float-right">List <?php //echo $pageTitle;
@ -34,7 +34,7 @@
<div class="form-group">
<?php
// $this->myaccounts->showFixedAccountsCategoriesCombo("parent_category_id", " Under", "parent_category_id", "status=1", $default = "", $CSSclass = "");
echo isset($AccountCategory) ? fillComboWithValue("parent_category_id", "Under", "parent_category_id", "tbl_accategories", "accategory_name", "accategory_id", $default = $AccountCategory->parent_category_id, $CSSclass = "", $multiple = false, $condition = "status=1") : $this->myaccounts->showFixedAccountsCategoriesCombo("parent_category_id", " Under", "parent_category_id", "status=1", $default = "", $CSSclass = "");
echo isset($AccountCategory) ? fillComboWithValue("parent_category_id", "Under", "parent_category_id", "tbl_accategories", "accategory_name", "accategory_id", $default = $AccountCategory->parent_category_id, $CSSclass = "", $multiple = false, $condition = "status=1") : $this->myaccounts->showFixedAccountsCategoriesCombo("parent_category_id", " Under <span style='color:#ff0000'>*</span>", "parent_category_id", "status=1", $default = "", $CSSclass = "");
?>
@ -62,7 +62,7 @@
<div class="col-9">
<div class="card card-primary card-outline">
<div class="card-header">
<h5 class="m-0"><?php echo $pageTitle . 's'; ?>
<h5 class="m-0 card-title"><?php echo $pageTitle . 's'; ?>
<!-- <a href="<?php //echo site_url("master/accategories/add_child");
?>" class="btn btn-sm btn-primary float-right">Create New <?php //echo $pageTitle;
?></a> -->
@ -77,8 +77,8 @@
<!-- <th class="col-3">Category</th> -->
<th class="col-3"><?php myLang("Group Name"); ?></th>
<th class="col-3"><?php myLang("Under"); ?></th>
<th class="col-3"><?php myLang('Remarks');?></th>
<th class="col-2 text-center">Action</th>
<th class="col-4"><?php myLang('Remarks');?></th>
<th class="col-1 text-center">Action</th>
</tr>
</thead>
<tbody>

View File

@ -14,9 +14,9 @@
<table class="table table-bordered table-striped longdataTable">
<thead>
<tr>
<th class="col-2">Type</th>
<th class="col-1">Type</th>
<th>Category Name</th>
<td class="col-1">Action</th>
<th class="col-1 text-center">Action</th>
</tr>
</thead>
<tbody>
@ -26,7 +26,7 @@
break;
endforeach; ?>
<?php if ($TableRow->parent_category_id == 0) : ?>
<tr>
<tr class="text-center">
<td><?php echo $TableRow->AccountGroup->acgroup_name; ?></td>
<td><?php echo $TableRow->accategory_name; ?></td>
<td><a href="<?php echo site_url("master/accategories/edit_parents/$id"); ?>" class="btn btn-info btn-xs"><i class="fas fa-edit"></i> </a>

View File

@ -34,7 +34,7 @@
<div class="col-7">
<div class="form-group">
<?php fillComboWithValue("accategory_id", "Under", "accategory_id", "tbl_accategories", "accategory_name", "accategory_id", $TableData->accategory_id, "", false, "status=1"); ?>
<?php fillComboWithValue("accategory_id", "Under", "accategory_id", "tbl_accategories", "accategory_name", "accategory_id", $TableData->accategory_id, "", false, "status=1", $required=true); ?>
</div>
</div>
@ -80,7 +80,10 @@
$category_name = getFieldfromValue("tbl_accategories", "accategory_name", "accategory_id", $TableData->accategory_id);
?>
<div id="creditorFields" style="display: none;">
<!-- <?php //if ($category_name == "Sundry Creditors" || $category_name == "Sundry Debtors") : ?> -->
<!-- <?php //if ($category_name == "Sundry Creditors" || $category_name == "Sundry Debtors") :
?> -->
<hr>
<div class="row" style="padding-bottom: 4px;"><b>Mailing Details:</b></div>
<div class="row">
<!--COL START-->
<div class="col">
@ -96,11 +99,11 @@
<label for="account_partyaddress">Party Address</label><input type="text" class="form-control" id="account_partyaddress" value="<?php echo $TableData->account_partyaddress; ?>" name="account_partyaddress">
</div>
</div>
<div class="col">
<div class="form-group">
<label for="account_partypan">PAN</label><input type="text" class="form-control" id="account_partypan" value="<?php echo $TableData->account_partypan; ?>" name="account_partypan">
</div>
</div>
<hr>
<div class="row" style="padding-bottom: 4px;"><b>Contact Details:</b></div>
<div class="row">
<!--COL END-->
<!--COL START-->
<div class="col">
@ -110,8 +113,6 @@
</div>
<!--COL END-->
</div>
<div class="row">
<!--COL START-->
<div class="col">
<div class="form-group">
@ -142,14 +143,89 @@
</div>
<!--COL END-->
</div>
<!-- <?php //endif; ?> -->
<hr>
<div class="row" style="padding-bottom: 4px;"><b>Tax Information:</b></div>
<div class="row">
<div class="col-md-6 col-lg-2">
<div class="form-group">
<label for="account_partypan">PAN</label><input type="text" class="form-control" id="account_partypan" value="<?php echo $TableData->account_partypan; ?>" name="account_partypan">
</div>
<div class="row" id="bankFields" >
<!-- <?php //if ($category_name == "Bank Account") : ?> -->
</div>
<!-- <?php //endif;
?> -->
</div>
</div>
<div id="bankFields">
<!-- <?php //if ($category_name == "Bank Account") :
?> -->
<hr>
<div class="row" style="padding-bottom: 4px;"><b>Mailing Details:</b></div>
<div class="row">
<!--COL START-->
<div class="col">
<div class="form-group">
<label for="account_partyname">Party Name</label><input type="text" class="form-control" id="account_partyname" value="<?php echo $TableData->account_partyname; ?>" name="account_partyname">
</div>
</div>
<!--COL END-->
<!--COL START-->
<div class="col">
<div class="form-group">
<label for="account_partyaddress">Party Address</label><input type="text" class="form-control" id="account_partyaddress" value="<?php echo $TableData->account_partyaddress; ?>" name="account_partyaddress">
</div>
</div>
</div>
<!--COL START-->
<hr>
<div class="row" style="padding-bottom: 4px;"><b>Contact Details:</b></div>
<div class="row">
<!--COL END-->
<!--COL START-->
<div class="col">
<div class="form-group">
<label for="account_partyemail">Party Email</label><input type="email" class="form-control" id="account_partyemail" value="<?php echo $TableData->account_partyemail; ?>" name="account_partyemail">
</div>
</div>
<!--COL END-->
<!--COL START-->
<div class="col">
<div class="form-group">
<label for="account_partycontact">Party Contact</label><input type="text" class="form-control" id="account_partycontact" value="<?php echo $TableData->account_partycontact; ?>" name="account_partycontact">
</div>
</div>
<!--COL END-->
<!--COL START-->
<div class="col">
<div class="form-group">
<label for="account_partycontactperson">Contact Person</label><input type="text" class="form-control" id="account_partycontactperson" value="<?php echo $TableData->account_partycontactperson; ?>" name="account_partycontactperson">
</div>
</div>
<!--COL END-->
<!--COL START-->
<div class="col">
<div class="form-group">
<label for="account_partycontactpersoncontact">Contact Person Phone</label><input type="text" class="form-control" id="account_partycontactpersoncontact" value="<?php echo $TableData->account_partycontactpersoncontact; ?>" name="account_partycontactpersoncontact">
</div>
</div>
<!--COL END-->
</div>
<hr>
<div class="row" style="padding-bottom: 4px;"><b>Account Details:</b></div>
<div class="row">
<div class="col">
@ -179,12 +255,14 @@
</div>
</div>
</div>
<!--COL END-->
<!-- <?php //endif; ?> -->
<!-- <?php //endif;
?> -->
</div>
<hr>
<div class="row">
<!--COL START-->
<div class="col">

View File

@ -7,7 +7,7 @@
<div class="col-3">
<div class="card card-primary card-outline">
<div class="card-header">
<h5 class="m-0"><?php myLang('Create Account'); ?>
<h5 class="m-0 card-title"><?php myLang('Create Account'); ?>
<?php //echo $pageTitle;
?>
@ -31,7 +31,7 @@
<div class="form-group">
<?php
// Assuming this PHP function shows a dropdown for account categories
$this->myaccounts->showAccountsCategoriesWithParentsCombo("accategory_id", "Under", "accategory_id", "status=1", "", "select2", "required");
$this->myaccounts->showAccountsCategoriesWithParentsCombo("accategory_id", "Under <span class='text-danger'>*</span>", "accategory_id", "status=1", "", "select2", "required");
?>
</div>
</div>
@ -135,7 +135,7 @@
<div class="card card-primary card-outline">
<div class="card-header">
<h5 class="m-0">
<h5 class="m-0 card-title">
<?php echo myLang('List Accounts'); ?>
<?php //myLang($pageTitle);
?>
@ -164,10 +164,10 @@
<tr>
<th class="col-1.5" rowspan="2"><?php myLang("Ledger"); ?></th>
<th class="col-1.5" rowspan="2"><?php myLang(" Group"); ?></th>
<th class="col-1.5 vm" rowspan="2"><?php myLang("Ledger"); ?></th>
<th class="col-1.5 vm" rowspan="2"><?php myLang(" Group"); ?></th>
<th colspan="2" class="col-3 text-center">Opening Balance</th>
<th class="col-2 text-center" rowspan="2"><?php myLang("Action"); ?></th>
<th class="col-1 text-center" rowspan="2"><?php myLang("Action"); ?></th>
</tr>
<tr>
@ -191,7 +191,7 @@
echo ($TableRow->cr_opening_balance > 0) ? myCurrency($TableRow->cr_opening_balance) : ""; ?></td>
<td class="text-center">
<a onClick="javascript:showDetails(<?php echo $id; ?>);" class="btn btn-primary btn-xs" title="View"><i class="fas fa-eye"></i> </a>
<!-- <a onClick="javascript:showDetails(<?php echo $id; ?>);" class="btn btn-primary btn-xs" title="View"><i class="fas fa-eye"></i> </a> -->
<a href="<?php echo site_url("accounts/accountheads/edit/$id"); ?>" class="btn btn-info btn-xs" title="Edit"><i class="fas fa-edit"></i> </a>
<a onClick="javascript:doDelete(<?php echo $id; ?>);" class="btn btn-danger btn-xs" title="Delete"><i class="fas fa-trash"></i> </a>
</td>

View File

@ -7,15 +7,12 @@ $tree=buildCategoryTree($array, false);
function buildCategoryTree($categories, $parent_id = 0, $showZero = true)
{
$tree = array();
foreach ($categories as $category) {
if ($category['parent_category_id'] == $parent_id) {
$children = buildCategoryTree($categories, $category['accategory_id'], $showZero);
if (!empty($children)) {
$category['children'] = $children;
}
if ($showZero && ($category['dr'] !== 0 || $category['cr'] !== 0)) {
$tree[] = $category;
} elseif (!$showZero && ($category['dr'] !== 0 && $category['cr'] !== 0)) {
@ -23,20 +20,25 @@ function buildCategoryTree($categories, $parent_id = 0, $showZero = true)
}
}
}
return $tree;
}
function displayCategoryTree($tree) {
function displayCategoryTree($tree)
{
echo '<table class="table table-bordered">';
foreach ($tree as $category) {
// print_r($category);die;
echo '<tr>';
echo '<td class="col-1">' . $category['accategory_id'] . '</td>';
echo '<td><a href="'.site_url("accounts/reports/balance_by_group") . "?category=" . $category['accategory_id'] .'">' . $category['accategory_name'] . '</a></td>';
echo '<td width="250">' . myCurrency($category['dr']) . '</td>';
echo '<td>' . myCurrency($category['cr']) . '</td>';
echo '<td class="col-6">'
. ($category['parent_category_id'] == 0
? "<b><a href='" . site_url("accounts/reports/balance_by_group") . "?category=" . $category['accategory_id'] . "'>"
: "<a href='" . site_url("accounts/reports/balance_by_ledger") . "?group=" . $category['accategory_id'] . "'>")
. $category['accategory_name']
. "</a>"
. ($category['parent_category_id'] == 0 ? "</b>" : "")
. '</td>';
echo '<td class="col-2">' . myCurrency($category['dr']) . '</td>';
echo '<td class="col-2">' . myCurrency($category['cr']) . '</td>';
echo '</tr>';
if (isset($category['children']) && !empty($category['children'])) {
echo '<tr>';
@ -55,10 +57,10 @@ function displayCategoryTree($tree) {
}
</style>
<div class="content-wrapper">
<div class="content">
<div class="container-fluid">
<?php //pre($tree); ?>
<?php //pre($tree);
?>
<div class="row">
<div class="col">
<div class="card card-primary card-outline">
@ -77,8 +79,6 @@ function displayCategoryTree($tree) {
</div>
</div>
</div>
<div class="container">
<script>
function toggleSubTable(row) {
@ -86,9 +86,5 @@ function displayCategoryTree($tree) {
subTable.style.display = subTable.style.display === 'none' ? 'table-row' : 'none';
}
</script>
</div>
<!-- /.content -->

View File

@ -1,6 +1,8 @@
<?php
$drWidth = 250;
$crWidth = 250;
$balanceWidth = 250;
$AccountCategories = $this->myaccounts->getChildAccountCategories();
?>
<style>
@ -10,7 +12,6 @@ $AccountCategories = $this->myaccounts->getChildAccountCategories();
</style>
<div class="content-wrapper">
<div class="container-fluid">
</div>
<div class="content">
<div class="container-fluid">
@ -27,16 +28,21 @@ $AccountCategories = $this->myaccounts->getChildAccountCategories();
<th>Account</th>
<th width="<?php echo $drWidth; ?>">Dr</th>
<th width="<?php echo $crWidth; ?>">Cr</th>
<th class="col-1 text-center">Balance</th>
<th class="col-1 text-center">Action</th>
</tr>
</thead>
<tbody>
<?php
$drTotal = 0;
$crTotal = 0;
$balanceTotal = 0;
foreach ($AccountCategories as $AccountCategory) :
$drTotal += $AccountCategory->dr;
$crTotal += $AccountCategory->cr;
$balanceTotal += $AccountCategory->Balance
?>
<!-- <?php //print_r($AccountCategory);die; ?> -->
<tr>
<td>
<a href="<?php echo site_url("accounts/reports/balance_by_ledger") . "?group=" . $AccountCategory->accategory_id; ?>">
@ -44,7 +50,9 @@ $AccountCategories = $this->myaccounts->getChildAccountCategories();
</a>
</td>
<td width="<?php echo $drWidth; ?>"><?php echo myCurrency($AccountCategory->dr); ?></td>
<td width="<?php echo $crWidth; ?>"><?php echo myCurrency($AccountCategory->cr); ?></td>
<td width="<?php echo $crWidth; ?>"><?php echo myCurrency(abs($AccountCategory->cr)); ?></td>
<td class="text-right"><?php echo myCurrency($AccountCategory->Balance); ?></td>
<td class="text-center"><a href="<?php echo site_url("accounts/reports/balance_by_ledger") . "?group=" . $AccountCategory->accategory_id; ?>" class="btn btn-info btn-xs"><i class="fas fa-eye"></i> </a></td>
</tr>
<?php endforeach; ?>
</tbody>
@ -52,20 +60,18 @@ $AccountCategories = $this->myaccounts->getChildAccountCategories();
<tr>
<th>Total</th>
<td width="<?php echo $drWidth; ?>"><?php echo myCurrency($drTotal); ?></td>
<td width="<?php echo $crWidth; ?>"><?php echo myCurrency($crTotal); ?></td>
<td width="<?php echo $crWidth; ?>"><?php echo myCurrency(abs($crTotal)); ?></td>
<td class="text-right"><?php echo myCurrency($balanceTotal); ?></td>
<td ></td>
</tr>
</thead>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<script>
function toggleSubTable(row) {
@ -73,5 +79,4 @@ $AccountCategories = $this->myaccounts->getChildAccountCategories();
subTable.style.display = subTable.style.display === 'none' ? 'table-row' : 'none';
}
</script>
</div>

View File

@ -0,0 +1,168 @@
<?php
$drWidth = 250;
$crWidth = 250;
$Accounts = $this->acc->getAccountsByCategory($accategory_id);
$array = json_decode(json_encode($Accounts), true);
// print_r($array);die;
$tree = buildCategoryTree($array, false);
function buildCategoryTree($categories, $parent_id = 0, $showZero = true)
{
$tree = array();
foreach ($categories as $category) {
// print_r($category);die;
// print_r(myCurrency(getBalance($category['account_id'])));die;
$category['dr'] = getDrTotal('account_id');
$category['cr'] = getCrTotal('account_id');
if ($showZero && ($category['dr'] !== 0 || $category['cr'] !== 0)) {
$tree[] = $category;
} elseif (!$showZero && ($category['dr'] !== 0 && $category['cr'] !== 0)) {
$tree[] = $category;
}
}
return $tree;
}
function displayCategoryTree($tree)
{
echo '<table id="myTable" class="table table-bordered">';
echo '<thead>';
echo '<tr>';
echo '<th>Sn</th>';
echo '<th>Account</th>';
echo '<th class="text-right">Balance</th>';
echo '</tr>';
echo '</thead>';
echo '<tbody>';
$BalanceTotal = 0;
foreach ($tree as $category) {
echo '<tr>';
echo '<td class="col-1">' . $category['account_id'] . '</td>';
echo '<td class="col-9"><a href="#" onClick="showLedger(' . $category['account_id'] . ')">' . $category['account_name'] . '</a></td>';
echo '<td class="col-2">' . myCurrency(getBalance($category['account_id'])) . '</td>';
$BalanceTotal += getBalance($category['account_id']);
echo '</tr>';
if (isset($category['children']) && !empty($category['children'])) {
echo '<tr>';
echo '<td colspan="4 ">';
displayCategoryTree($category['children']);
echo '</td>';
echo '</tr>';
}
}
echo '</tbody>';
echo '<tfoot>';
echo "<tr><th colspan=2 class='text-right'>Total</th><th class='text-right'>" . myCurrency($BalanceTotal) . "</th></tr>";
echo '</table>';
}
$html = "";
$html .= " <div class=\"modal fade\" id=\"ledgerdetails_box\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"ledgerdetails_box\" aria-hidden=\"true\">
<div class=\"modal-dialog modal-xl\" role=\"document\">
<div class=\"modal-content\">
<div class=\"modal-header\">
<h5 class=\"modal-title\" id=\"exampleModalLabel\">Ledger Details</h5>
<button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\">
<span aria-hidden=\"true\">&times;</span>
</button>
</div>
<div class=\"modal-body\" id=\"details_container\">
Ledger Details Goes Here
</div>
<!--<div class=\"modal-footer\">
<button type=\"button\" class=\"btn btn-secondary\" data-dismiss=\"modal\">Close</button>
<button type=\"button\" class=\"btn btn-success\" data-dismiss=\"modal\">Print</button>
</div>-->
</div>
</div>
</div>";
$html .= '<script>function showLedger(id) {$.ajax({url: \'';
$html .= site_url("accounts/reports/ajax/getledgersummary/");
$html .= '\' + id,success: function(data) {$(\'#ledgerdetails_box #details_container\').html(data);$(\'#ledgerdetails_box\').modal(\'show\');}});}</script>';
echo $html;
?>
<style>
.expandable {
text-decoration: underline;
}
</style>
<div class="content-wrapper">
<div class="content">
<div class="container-fluid">
<?php //pre($tree);
?>
<div class="row">
<div class="col">
<div class="card card-primary card-outline">
<div class="card-header">
<h5 class="m-0"><?php echo $pageTitle; ?> </h5>
</div>
<div class="card-body">
<input type="checkbox" name="showZero" value="true" id="showZero">
<label for="showZero">
Show Zero Balances
</label>
<?php displayCategoryTree($tree); ?>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<script>
function toggleSubTable(row) {
var subTable = row.nextElementSibling;
subTable.style.display = subTable.style.display === 'none' ? 'table-row' : 'none';
}
function showLedger(id) {
// $("#accountsContainer").html("");
// alert(id);
$.ajax({
url: "<?php echo site_url("accounts/reports/ajax/getledgersummary/"); ?>" + id, //accounts/getledgersummary/
success: function(data) {
$("#ledgerdetails_box #details_container").html(data);
$("#ledgerdetails_box").modal("show");
$('.dataTable').DataTable().clear().destroy();
$(".dataTable").dataTable();
}
});
}
</script>
<!-- pdf document -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.0/xlsx.full.min.js"></script>
<script>
document.getElementById('downloadCsv').addEventListener('click', function() {
const table = document.getElementById('myTable');
const rows = Array.from(table.rows);
const data = [];
rows.forEach((row) => {
const cells = Array.from(row.cells);
const rowData = [];
cells.forEach((cell) => {
// Handle colspan
const colspan = cell.colSpan || 1;
for (let i = 0; i < (colspan - 1); i++) {
rowData.push(''); // Fill empty cells for merged columns
}
for (let i = 0; i < 1; i++) {
rowData.push(cell.innerText.trim());
}
// Fill empty cells for colspan
});
data.push(rowData);
});
// Create a worksheet
const worksheet = XLSX.utils.aoa_to_sheet(data);
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
// Export to Excel
XLSX.writeFile(workbook, 'table.xlsx');
});
</script>
<!-- pdf document ends-->
</div>
<!-- /.content -->

View File

@ -12,7 +12,6 @@ $AssetsAccounts = $this->acc->getAccountsByGroup(1);
$LiabilitiesTotal = $this->acc->getAccountBalanceByGroup(2);
$EquityTotal = $this->acc->getAccountBalanceByGroup(5);
$AssetsTotal = $this->acc->getAccountBalanceByGroup(1, false);
$IncomeAccounts = $this->acc->getAccountsByGroup(3);
$ExpenseAccounts = $this->acc->getAccountsByGroup(4);
$IncomesTotal = $this->acc->getAccountBalanceByGroup(3);
@ -21,7 +20,6 @@ $PL = $IncomesTotal - $ExpensesTotal;
$LiabilitiesTotal = $LiabilitiesTotal + $EquityTotal + $PL;
?>
<div class="content-wrapper">
<div class="content">
<div class="container-fluid">
<div class="row">
@ -39,13 +37,11 @@ $LiabilitiesTotal=$LiabilitiesTotal+$EquityTotal+$PL;
</thead>
<tbody>
<tr class="bg-dark">
<th>Liabilities</th>
<th class="col-2">Amount</th>
<th>Assets</th>
<th class="col-2">Amount</th>
</tr>
<tr class="bg-light">
<td colspan="2">
<?php $this->acc->showTable($LiabilitiesAccounts); ?>
@ -54,33 +50,22 @@ $LiabilitiesTotal=$LiabilitiesTotal+$EquityTotal+$PL;
<td colspan="2">
<?php $this->acc->showTable($AssetsAccounts, false); ?>
</td>
</tr>
</tbody>
<tfoot>
<tr class="bg-light">
<th>Net Profit:</th>
<th><?php echo myCurrency($PL); ?></th>
<th></th>
<th></th>
</tr>
<tr class="bg-light">
<th>Total Liabilities:</th>
<th><?php echo myCurrency($LiabilitiesTotal); ?></th>
<th>Total Assets: </th>
<th><?php echo myCurrency($AssetsTotal); ?></th>
</tr>
</tfoot>
</table>
</div>
</div>

View File

@ -2,7 +2,6 @@
$this->load->library("BIBAccounts");
$BIBAccounts = new BIBAccounts();
?>
<style>
table,
td,
@ -13,7 +12,6 @@ $BIBAccounts = new BIBAccounts();
.group-name {
width: 40%;
font-weight: 600px;
}
.group-total {
@ -85,85 +83,94 @@ $BIBAccounts = new BIBAccounts();
box-shadow: inset 0 0 0 transparent;
transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}
.table1 {
border: 0px !important;
padding: 0;
margin: 10 !important;
width: 100%;
vertical-align: middle;
}
.table-responsive {
overflow-x: auto;
}
.card-body {
-webkit-flex: 1 1 auto;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
min-height: 1px;
padding: 0;
}
table {
border: 1px solid #ddd;
border-collapse: collapse;
}
</style>
<div class="content-wrapper">
<section class="content">
<div class="container-fluid">
<div class="card card-primary card-outline">
<div class="card-header">
<h3 class="card-title"><?php echo $pageTitle; ?> </h3>
<h3 class="card-title mt-1"><?php echo $pageTitle; ?> </h3>
<div class="card-tools">
<form method="post" action="" id="FilterForm">
<form method="post" action=<?php echo base_url('accounts/reports/balance_sheet'); ?> id="FilterForm">
<!-- button with a dropdown -->
<div class="btn-group">
<button type="button" class="btn btn-success btn-sm dropdown-toggle" data-toggle="dropdown" data-offset="-52">
Filters
</button>
<div class="dropdown-menu" role="menu">
<div class="form-group p-2 pb-0">
<div class="col">
<div class="form-group">
<label for="fromDate"><?php myLang("Starting Period"); ?></label>
<input type="text" class="form-control " name="fromDate" value="<?php echo (isset($_POST['fromDate'])) ? $_POST['fromDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_from); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="fromDate" aria-describedby="helpId_fromDate" placeholder="Starting Period">
</div>
<div class="form-group">
<label for="toDate"><?php myLang("Ending Period"); ?></label>
<input type="text" class="form-control " name="toDate" value="<?php echo (isset($_POST['toDate'])) ? $_POST['toDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_to); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="toDate" aria-describedby="helpId_toDate" placeholder="Ending Period">
</div>
</div>
<div class="dropdown-divider"></div>
<div class="form-check">
<input class="form-check-input" type="checkbox">
<label class="form-check-label">Select
All</label>
</div>
<div class="form-check">
<input type="hidden" name="showOB" value="not">
<!-- <input type="hidden" name="showOB" value="not"> -->
<input type="checkbox" class="form-check-input " name="showOB" id="showOB" aria-describedby="helpId_showOB" placeholder="Show Opening Balance" <?php echo (isset($_POST['showOB'])) ? "CHECKED" : ""; ?>>
<!-- <input class="form-check-input" type="checkbox"> -->
<label class="form-check-label">Opening</label>
<label class="form-check-label" for="showOB">Opening</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox"> -->
<input type="checkbox" class="form-check-input " name="showClosing" id="showClosing" aria-describedby="helpId_showClosing" placeholder="Show Closing Balance" <?php echo (isset($_POST['showClosing'])) ? "CHECKED" : ""; ?>>
<label class="form-check-label">Closing</label>
<label class="form-check-label" for="showClosing">Closing</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox" checked> -->
<input type="checkbox" class="form-check-input" name="showPeriod" id="showPeriod" aria-describedby="helpId_showPeriod" placeholder="Show Periodic Balance" <?php echo (isset($_POST['showPeriod'])) ? "CHECKED" : "CHECKED"; ?>>
<label class="form-check-label">Period</label>
<label class="form-check-label" for="showPeriod">Period</label>
</div>
</div>
<div class="dropdown-divider"></div>
<button type="submit" class="btn btn-primary mr-2 text-center">Search Now</button>
<div class="form-group p-2 pb-0 text-right">
<button type="button" class="btn btn-info btn-sm " style="width:60px;height:30px;" onclick="resetForm()">Reset</button>
<button type="submit" class="btn btn-primary mr-2 btn-sm" style="width:60px;height:30px;">Search </button>
</div>
</div>
</div>
<div class="btn-group">
<button type="submit" class="btn btn-danger btn-sm " data-toggle="dropdown" data-offset="-52">
<!-- <button type="submit" class="btn btn-warning btn-sm " data-toggle="dropdown" data-offset="-52">
Export
</button> -->
<button type="submit" id="downloadCsv" class="btn btn-warning btn-sm ">
Export csv
</button>
<!-- <div class="dropdown-menu" role="menu">
<a href="#" class="dropdown-item">Export</a>
<a href="#" class="dropdown-item">Pdf</a>
<div class="dropdown-divider"></div>
<a href="#" class="dropdown-item">View calendar</a>
</div> -->
</div>
<button type="button" class="btn btn-warning btn-sm" onclick="resetForm()">Reset</button>
<!-- <button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle Collapse</button> -->
<button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle Collapse</button>
</form>
<script>
function resetForm() {
@ -178,81 +185,20 @@ $BIBAccounts = new BIBAccounts();
<!-- /.card-tools -->
</div>
<!-- <div class="card-body">
<form method="post" action="" id="FilterForm">
<div class="row align-items-end">
<div class="col-2">
<div class="form-group">
<label for="fromDate"><?php myLang("Starting Period"); ?></label>
<input type="text" class="form-control nepaliDatePicker" name="fromDate" value="<?php echo (isset($_POST['fromDate'])) ? $_POST['fromDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_from); ?>" id="fromDate" aria-describedby="helpId_fromDate" placeholder="Starting Period">
</div>
</div>
<div class="col-2">
<div class="form-group">
<label for="toDate"><?php myLang("Ending Period"); ?></label>
<input type="text" class="form-control nepaliDatePicker" name="toDate" value="<?php echo (isset($_POST['toDate'])) ? $_POST['toDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_to); ?>" id="toDate" aria-describedby="helpId_toDate" placeholder="Ending Period">
</div>
</div>
<div class="col-1 text-center">
<div class="form-group">
<label for="showOB"><?php myLang("Opening"); ?></label>
<input type="checkbox" class="form-control " name="showOB" id="showOB" aria-describedby="helpId_showOB" placeholder="Show Opening Balance" <?php echo (isset($_POST['showOB'])) ? "" : "CHECKED"; ?>>
</div>
</div>
<div class="col-1 text-center">
<div class="form-group">
<label for="showClosing"><?php myLang("Closing"); ?></label>
<input type="checkbox" class="form-control " name="showClosing" id="showClosing" aria-describedby="helpId_showClosing" placeholder="Show Closing Balance" <?php echo (isset($_POST['showClosing'])) ? "" : "CHECKED"; ?>>
</div>
</div>
<div class="col-1 text-center">
<div class="form-group">
<label for="showPeriod"><?php myLang("Period"); ?></label>
<input type="checkbox" class="form-control " name="showPeriod" id="showPeriod" aria-describedby="helpId_showPeriod" placeholder="Show Periodic Balance" <?php echo (isset($_POST['showPeriod'])) ? "CHECKED" : "CHECKED"; ?>>
</div>
</div>
<div class="col">
<div class="form-group d-flex justify-content-end">
<button type="submit" class="btn btn-primary mr-2">Filter</button>
<button type="submit" class="btn btn-success mr-2">Export</button>
<button type="button" class="btn btn-warning" onclick="resetForm()">Reset</button>
</div>
</div>
</div>
</form>
<script>
function resetForm() {
document.getElementById("fromDate").value = "2078-4-1";
document.getElementById("toDate").value = "2079-3-32";
document.getElementById("showOB").checked = false;
document.getElementById("showClosing").checked = false;
document.getElementById("FilterForm").submit();
}
</script>
</div> -->
</div>
</div><!-- /.container-fluid -->
</section>
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col">
<!-- <button class="btn btn-secondary toggle-collapse mr-2" id="toggleShowAll">Toggle Collapse</button> -->
<button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle
Collapse</button>
<div class="card card-primary card-outline">
<div class="card-body pl-2 ">
<div class="card-body p-0">
<div class="row">
<?php
// echo $_POST['showClosing'];
$ReportOptions = array(
'showZeroBalances' => false,
@ -261,26 +207,21 @@ $BIBAccounts = new BIBAccounts();
'showPeriod' => false,
);
?>
<table class="table table-bordered">
<?php $AccountGroups = $BIBAccounts->getAccountGroupsWithBalancesNew(2, $fiscalStart, $fiscalEnd); ?>
<?php $Side1Total = 0; ?>
<div class="col-6 p-0 m-0 gy-0">
<div class="table-responsive">
<table id='myTable' class="table mb-0 pb-0">
<thead>
<tr>
<td class="group-name"><b>Particulars</b></td>
<td class="group-total text-right pr-2 "><b>Amount</b></td>
<td class="group-name"><b>Particulars</b></td>
<td class="group-total text-right pr-2"><b>Amount</b></td>
<th class="group-name pl-1">Particulars</th>
<th class="group-total text-center col-1">Amount</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2" class="p-0">
<?php $AccountGroups = $BIBAccounts->getAccountGroupsWithBalances(2); ?>
<?php $Side1Total = 0; ?>
<table class="table table-bordered vertical-borders" id="TrialBalanceTable">
<?php $AccountGroups = $BIBAccounts->getAccountGroupsWithBalancesNew(2, $fiscalStart, $fiscalEnd); ?>
<?php $Side1Total = 0; ?>
<?php
// Initialize variables for column totals
$incomes_totalOpeningDr = 0;
@ -293,12 +234,11 @@ $BIBAccounts = new BIBAccounts();
<?php foreach ($AccountGroups as $group) : ?>
<tr class="group-heading" data-toggle="collapse" data-target="#group_<?php echo $group->acgroup_id; ?>">
<td><b><?php echo $group->acgroup_name; ?></b></td>
<td width="20%"><?php echo myCurrency(($group->posting_side == "CR") ? $group->closing_balance : 0); ?></td>
</tr>
<tr>
<td colspan="7" class="group-details p-0">
<div id="group_<?php echo $group->acgroup_id; ?>" class="collapse">
<div id="group_<?php echo $group->acgroup_id; ?>" class="">
<?php $Accountcategories = $BIBAccounts->getRootCategoriesWithBalances($group->acgroup_id); ?>
<?php $BIBAccounts->renderAccountCategoriesTable($Accountcategories, $ReportOptions, false, array()); ?>
</div>
@ -309,11 +249,7 @@ $BIBAccounts = new BIBAccounts();
$Side1Total += $group->closing_balance;
?>
<?php endforeach; ?>
</table>
<?php $AccountGroups = $BIBAccounts->getAccountGroupsWithBalances(5); ?>
<table class="table table-bordered vertical-borders" id="TrialBalanceTable">
<?php $AccountGroups = $BIBAccounts->getAccountGroupsWithBalancesNew(5, $fiscalStart, $fiscalEnd); ?>
<?php
// Initialize variables for column totals
@ -326,13 +262,12 @@ $BIBAccounts = new BIBAccounts();
?>
<?php foreach ($AccountGroups as $group) : ?>
<tr class="group-heading" data-toggle="collapse" data-target="#group_<?php echo $group->acgroup_id; ?>">
<td class="group-name"><?php echo $group->acgroup_name; ?></td>
<td class="group-name"><b><?php echo $group->acgroup_name; ?></b></td>
<td class="group-total"><?php echo myCurrency(($group->posting_side == "CR") ? $group->closing_balance : 0); ?></td>
</tr>
<tr>
<td colspan="7" class="group-details p-0">
<div id="group_<?php echo $group->acgroup_id; ?>" class="collapse">
<div id="group_<?php echo $group->acgroup_id; ?>" class="">
<?php $Accountcategories = $BIBAccounts->getRootCategoriesWithBalances($group->acgroup_id); ?>
<?php $BIBAccounts->renderAccountCategoriesTable($Accountcategories, $ReportOptions, false, array()); ?>
</div>
@ -343,12 +278,24 @@ $BIBAccounts = new BIBAccounts();
$Side1Total += $group->closing_balance;
?>
<?php endforeach; ?>
</table>
</td>
<td colspan="2" class="p-0">
<?php $AccountGroups = $BIBAccounts->getAccountGroupsWithBalances(1); ?>
<table class="table table-bordered vertical-borders" id="TrialBalanceTable">
</tbody>
</table>
</div>
</div>
<div class="col-6 p-0 m-0">
<div class="table-responsive">
<table class="table mt-0 pt-0">
<thead>
<tr>
<th class="group-name pl-1">Particulars</th>
<th class="group-total text-center col-1">Amount</th>
</tr>
</thead>
<tbody>
<?php $AccountGroups = $BIBAccounts->getAccountGroupsWithBalancesNew(1, $fiscalStart, $fiscalEnd); ?>
<?php
// Initialize variables for column totals
@ -361,12 +308,12 @@ $BIBAccounts = new BIBAccounts();
?>
<?php foreach ($AccountGroups as $group) : ?>
<tr class="group-heading" data-toggle="collapse" data-target="#group_<?php echo $group->acgroup_id; ?>">
<td class="group-name"><?php echo $group->acgroup_name; ?></td>
<td class="group-total"><?php echo myCurrency(($group->posting_side == "DR") ? $group->closing_balance : 0); ?></td>
<td class="group-name"><b><?php echo $group->acgroup_name; ?></b></td>
<td class="group-total text-right "><?php echo myCurrency(($group->posting_side == "DR") ? $group->closing_balance : 0); ?></td>
</tr>
<tr>
<td colspan="7" class="group-details p-0">
<div id="group_<?php echo $group->acgroup_id; ?>" class="collapse">
<div id="group_<?php echo $group->acgroup_id; ?>" class="">
<?php $Accountcategories = $BIBAccounts->getRootCategoriesWithBalances($group->acgroup_id); ?>
<?php $BIBAccounts->renderAccountCategoriesTable($Accountcategories, $ReportOptions, false, array()); ?>
</div>
@ -383,76 +330,109 @@ $BIBAccounts = new BIBAccounts();
?>
<?php endforeach; ?>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<?php
// pre($BIBAccounts->getAccountGroupsWithBalances(4));
$TotalIncomes = $BIBAccounts->getAccountGroupsWithBalances(3)[0]->closing_balance;
$TotalExpenses = $BIBAccounts->getAccountGroupsWithBalances(4)[0]->closing_balance;
$TotalIncomes = ($BIBAccounts->getAccountGroupsWithBalancesNew(3, $fiscalStart, $fiscalEnd)[0]->closing_balance) ?? 0;
$TotalExpenses = ($BIBAccounts->getAccountGroupsWithBalancesNew(4, $fiscalStart, $fiscalEnd)[0]->closing_balance) ?? 0;
$PL = $TotalIncomes - $TotalExpenses;
$Side1Total += $PL;
?>
<div class="col-6 p-0 m-0 gy-0">
<table class="table">
<tr>
<td colspan="2" class="p-0">
<table class="table table-bordered">
<tr>
<td>Total Profit/Loss</td>
<td><b> Profit/Loss</b></td>
<td class="cr closing-cr"><?php echo myCurrency($PL); ?></td>
</tr>
</table>
</td>
<td colspan="2" class="p-0">
</td>
</tr>
<tr>
<td colspan="2" class="p-0">
<table class="table table-bordered">
<table class="table">
<tr>
<th>Total Amount</th>
<th class="pl-1">Total Amount</th>
<th class="cr closing-cr">
<?php echo myCurrency($Side1Total); ?>
</th>
</tr>
</table>
</td>
</tr>
</table>
</div>
<div class="col-6 p-0 m-0 gy-0">
<table class="table">
<tr>
<th>&nbsp;</th>
<th>&nbsp;</th>
</tr>
<tr>
<td colspan="2" class="p-0">
<table class="table">
<tr>
<th class="pl-1">Total Amount</th>
<th class="dr closing-dr">
<?php echo myCurrency($totalClosingDr); ?>
</th>
</tr>
</table>
</td>
</tr>
</table>
</div>
<!-- <div class="col-12 p-0">
<table class="table">
<?php
// pre($BIBAccounts->getAccountGroupsWithBalances(4));
// $TotalIncomes = $BIBAccounts->getAccountGroupsWithBalances(3)[0]->closing_balance;
// $TotalExpenses = $BIBAccounts->getAccountGroupsWithBalances(4)[0]->closing_balance;
// $PL = $TotalIncomes - $TotalExpenses;
// $Side1Total += $PL;
?>
<tr>
<td>Total Profit/Loss</td>
<td class="cr closing-cr"><?php echo myCurrency($PL); ?></td>
</tr>
<tr>
<td colspan="2" class="p-0">
<table class="table">
<tr>
<th class="pl-1">Total Amount</th>
<th class="cr closing-cr">
<?php echo myCurrency($Side1Total); ?>
</th>
</tr>
</table>
</td>
<td colspan="2" class="p-0">
<table class="table table-bordered">
<table class="table">
<tr>
<th>Total Amount</th>
<th class="pl-1">Total Amount</th>
<th class="dr closing-dr">
<?php echo myCurrency($totalClosingDr); ?>
</th>
</tr>
</table>
</td>
</tr>
</table>
</div> -->
<?php //pre($BIBAccounts->getAccountGroupsWithBalances($acgroup_id = null));
?>
</div>
</div>
</div>
</div>
@ -465,12 +445,16 @@ function footerfunctions()
?>
<script>
$(document).ready(function() {
document.getElementById("toggleShowAll").click();
// Prevent the dropdown from closing when clicking inside
$('.dropdown-menu').on('click', function(event) {
event.stopPropagation();
});
});
</script>
<script>
$(document).ready(function() {
document.getElementById("toggleShowAll").click();
});
document.getElementById("toggleShowAll").addEventListener("click", function(e) {
e.preventDefault();
var nestedRows = document.getElementsByClassName("collapse");
@ -490,27 +474,21 @@ function footerfunctions()
function exportTableToCSV(filename) {
var csv = [];
var rows = document.querySelectorAll("table tr:not(.hide)");
for (var i = 0; i < rows.length; i++) {
var row = [];
var cols = rows[i].querySelectorAll("td:not(.hide), th:not(.hide)");
// Check if the parent row is collapsed or hidden
var parentRow = rows[i].closest(".collapse");
var isParentCollapsed = parentRow && (!parentRow.classList.contains("show"));
if (isParentCollapsed) {
continue; // Skip child table rows if parent is collapsed
}
for (var j = 0; j < cols.length; j++) {
var cellValue = cols[j].innerText.replace(/,/g, ""); // Remove commas from the cell value
row.push(cellValue);
}
csv.push(row.join(","));
}
// Create a CSV file
var csvContent = "data:text/csv;charset=utf-8," + csv.join("\n");
var encodedUri = encodeURI(csvContent);
@ -538,5 +516,42 @@ function footerfunctions()
});
</script>
<!-- pdf document -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.0/xlsx.full.min.js"></script>
<script>
document.getElementById('downloadCsv').addEventListener('click', function() {
const table = document.getElementById('myTable');
const rows = Array.from(table.rows);
const data = [];
rows.forEach((row) => {
const cells = Array.from(row.cells);
const rowData = [];
cells.forEach((cell) => {
// Handle colspan
const colspan = cell.colSpan || 1;
for (let i = 0; i < (colspan - 1); i++) {
rowData.push(''); // Fill empty cells for merged columns
}
for (let i = 0; i < 1; i++) {
rowData.push(cell.innerText.trim());
}
// Fill empty cells for colspan
});
data.push(rowData);
});
// Create a worksheet
const worksheet = XLSX.utils.aoa_to_sheet(data);
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
// Export to Excel
XLSX.writeFile(workbook, 'table.xlsx');
});
</script>
<!-- pdf document ends-->
<?php
}

View File

@ -0,0 +1,405 @@
<?php
$this->load->library("BIBAccounts");
$BIBAccounts = new BIBAccounts();
?>
<div class="content-wrapper">
<section class="content">
<div class="container-fluid">
<div class="card card-primary card-outline">
<div class="card-header">
<h3 class="card-title mt-1"><?php echo $pageTitle; ?> </h3>
<div class="card-tools">
<form method="post" action="" id="FilterForm">
<!-- button with a dropdown -->
<div class="btn-group">
<button type="button" class="btn btn-success btn-sm dropdown-toggle" data-toggle="dropdown" data-offset="-52">
Filters
</button>
<div class="dropdown-menu" role="menu">
<div class="form-group p-2 pb-0">
<div class="col">
<div class="form-group">
<label for="fromDate"><?php myLang("Starting Period"); ?></label>
<input type="text" class="form-control " name="fromDate" value="<?php echo (isset($_POST['fromDate'])) ? $_POST['fromDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_from); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="fromDate" aria-describedby="helpId_fromDate" placeholder="Starting Period">
</div>
<div class="form-group">
<label for="toDate"><?php myLang("Ending Period"); ?></label>
<input type="text" class="form-control " name="toDate" value="<?php echo (isset($_POST['toDate'])) ? $_POST['toDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_to); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="toDate" aria-describedby="helpId_toDate" placeholder="Ending Period">
</div>
</div>
<div class="dropdown-divider"></div>
<!-- <div class="form-check">
<input class="form-check-input" type="checkbox">
<label class="form-check-label">Select
All</label>
</div> -->
<div class="form-check">
<!-- <input type="hidden" name="showOB" value="not"> -->
<input type="checkbox" class="form-check-input " name="showOB" id="showOB" aria-describedby="helpId_showOB" placeholder="Show Opening Balance" <?php echo (isset($_POST['showOB'])) ? "CHECKED" : ""; ?>>
<!-- <input class="form-check-input" type="checkbox"> -->
<label class="form-check-label" for="showOB">Opening</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox"> -->
<input type="checkbox" class="form-check-input " name="showClosing" id="showClosing" aria-describedby="helpId_showClosing" placeholder="Show Closing Balance" <?php echo (isset($_POST['showClosing'])) ? "CHECKED" : ""; ?>>
<label class="form-check-label" for="showClosing">Closing</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox" checked> -->
<input type="checkbox" class="form-check-input" name="showPeriod" id="showPeriod" aria-describedby="helpId_showPeriod" placeholder="Show Periodic Balance" <?php echo (isset($_POST['showPeriod'])) ? "CHECKED" : "CHECKED"; ?>>
<label class="form-check-label" for="showPeriod">Period</label>
</div>
</div>
<div class="dropdown-divider"></div>
<div class="form-group p-2 pb-0 text-right">
<button type="button" class="btn btn-info btn-sm " style="width:60px;height:30px;" onclick="resetForm()">Reset</button>
<button type="submit" class="btn btn-primary mr-2 btn-sm" style="width:60px;height:30px;">Search </button>
</div>
</div>
</div>
<div class="btn-group">
<button type="submit" class="btn btn-warning btn-sm " data-toggle="dropdown" data-offset="-52">
Export
</button>
<!-- <button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle
Collapse</button> -->
<!-- <div class="dropdown-menu" role="menu">
<a href="#" class="dropdown-item">Export</a>
<a href="#" class="dropdown-item">Pdf</a>
<div class="dropdown-divider"></div>
<a href="#" class="dropdown-item">View calendar</a>
</div> -->
</div>
<button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle Collapse</button>
</form>
<script>
function resetForm() {
document.getElementById("fromDate").value = "<?php echo NepaliDate($this->session->FiscalYear->fiscalyear_from); ?>";
document.getElementById("toDate").value = "<?php echo NepaliDate($this->session->FiscalYear->fiscalyear_to); ?>";
document.getElementById("showOB").checked = <?php echo "false"; ?>;
document.getElementById("showClosing").checked = <?php echo "false"; ?>;
document.getElementById("FilterForm").submit();
}
</script>
</div>
<!-- /.card-tools -->
</div>
<!-- <div class="card-body">
<form method="post" action="" id="FilterForm">
<div class="row align-items-end">
<div class="col-2">
<div class="form-group">
<label for="fromDate"><?php //myLang("Starting Period"); ?></label>
<input type="text" class="form-control nepaliDatePicker" name="fromDate" value="<?php //echo (isset($_POST['fromDate'])) ? $_POST['fromDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_from); ?>" id="fromDate" aria-describedby="helpId_fromDate" placeholder="Starting Period">
</div>
</div>
<div class="col-2">
<div class="form-group">
<label for="toDate"><?php //myLang("Ending Period"); ?></label>
<input type="text" class="form-control nepaliDatePicker" name="toDate" value="<?php //echo (isset($_POST['toDate'])) ? $_POST['toDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_to); ?>" id="toDate" aria-describedby="helpId_toDate" placeholder="Ending Period">
</div>
</div>
<div class="col-1 text-center">
<div class="form-group">
<label for="showOB"><?php// myLang("Opening"); ?></label>
<input type="checkbox" class="form-control " name="showOB" id="showOB" aria-describedby="helpId_showOB" placeholder="Show Opening Balance" <?php echo (isset($_POST['showOB'])) ? "" : "CHECKED"; ?>>
</div>
</div>
<div class="col-1 text-center">
<div class="form-group">
<label for="showClosing"><?php //myLang("Closing"); ?></label>
<input type="checkbox" class="form-control " name="showClosing" id="showClosing" aria-describedby="helpId_showClosing" placeholder="Show Closing Balance" <?php echo (isset($_POST['showClosing'])) ? "" : "CHECKED"; ?>>
</div>
</div>
<div class="col-1 text-center">
<div class="form-group">
<label for="showPeriod"><?php //myLang("Period"); ?></label>
<input type="checkbox" class="form-control " name="showPeriod" id="showPeriod" aria-describedby="helpId_showPeriod" placeholder="Show Periodic Balance" <?php echo (isset($_POST['showPeriod'])) ? "CHECKED" : "CHECKED"; ?>>
</div>
</div>
<div class="col">
<div class="form-group d-flex justify-content-end">
<button type="submit" class="btn btn-primary mr-2">Filter</button>
<button type="submit" class="btn btn-success mr-2">Export</button>
<button type="button" class="btn btn-warning" onclick="resetForm()">Reset</button>
</div>
</div>
</div>
</form>
<script>
function resetForm() {
document.getElementById("fromDate").value = "2078-4-1";
document.getElementById("toDate").value = "2079-3-32";
document.getElementById("showOB").checked = false;
document.getElementById("showClosing").checked = false;
document.getElementById("FilterForm").submit();
}
</script>
</div> -->
</div>
</div><!-- /.container-fluid -->
</section>
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col">
<!-- <button class="btn btn-secondary toggle-collapse mr-2" id="toggleShowAll">Toggle Collapse</button> -->
<div class="card card-primary card-outline">
<div class="card-body p-0">
<?php
// echo $_POST['showClosing'];
$ReportOptions = array(
'showZeroBalances' => false,
'showOB' => false,
'showClosing' => true,
'showPeriod' => false,
);
?>
<table class="table table-bordered">
<thead>
<tr>
<td class="group-name "><b>Liabilities</b></td>
<td class="group-total text-right pr-2 "><b>Amount</b></td>
<td class="group-name"><b>Assets</b></td>
<td class="group-total text-right pr-2"><b>Amount</b></td>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2" class="p-0">
<?php $AccountGroups = $BIBAccounts->getAccountGroupsWithBalances(2); ?>
<?php $Side1Total = 0; ?>
<table class="table table-bordered vertical-borders" id="TrialBalanceTable">
<?php
// Initialize variables for column totals
$incomes_totalOpeningDr = 0;
$incomes_totalOpeningCr = 0;
$incomes_totalThisYearDr = 0;
$incomes_totalThisYearCr = 0;
$incomes_totalClosingDr = 0;
$incomes_totalClosingCr = 0;
?>
<?php foreach ($AccountGroups as $group) : ?>
<tr class="group-heading" data-toggle="collapse" data-target="#group_<?php echo $group->acgroup_id; ?>">
<td><b><?php echo $group->acgroup_name; ?></b></td>
<td width="20%"><?php echo myCurrency(($group->posting_side == "CR") ? $group->closing_balance : 0); ?></td>
</tr>
<tr>
<td colspan="7" class="group-details p-0">
<div id="group_<?php echo $group->acgroup_id; ?>" class="">
<?php $Accountcategories = $BIBAccounts->getRootCategoriesWithBalances($group->acgroup_id); ?>
<?php $BIBAccounts->renderAccountCategoriesTable($Accountcategories, $ReportOptions, false, array()); ?>
</div>
</td>
</tr>
<?php
// Update column totals
$Side1Total += $group->closing_balance;
?>
<?php endforeach; ?>
</table>
<?php $AccountGroups = $BIBAccounts->getAccountGroupsWithBalances(5); ?>
<table class="table table-bordered vertical-borders" id="TrialBalanceTable">
<?php
// Initialize variables for column totals
$incomes_totalOpeningDr = 0;
$incomes_totalOpeningCr = 0;
$incomes_totalThisYearDr = 0;
$incomes_totalThisYearCr = 0;
$incomes_totalClosingDr = 0;
$incomes_totalClosingCr = 0;
?>
<?php foreach ($AccountGroups as $group) : ?>
<tr class="group-heading" data-toggle="collapse" data-target="#group_<?php echo $group->acgroup_id; ?>">
<td class="group-name"><b><?php echo $group->acgroup_name; ?></b></td>
<td class="group-total"><?php echo myCurrency(($group->posting_side == "CR") ? $group->closing_balance : 0); ?></td>
</tr>
<tr>
<td colspan="7" class="group-details p-0">
<div id="group_<?php echo $group->acgroup_id; ?>" class="">
<?php $Accountcategories = $BIBAccounts->getRootCategoriesWithBalances($group->acgroup_id); ?>
<?php $BIBAccounts->renderAccountCategoriesTable($Accountcategories, $ReportOptions, false, array()); ?>
</div>
</td>
</tr>
<?php
// Update column totals
$Side1Total += $group->closing_balance;
?>
<?php endforeach; ?>
</table>
</td>
<td colspan="2" class="p-0">
<?php $AccountGroups = $BIBAccounts->getAccountGroupsWithBalances(1); ?>
<table class="table table-bordered vertical-borders" id="TrialBalanceTable">
<?php
// Initialize variables for column totals
$totalOpeningDr = 0;
$totalOpeningCr = 0;
$totalThisYearDr = 0;
$totalThisYearCr = 0;
$totalClosingDr = 0;
$totalClosingCr = 0;
?>
<?php foreach ($AccountGroups as $group) : ?>
<tr class="group-heading" data-toggle="collapse" data-target="#group_<?php echo $group->acgroup_id; ?>">
<td class="group-name"><b><?php echo $group->acgroup_name; ?></b></td>
<td class="group-total text-right pr-2"><?php echo myCurrency(($group->posting_side == "DR") ? $group->closing_balance : 0); ?></td>
</tr>
<tr>
<td colspan="7" class="group-details p-0">
<div id="group_<?php echo $group->acgroup_id; ?>" class="">
<?php $Accountcategories = $BIBAccounts->getRootCategoriesWithBalances($group->acgroup_id); ?>
<?php $BIBAccounts->renderAccountCategoriesTable($Accountcategories, $ReportOptions, false, array()); ?>
</div>
</td>
</tr>
<?php
// Update column totals
$totalOpeningDr += ($group->posting_side == "DR") ? $group->opening_balance : 0;
$totalOpeningCr += ($group->posting_side == "CR") ? $group->opening_balance : 0;
$totalThisYearDr += ($group->posting_side == "DR") ? $group->regular_balance : 0;
$totalThisYearCr += ($group->posting_side == "CR") ? $group->regular_balance : 0;
$totalClosingDr += ($group->posting_side == "DR") ? $group->closing_balance : 0;
$totalClosingCr += ($group->posting_side == "CR") ? $group->closing_balance : 0;
?>
<?php endforeach; ?>
</table>
</td>
</tr>
<?php
// pre($BIBAccounts->getAccountGroupsWithBalances(4));
$TotalIncomes = $BIBAccounts->getAccountGroupsWithBalances(3)[0]->closing_balance;
$TotalExpenses = $BIBAccounts->getAccountGroupsWithBalances(4)[0]->closing_balance;
$PL = $TotalIncomes - $TotalExpenses;
$Side1Total += $PL;
?>
<tr>
<td colspan="2" class="p-0">
<table class="table table-bordered">
<tr>
<td>Total Profit/Loss</td>
<td class="cr closing-cr"><?php echo myCurrency($PL); ?></td>
</tr>
</table>
</td>
<td colspan="2" class="p-0">
</td>
</tr>
<tr>
<td colspan="2" class="p-0">
<table class="table table-bordered">
<tr>
<th>Total Amount</th>
<th class="cr closing-cr">
<?php echo myCurrency($Side1Total); ?>
</th>
</tr>
</table>
</td>
<td colspan="2" class="p-0">
<table class="table table-bordered">
<tr>
<th>Total Amount</th>
<th class="dr closing-dr">
<?php echo myCurrency($totalClosingDr); ?>
</th>
</tr>
</table>
</td>
</tr>
</table>
<?php //pre($BIBAccounts->getAccountGroupsWithBalances($acgroup_id = null));
?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
function footerfunctions()
{
?>
<script>
$(document).ready(function() {
// Prevent the dropdown from closing when clicking inside
$('.dropdown-menu').on('click', function(event) {
event.stopPropagation();
});
});
</script>
<script>
$(document).ready(function() {
document.getElementById("toggleShowAll").click();
});
document.getElementById("toggleShowAll").addEventListener("click", function(e) {
e.preventDefault();
var nestedRows = document.getElementsByClassName("collapse");
for (var i = 0; i < nestedRows.length; i++) {
if (nestedRows[i].classList.contains("show")) {
nestedRows[i].classList.remove("show");
} else {
nestedRows[i].classList.add("show");
}
}
});
var exportButton = document.getElementById("exportButton");
exportButton.addEventListener("click", function() {
exportTableToCSV("table.csv");
});
function exportTableToCSV(filename) {
var csv = [];
var rows = document.querySelectorAll("table tr:not(.hide)");
for (var i = 0; i < rows.length; i++) {
var row = [];
var cols = rows[i].querySelectorAll("td:not(.hide), th:not(.hide)");
// Check if the parent row is collapsed or hidden
var parentRow = rows[i].closest(".collapse");
var isParentCollapsed = parentRow && (!parentRow.classList.contains("show"));
if (isParentCollapsed) {
continue; // Skip child table rows if parent is collapsed
}
for (var j = 0; j < cols.length; j++) {
var cellValue = cols[j].innerText.replace(/,/g, ""); // Remove commas from the cell value
row.push(cellValue);
}
csv.push(row.join(","));
}
// Create a CSV file
var csvContent = "data:text/csv;charset=utf-8," + csv.join("\n");
var encodedUri = encodeURI(csvContent);
var link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", filename);
document.body.appendChild(link);
link.click();
}
</script>
<script>
$("#fromDate").nepaliDatePicker({
dateFormat: "%y-%m-%d",
closeOnDateSelect: true,
minDate: $('#fromDate').data('start'),
maxDate: $('#fromDate').data('end'),
});
</script>
<script>
$("#toDate").nepaliDatePicker({
dateFormat: "%y-%m-%d",
closeOnDateSelect: true,
minDate: $('#toDate').data('start'),
maxDate: $('#toDate').data('end'),
});
</script>
<?php
}

View File

@ -8,9 +8,7 @@ $ExpenseAccounts = $this->acc->getAccountsByGroup(4);
$IncomesTotal = $this->acc->getAccountBalanceByGroup(3);
$ExpensesTotal = $this->acc->getAccountBalanceByGroup(4);
$PL = $IncomesTotal - $ExpensesTotal;
?>
<style>
table,
td,
@ -92,78 +90,109 @@ $PL = $IncomesTotal - $ExpensesTotal;
box-shadow: inset 0 0 0 transparent;
transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}
.table1 {
border: 0px !important;
padding: 0;
margin: 10 !important;
width: 100%;
vertical-align: middle;
}
.table-responsive {
overflow-x: auto;
}
.card-body {
-webkit-flex: 1 1 auto;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
min-height: 1px;
padding: 0;
}
table {
border: 1px solid #ddd;
border-collapse: collapse;
}
.card-body.p-0 .table tbody>tr>td:last-of-type,
.card-body.p-0 .table tbody>tr>th:last-of-type,
.card-body.p-0 .table tfoot>tr>td:last-of-type,
.card-body.p-0 .table tfoot>tr>th:last-of-type,
.card-body.p-0 .table thead>tr>td:last-of-type,
.card-body.p-0 .table thead>tr>th:last-of-type {
padding-right: 0 !important;
}
.text-bold {
font-weight: 900;
}
</style>
<div class="content-wrapper">
<section class="content">
<div class="container-fluid">
<div class="card card-primary card-outline">
<div class="card-header ">
<h3 class="card-title">Cash Flow<?php //echo $pageTitle;
<h3 class="card-title mt-1">Cash Flow<?php //echo $pageTitle;
?> </h3>
<div class="card-tools">
<form method="post" action="" id="FilterForm">
<form method="post" action=<?php echo base_url('accounts/reports/cash_flow'); ?> id="FilterForm">
<!-- button with a dropdown -->
<div class="btn-group">
<button type="button" class="btn btn-success btn-sm dropdown-toggle" data-toggle="dropdown" data-offset="-52">
Filters
</button>
<div class="dropdown-menu" role="menu">
<div class="form-group p-2 pb-0">
<div class="col">
<div class="form-group">
<label for="fromDate"><?php myLang("Starting Period"); ?></label>
<input type="text" class="form-control " name="fromDate" value="<?php echo (isset($_POST['fromDate'])) ? $_POST['fromDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_from); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="fromDate" aria-describedby="helpId_fromDate" placeholder="Starting Period">
</div>
<div class="form-group">
<label for="toDate"><?php myLang("Ending Period"); ?></label>
<input type="text" class="form-control " name="toDate" value="<?php echo (isset($_POST['toDate'])) ? $_POST['toDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_to); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="toDate" aria-describedby="helpId_toDate" placeholder="Ending Period">
</div>
</div>
<div class="dropdown-divider"></div>
<div class="form-check">
<!-- <div class="form-check">
<input class="form-check-input" type="checkbox">
<label class="form-check-label">Select
All</label>
</div>
</div> -->
<div class="form-check">
<input type="hidden" name="showOB" value="not">
<!-- <input type="hidden" name="showOB" value="not"> -->
<input type="checkbox" class="form-check-input " name="showOB" id="showOB" aria-describedby="helpId_showOB" placeholder="Show Opening Balance" <?php echo (isset($_POST['showOB'])) ? "CHECKED" : ""; ?>>
<!-- <input class="form-check-input" type="checkbox"> -->
<label class="form-check-label">Opening</label>
<label class="form-check-label" for="showOB">Opening</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox"> -->
<input type="checkbox" class="form-check-input " name="showClosing" id="showClosing" aria-describedby="helpId_showClosing" placeholder="Show Closing Balance" <?php echo (isset($_POST['showClosing'])) ? "CHECKED" : ""; ?>>
<label class="form-check-label">Closing</label>
<label class="form-check-label" for="showClosing">Closing</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox" checked> -->
<input type="checkbox" class="form-check-input" name="showPeriod" id="showPeriod" aria-describedby="helpId_showPeriod" placeholder="Show Periodic Balance" <?php echo (isset($_POST['showPeriod'])) ? "CHECKED" : "CHECKED"; ?>>
<label class="form-check-label">Period</label>
<label class="form-check-label" for="showPeriod">Period</label>
</div>
</div>
<div class="dropdown-divider"></div>
<button type="submit" class="btn btn-primary mr-2 text-center">Search Now</button>
<div class="form-group p-2 pb-0 text-right">
<button type="button" class="btn btn-info btn-sm " style="width:60px;height:30px;" onclick="resetForm()">Reset</button>
<button type="submit" class="btn btn-primary mr-2 btn-sm" style="width:60px;height:30px;">Search </button>
</div>
</div>
</div>
<div class="btn-group">
<button type="submit" class="btn btn-danger btn-sm " data-toggle="dropdown" data-offset="-52">
<!-- <button type="submit" class="btn btn-warning btn-sm " data-toggle="dropdown" data-offset="-52">
Export
</button> -->
<button type="submit" id="downloadCsv" class="btn btn-warning btn-sm ">
Export csv
</button>
<!-- <div class="dropdown-menu" role="menu">
<a href="#" class="dropdown-item">Export</a>
<a href="#" class="dropdown-item">Pdf</a>
@ -171,10 +200,9 @@ $PL = $IncomesTotal - $ExpensesTotal;
<a href="#" class="dropdown-item">View calendar</a>
</div> -->
</div>
<button type="button" class="btn btn-warning btn-sm" onclick="resetForm()">Reset</button>
<button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle Collapse</button>
<!-- <button type="button" class="btn btn-warning btn-sm" onclick="resetForm()">Reset</button> -->
<!-- <button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle Collapse</button> -->
</form>
<script>
function resetForm() {
@ -230,9 +258,7 @@ $PL = $IncomesTotal - $ExpensesTotal;
</div>
</div>
</div>
</form>
<script>
function resetForm() {
document.getElementById("fromDate").value = "2078-4-1";
@ -242,31 +268,30 @@ $PL = $IncomesTotal - $ExpensesTotal;
document.getElementById("FilterForm").submit();
}
</script>
</div> -->
</div>
<!-- <button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle Collapse</button> -->
<div class="card card-primary card-outline">
<!-- <div class="card-header">
<h4 class="card-title">Cash Flow</h4>
</div> -->
<div class="card-body table-responsive p-0">
<?php $IncomesExpenses = $BIBAccounts->prepareIncomeExpenses($fiscalStart, $fiscalEnd);
// echo "<pre>";print_r($IncomesExpenses); die();
?>
<?php $IncomesExpenses = $BIBAccounts->prepareIncomeExpenses() ?>
<table class="table table-head-fixed table-bordered g-0">
<table id='myTable' class="table table-bordered p-0 ">
<thead>
<tr>
<th class="" width="35%"><?php myLang("Cash inflow"); ?></th>
<th class="text-right" width="15%"></th>
<th class="text-right" width="15%"><?php myLang("Amount"); ?></th>
<th class="" width="35%"><?php echo myLang("Cash outflow"); ?></th>
<th class="text-right" width="15%"></th>
<th class="text-right" width="15%"><?php myLang("Amount"); ?></th>
<th class="" width="30%"><?php myLang("Cash inflow"); ?></th>
<th class="text-right" width="10%"></th>
<th class="text-right pr-1" width="10%"><?php myLang("Amount"); ?></th>
<th class="pl-2" width="30%"><?php echo myLang("Cash outflow"); ?></th>
<th class="text-right" width="10%"></th>
<th class="text-right pr-1" width="10%"><?php myLang("Amount"); ?></th>
</tr>
</thead>
<tbody>
@ -274,37 +299,35 @@ $PL = $IncomesTotal - $ExpensesTotal;
<td colspan=3 class="p-0">
<table class="table g-0">
<?php $total1 = 0;
$counter = 0;
$index = 0;
foreach ($IncomesExpenses['Incomes'] as $Incomes) { ?>
<?php if ($Incomes['account'] == "GROUP TOTAL") : ?>
<!-- <tr>
<td class="" width="70%"><b><?php echo $Incomes['group']; ?></b></td>
<td width="15%"></td>
<td class="text-right" width="15%"><u><?php echo myCurrency($Incomes['amount']); ?></u></td>
</tr> -->
<?php elseif ($Incomes['account'] == "CATEGORY TOTAL") : ?>
<tr>
<td class="" width="70%"><b><?php echo $Incomes['category']; ?></b></td>
<td class="text-right" width="15%"><?php echo myCurrency($Incomes['amount']); ?></td>
<td width="15%"></td>
<tr class="parent-row" class="group-heading" data-toggle="collapse" data-target="#group_<?php echo $index; ?>">
<td class="" width="60%"><b><?php echo $Incomes['category']; ?></b></td>
<td width="20%"></td>
<td class="text-right " width="20%"><?php echo myCurrency($Incomes['amount']); ?></td>
</tr>
<?php else : ?>
<?php $total1 += $Incomes['amount']; ?>
<tr>
<td class="" width="70%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $Incomes['account']; ?></td>
<td width="15%"></td>
<td class="text-right" width="15%"><?php echo myCurrency($Incomes['amount']); ?></td>
<tr class="collapse" data-target="#group_<?php echo $index; ?>">
<td class="" width="60%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $Incomes['account']; ?></td>
<td class="text-right " width="20%"><?php echo myCurrency($Incomes['amount']); ?></td>
<td width="20%"></td>
</tr>
<?php endif; ?>
<?php $counter = $index ?>
<?php }; ?>
</table>
</td>
<td colspan=3 class="p-0">
<table class="table g-0">
<table class="table p-0">
<?php $total = 0;
foreach ($IncomesExpenses['Expenses'] as $Expenses) {
if ($Expenses['account'] == "GROUP TOTAL") : ?>
@ -312,53 +335,41 @@ $PL = $IncomesTotal - $ExpensesTotal;
<td class="" width="70%"><b><?php echo $Expenses['group']; ?></b></td>
<td width="15%"></td>
<td class="text-right" width="15%"><u><?php echo myCurrency($Expenses['amount']); ?></u></td>
</tr> -->
<?php elseif ($Expenses['account'] == "CATEGORY TOTAL") : ?>
<tr>
<td class="" width="70%"><b><?php echo $Expenses['category']; ?></b></td>
<td class="text-right" width="15%"><?php echo myCurrency($Expenses['amount']); ?></td>
<td width="15%"></td>
<tr data-toggle="collapse" data-target="#group_<?php echo $counter; ?>">
<td class="" width="60%"><b><?php echo $Expenses['category']; ?></b></td>
<td width="20%"></td>
<td class="text-right " width="20%"><?php echo myCurrency($Expenses['amount']); ?></td>
</tr>
<?php else : ?>
<?php $total += $Expenses['amount']; ?>
<tr>
<td class="" width="70%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $Expenses['account']; ?></td>
<td width="15%"></td>
<td class="text-right" width="15%"><?php echo myCurrency($Expenses['amount']); ?></td>
<tr class="collapse" data-target="#group_<?php echo $counter; ?>">
<td class="" width="60%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $Expenses['account']; ?></td>
<td class="text-right" width="20%"><?php echo myCurrency($Expenses['amount']); ?></td>
<td width="20%"></td>
</tr>
<?php endif; ?>
<?php }; ?>
</table>
</td>
</tr>
</tbody>
<tr>
<th>Total</th>
<th class="p-1">Total</th>
<td></td>
<td class="text-right"><?php echo myCurrency($total1); ?></td>
<th>Total</th>
<td class="text-right text-bold"><?php echo myCurrency($total1); ?></td>
<th class="p-1">Total</th>
<td></td>
<td class="text-right"><?php echo myCurrency($total); ?></td>
<td class="text-right text-bold"><?php echo myCurrency($total); ?></td>
</tr>
<tr>
<th></th>
<td></td>
<td class="text-right"></td>
<th>Net Inflow</th>
<th class="pl-1">Net Inflow</th>
<td></td>
<td class="text-right"><?php echo myCurrency($total1 - $total); ?></td>
<td class="text-right text-bold"><?php echo myCurrency($total1 - $total); ?></td>
</tr>
<?php $Bank = $BIBAccounts->getAccountCategoriesWithBalances(null, 2); ?>
<?php foreach ($Bank->accounts as $account) : ?>
@ -366,40 +377,88 @@ $PL = $IncomesTotal - $ExpensesTotal;
<th></th>
<td></td>
<td class="text-right"></td>
<th><?php echo $account->account_name; ?></th>
<th class="pl-1"><?php echo $account->account_name; ?></th>
<td></td>
<td class="text-right"><?php echo myCurrency($account->balances['dr_total'] - $account->balances['cr_total']); ?></td>
<td class="text-right text-bold"><?php echo myCurrency($account->balances['dr_total'] - $account->balances['cr_total']); ?></td>
</tr>
<?php endforeach; ?>
<?php $Cash = $BIBAccounts->getAccountCategoriesWithBalances(null, 3); ?>
<?php foreach ($Cash->accounts as $account) : ?>
<tr>
<th></th>
<td></td>
<td class="text-right"></td>
<th><?php echo $account->account_name; ?></th>
<th class="pl-1"><?php echo $account->account_name; ?></th>
<td></td>
<td class="text-right"><?php echo myCurrency($account->balances['dr_total'] - $account->balances['cr_total']); ?></td>
<td class="text-right text-bold"><?php echo myCurrency($account->balances['dr_total'] - $account->balances['cr_total']); ?></td>
</tr>
<?php endforeach; ?>
</table>
<?php //pre($IncomesExpenses);
?>
</div>
</div>
</div><!-- /.container-fluid -->
</section>
<?php function footerFunctions()
{ ?>
<script>
$(document).ready(function() {
// Prevent the dropdown from closing when clicking inside
$('.dropdown-menu').on('click', function(event) {
event.stopPropagation();
});
});
</script>
<script>
// var exportButton = document.getElementById("exportButton");
// exportButton.addEventListener("click", function() {
// exportTableToCSV("table.csv");
// });
document.addEventListener("DOMContentLoaded", function() {
// Trigger click event on page load
document.getElementById("toggleShowAll").click();
});
document.getElementById("toggleShowAll").addEventListener("click", function(e) {
e.preventDefault();
var nestedRows = document.getElementsByClassName("collapse");
for (var i = 0; i < nestedRows.length; i++) {
if (nestedRows[i].classList.contains("show")) {
nestedRows[i].classList.remove("show");
} else {
nestedRows[i].classList.add("show");
}
}
});
function exportTableToCSV(filename) {
var csv = [];
var rows = document.querySelectorAll("table tr:not(.hide)");
for (var i = 0; i < rows.length; i++) {
var row = [];
var cols = rows[i].querySelectorAll("td:not(.hide), th:not(.hide)");
// Check if the parent row is collapsed or hidden
var parentRow = rows[i].closest(".collapse");
var isParentCollapsed = parentRow && (!parentRow.classList.contains("show"));
if (isParentCollapsed) {
continue; // Skip child table rows if parent is collapsed
}
for (var j = 0; j < cols.length; j++) {
var cellValue = cols[j].innerText.replace(/,/g, ""); // Remove commas from the cell value
row.push(cellValue);
}
csv.push(row.join(","));
}
// Create a CSV file
var csvContent = "data:text/csv;charset=utf-8," + csv.join("\n");
var encodedUri = encodeURI(csvContent);
var link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", filename);
document.body.appendChild(link);
link.click();
}
</script>
<script>
$("#fromDate").nepaliDatePicker({
dateFormat: "%y-%m-%d",
@ -416,4 +475,40 @@ $PL = $IncomesTotal - $ExpensesTotal;
maxDate: $('#toDate').data('end'),
});
</script>
<!-- pdf document -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.0/xlsx.full.min.js"></script>
<script>
document.getElementById('downloadCsv').addEventListener('click', function() {
const table = document.getElementById('myTable');
const rows = Array.from(table.rows);
const data = [];
rows.forEach((row) => {
const cells = Array.from(row.cells);
const rowData = [];
cells.forEach((cell) => {
// Handle colspan
const colspan = cell.colSpan || 1;
for (let i = 0; i < (colspan - 1); i++) {
rowData.push(''); // Fill empty cells for merged columns
}
for (let i = 0; i < 1; i++) {
rowData.push(cell.innerText.trim());
}
// Fill empty cells for colspan
});
data.push(rowData);
});
// Create a worksheet
const worksheet = XLSX.utils.aoa_to_sheet(data);
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
// Export to Excel
XLSX.writeFile(workbook, 'table.xlsx');
});
</script>
<!-- pdf document ends-->
<?php } ?>

View File

@ -1,24 +1,97 @@
<style>
.mt-26 {
margin-top: 26px;
}
</style>
<div class="content-wrapper">
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col">
<div class="card card-primary card-outline">
<div class="card-header">
<h5 class="m-0"><?php echo $pageTitle; ?> </h5>
<h3 class="card-title mt-1"><?php echo $pageTitle; ?> </h3>
<div class="card-tools">
<form method="post" action="" id="FilterForm">
<!-- button with a dropdown -->
<div class="btn-group">
<button type="button" class="btn btn-success btn-sm dropdown-toggle" data-toggle="dropdown" data-offset="-52">
Filters
</button>
<div class="dropdown-menu" role="menu">
<div class="form-group p-2 pb-0">
<div class="col">
<div class="form-group">
<label for="fromDate"><?php myLang("Starting Period"); ?></label>
<input type="text" class="form-control nepaliDatePicker" name="fromDate" value="<?php echo (isset($_POST['fromDate'])) ? $_POST['fromDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_from); ?>" id="fromDate" aria-describedby="helpId_fromDate" placeholder="Starting Period">
</div>
<div class="form-group">
<label for="toDate"><?php myLang("Ending Period"); ?></label>
<input type="text" class="form-control nepaliDatePicker" name="toDate" value="<?php echo (isset($_POST['toDate'])) ? $_POST['toDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_to); ?>" id="toDate" aria-describedby="helpId_toDate" placeholder="Ending Period">
</div>
</div>
<div class="dropdown-divider"></div>
<div class="form-check">
<input class="form-check-input" type="checkbox">
<label class="form-check-label">Select
All</label>
</div>
<div class="form-check">
<input type="hidden" name="showOB" value="not">
<input type="checkbox" class="form-check-input " name="showOB" id="showOB" aria-describedby="helpId_showOB" placeholder="Show Opening Balance" <?php echo (isset($_POST['showOB'])) ? "CHECKED" : ""; ?>>
<!-- <input class="form-check-input" type="checkbox"> -->
<label class="form-check-label">Opening</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox"> -->
<input type="checkbox" class="form-check-input " name="showClosing" id="showClosing" aria-describedby="helpId_showClosing" placeholder="Show Closing Balance" <?php echo (isset($_POST['showClosing'])) ? "CHECKED" : ""; ?>>
<label class="form-check-label">Closing</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox" checked> -->
<input type="checkbox" class="form-check-input" name="showPeriod" id="showPeriod" aria-describedby="helpId_showPeriod" placeholder="Show Periodic Balance" <?php echo (isset($_POST['showPeriod'])) ? "CHECKED" : "CHECKED"; ?>>
<label class="form-check-label">Period</label>
</div>
</div>
<div class="dropdown-divider"></div>
<div class="form-group p-2 pb-0">
<button type="button" class="btn btn-info btn-sm " onclick="resetForm()">Reset</button>
<button type="submit" class="btn btn-primary mr-2 btn-sm text-center">Search </button>
</div>
</div>
</div>
<div class="btn-group">
<!-- <button type="submit" class="btn btn-warning btn-sm " data-toggle="dropdown" data-offset="-52">
Export
</button> -->
<button type="submit" id="downloadCsv" class="btn btn-warning btn-sm ">
Export csv
</button>
<!-- <div class="dropdown-menu" role="menu">
<a href="#" class="dropdown-item">Export</a>
<a href="#" class="dropdown-item">Pdf</a>
<div class="dropdown-divider"></div>
<a href="#" class="dropdown-item">View calendar</a>
</div> -->
</div>
<!-- <button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle Collapse</button> -->
</form>
<script>
function resetForm() {
document.getElementById("fromDate").value = "<?php echo NepaliDate($this->session->FiscalYear->fiscalyear_from); ?>";
document.getElementById("toDate").value = "<?php echo NepaliDate($this->session->FiscalYear->fiscalyear_to); ?>";
document.getElementById("showOB").checked = <?php echo "false"; ?>;
document.getElementById("showClosing").checked = <?php echo "false"; ?>;
document.getElementById("FilterForm").submit();
}
</script>
</div>
</div>
<div class="card-body">
<form method="GET" action="">
<div class="row">
<div class="col-2"><?php createNepaliDateInput("from_date", "Date", "from_date", isset($_GET['from_date']) ? $_GET['from_date'] : ''); ?></div>
<div class="col-1"><?php createButton("show_voucher", "Show", "show_voucher", "Submit", "mt-30"); ?></div>
<div class="col-1"><?php createButton("show_voucher", "Show", "show_voucher", "Submit", "mt-26 btn btn-block btn-primary btn-sm "); ?></div>
</div>
</form>
<div id="dataTable_Commands"></div>
@ -30,12 +103,46 @@
$vouchertype_id = isset($_GET['vouchertypes']) ? $_GET['vouchertypes'] : '';
$this->myaccounts->listVouchers($fromDate, $fromDate, $account_id, $vouchertype_id, true, true);
?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- pdf document -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.0/xlsx.full.min.js"></script>
<script>
document.getElementById('downloadCsv').addEventListener('click', function() {
const table = document.getElementById('voucherList1');
const rows = Array.from(table.rows);
const data = [];
</div>
</div>
</div>
</div>
</div>
</div>
</div>
rows.forEach((row) => {
const cells = Array.from(row.cells);
const rowData = [];
cells.forEach((cell) => {
// Handle colspan
const colspan = cell.colSpan || 1;
for (let i = 0; i < (colspan - 1); i++) {
rowData.push(''); // Fill empty cells for merged columns
}
for (let i = 0; i < 1; i++) {
rowData.push(cell.innerText.trim());
}
// Fill empty cells for colspan
});
data.push(rowData);
});
// Create a worksheet
const worksheet = XLSX.utils.aoa_to_sheet(data);
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
// Export to Excel
XLSX.writeFile(workbook, 'table.xlsx');
});
</script>
<!-- pdf document ends-->

View File

@ -0,0 +1,70 @@
<div class="card-body">
<div class="row">
<div class="col">
<div id="dataTable_wrapper">
<?php //$this->myaccounts->getAllAccountsTable(3);
?>
<?php
$accategory_id = 3;
$CI = &get_instance();
// $CI->db->where("status", 1)->where("(accategory_id = 2 OR accategory_id = 3)");
$CI->db->where("status", 1)->where("accategory_id = 3")->where("created_on >= '$fiscalStart'")->where("created_on >= '$fiscalEnd'");
$CI->db->order_by("account_name ASC");
$Accounts = $CI->db->get("tbl_accounts")->result();
foreach ($Accounts as $Account) {
$Account->Group = $CI->db->query("select * from tbl_acgroups where acgroup_id=(select acgroup_id from tbl_accategories where accategory_id = $Account->accategory_id)")->row();
$Account->Category = $CI->db->query("select * from tbl_accategories where accategory_id = $Account->accategory_id")->row();
}
?>
<div class="row mb-3">
<!-- <div id="dataTable_commands" class="col text-right"></div> -->
</div>
<?php
$html = "";
$html .= "<table id='myTable' class='table table-bordered table-striped longdataTable'>";
$html .= "<thead>";
$html .= "<tr><th class='text-center' width='25'>Sn</th><th class='text-center'>Account</th><th class='text-center'>Account Group</th><th class='text-center'>Dr</th><th class='text-center'>Cr</th><th class='text-center'>Balance</th><th class='text-center col-1'>Action</th></tr>";
$html .= "</thead><tbody>";
$sn = 0;
$BalanceTotal = 0;
foreach ($Accounts as $Account) : $sn++;
$balance = getBalance($Account->account_id);
$BalanceTotal += $balance;
// pre($Account);
$html .= "<tr><td class='col-1 text-center'>" . $sn . "</td><td><a href='#' onClick='showLedger(" . $Account->account_id . ")'>" . $Account->account_name . "</a></td><td class='col-2'>" . $Account->Category->accategory_name . "</td><td class='col-1'>" . (($balance >= 0) ? myCurrency($balance) : "") . "</td><td class='col-1'>" . (($balance < 0) ? myCurrency(abs($balance)) : "") . "</td><td class='col-1'>" . (myCurrency($balance)) . "</td><td class=' text-center'><a title='Show Ledger' class='btn btn-info btn-xs ' onClick='showLedger(" . $Account->account_id . ")'><i class='fa fa-eye'></i></a></td></tr>";
endforeach;
$html .= "</tbody><tfoot>";
$html .= "<tr><th colspan=3 class='text-right'>Total</th><th class='text-right'>" . (($BalanceTotal > 0) ? myCurrency(abs($BalanceTotal)) : "") . "</th><th class='text-right'>" . (($BalanceTotal < 0) ? myCurrency(abs($BalanceTotal)) : "") . "</th><th class='text-right'>" . myCurrency($BalanceTotal) . "</th><th></th></tr>";
$html .= "</tfoot></table>\n";
$html .= " <div class=\"modal fade\" id=\"ledgerdetails_box\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"ledgerdetails_box\" aria-hidden=\"true\">
<div class=\"modal-dialog modal-xl\" role=\"document\">
<div class=\"modal-content\">
<div class=\"modal-header\">
<h5 class=\"modal-title\" id=\"exampleModalLabel\">Ledger Details</h5>
<button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Close\">
<span aria-hidden=\"true\">&times;</span>
</button>
</div>
<div class=\"modal-body\" id=\"details_container\">
Ledger Details Goes Here
</div>
<!--<div class=\"modal-footer\">
<button type=\"button\" class=\"btn btn-secondary\" data-dismiss=\"modal\">Close</button>
<button type=\"button\" class=\"btn btn-success\" data-dismiss=\"modal\">Print</button>
</div>-->
</div>
</div>
</div>";
$html .= '<script>function showLedger(id) {$.ajax({url: \'';
$html .= site_url("accounts/reports/ajax/getledgersummary/");
$html .= '\' + id,success: function(data) {$(\'#ledgerdetails_box #details_container\').html(data);$(\'#ledgerdetails_box\').modal(\'show\');}});}</script>';
echo $html;
?>
</div>
</div>
</div>
</div>

View File

@ -1,5 +1,4 @@
<div class="content-wrapper">
<div class="content">
<div class="container-fluid">
<div class="row">
@ -15,8 +14,8 @@
</div> -->
<div class="col">
<div class="card card-primary card-outline">
<div class="card-header bg-primary disabled color-palette">
<h3 class="card-title m-0"><?php echo $pageTitle; ?></h3>
<div class="card-header disabled color-palette">
<h5 class="card-title m-0"><?php echo $pageTitle; ?></h5>
</div>
<div class="card-body">
<div class="row">
@ -79,7 +78,6 @@ $tree .= "]";
var id = $(this).attr("id").substr(8);
showLedger(id);
});
function getAccounts(id) {
$("#accountsContainer").empty();
$.ajax({
@ -94,7 +92,6 @@ $tree .= "]";
});
}
getAccountsAll();
function getAccountsAll() {
$("#accountsContainer").html("");
$.ajax({
@ -107,7 +104,6 @@ $tree .= "]";
}
});
}
function showLedger(id) {
// $("#accountsContainer").html("");
alert(id);

View File

@ -1,18 +1,12 @@
<div class="content-wrapper">
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col">
<div class="card card-primary card-outline">
<div class="card-header bg-primary disabled color-palette">
<h3 class="card-title m-0"><?php echo $pageTitle; ?></h3>
</div>
<div class="card-body">
<form method="GET" action="#">
<div class="row">
@ -22,25 +16,21 @@
<div class="col"><?php createButton("show_ledger", "Show Ledger", "show_ledger", "Submit", "btn btn-primary"); ?></div>
</div>
</form>
<button id="openModal" class="btn btn-primary">Open Modal</button>
</div>
</div>
<div class="card">
<div id="dataTable_Commands">
</div>
<?php
if (!isset($account_id)) {
$account_id = 1;
}
?>
<?php if (isset($account_id) && $account_id != "") {
$fromDate = NepaliToEnglishDate(isset($_GET['from_date']) ? $_GET['from_date'] : firstDayOfNepaliMonth());
$toDate = isset($_GET['to_date']) ? $_GET['to_date'] : Today();
$this->myaccounts->showLedger($account_id, $fromDate, $toDate);
$this->myaccounts->showLedger($account_id, $fromDate, $toDate, $fiscalStart, $fiscalEnd);
} ?>
<div class="modal fade" id="ledgerdetails_box" tabindex="-1" role="dialog" aria-labelledby="ledgerdetails_box" aria-hidden="true">
<div class="modal-dialog modal-xl" role="document">
@ -57,6 +47,9 @@
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-success" data-dismiss="modal">Print</button>
<!-- <button type="submit" id="downloadCsv" class="btn btn-warning btn-sm ">
Export csv
</button> -->
</div>
</div>
</div>
@ -67,4 +60,39 @@
</div>
</div>
</div>
<!-- pdf document -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.0/xlsx.full.min.js"></script>
<script>
document.getElementById('downloadCsv').addEventListener('click', function() {
const table = document.getElementById('myTable');
const rows = Array.from(table.rows);
const data = [];
rows.forEach((row) => {
const cells = Array.from(row.cells);
const rowData = [];
cells.forEach((cell) => {
// Handle colspan
const colspan = cell.colSpan || 1;
for (let i = 0; i < (colspan - 1); i++) {
rowData.push(''); // Fill empty cells for merged columns
}
for (let i = 0; i < 1; i++) {
rowData.push(cell.innerText.trim());
}
// Fill empty cells for colspan
});
data.push(rowData);
});
// Create a worksheet
const worksheet = XLSX.utils.aoa_to_sheet(data);
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
// Export to Excel
XLSX.writeFile(workbook, 'table.xlsx');
});
</script>
<!-- pdf document ends-->

View File

@ -4,8 +4,83 @@
<div class="row">
<div class="col">
<div class="card card-primary card-outline">
<div class="card-header bg-primary disabled color-palette">
<h3 class="card-title"><?php echo $pageTitle; ?> </h3>
<div class="card-header disabled color-palette">
<h3 class="card-title mt-1"><?php echo $pageTitle; ?> </h3>
<div class="card-tools">
<form method="post" action="<?php echo base_url('accounts/ledger/bank_book'); ?>" id="FilterForm">
<!-- button with a dropdown -->
<div class="btn-group">
<button type="button" class="btn btn-success btn-sm dropdown-toggle" data-toggle="dropdown" data-offset="-52">
Filters
</button>
<div class="dropdown-menu" role="menu">
<div class="form-group p-2 pb-0">
<div class="col">
<div class="form-group">
<label for="fromDate"><?php myLang("Starting Period"); ?></label>
<input type="text" class="form-control " name="fromDate" value="<?php echo (isset($_POST['fromDate'])) ? $_POST['fromDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_from); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="fromDate" aria-describedby="helpId_fromDate" placeholder="Starting Period">
</div>
<div class="form-group">
<label for="toDate"><?php myLang("Ending Period"); ?></label>
<input type="text" class="form-control " name="toDate" value="<?php echo (isset($_POST['toDate'])) ? $_POST['toDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_to); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="toDate" aria-describedby="helpId_toDate" placeholder="Ending Period">
</div>
</div>
<div class="dropdown-divider"></div>
<!-- <div class="form-check">
<input class="form-check-input" type="checkbox">
<label class="form-check-label">Select
All</label>
</div> -->
<div class="form-check">
<!-- <input type="hidden" name="showOB" value="not"> -->
<input type="checkbox" class="form-check-input " name="showOB" id="showOB" aria-describedby="helpId_showOB" placeholder="Show Opening Balance" <?php echo (isset($_POST['showOB'])) ? "CHECKED" : ""; ?>>
<!-- <input class="form-check-input" type="checkbox"> -->
<label class="form-check-label" for="showOB">Opening</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox"> -->
<input type="checkbox" class="form-check-input " name="showClosing" id="showClosing" aria-describedby="helpId_showClosing" placeholder="Show Closing Balance" <?php echo (isset($_POST['showClosing'])) ? "CHECKED" : ""; ?>>
<label class="form-check-label" for="showClosing">Closing</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox" checked> -->
<input type="checkbox" class="form-check-input" name="showPeriod" id="showPeriod" aria-describedby="helpId_showPeriod" placeholder="Show Periodic Balance" <?php echo (isset($_POST['showPeriod'])) ? "CHECKED" : "CHECKED"; ?>>
<label class="form-check-label" for="showPeriod">Period</label>
</div>
</div>
<div class="dropdown-divider"></div>
<div class="form-group p-2 pb-0 text-right">
<button type="button" class="btn btn-info btn-sm " style="width:60px;height:30px;" onclick="resetForm()">Reset</button>
<button type="submit" class="btn btn-primary mr-2 btn-sm" style="width:60px;height:30px;">Search </button>
</div>
</div>
</div>
<div class="btn-group">
<button type="submit" id="downloadCsv" class="btn btn-warning btn-sm ">
Export csv
</button>
<!-- <button class="btn btn-warning btn-sm " onclick="exportTableToCSV('accounts_data.csv')">Export to CSV</button> -->
<!-- <div class="dropdown-menu" role="menu">
<a href="#" class="dropdown-item">Export</a>
<a href="#" class="dropdown-item">Pdf</a>
<div class="dropdown-divider"></div>
<a href="#" class="dropdown-item">View calendar</a>
</div> -->
</div>
<!-- <button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle Collapse</button> -->
</form>
<script>
function resetForm() {
document.getElementById("fromDate").value = "<?php echo NepaliDate($this->session->FiscalYear->fiscalyear_from); ?>";
document.getElementById("toDate").value = "<?php echo NepaliDate($this->session->FiscalYear->fiscalyear_to); ?>";
document.getElementById("showOB").checked = <?php echo "false"; ?>;
document.getElementById("showClosing").checked = <?php echo "false"; ?>;
document.getElementById("FilterForm").submit();
}
</script>
</div>
</div>
<div class="card-body">
<div class="row">
@ -17,7 +92,7 @@
$accategory_id = 3;
$CI = &get_instance();
$CI->db->where("status", 1)->where("accategory_id = 2");
$CI->db->where("status", 1)->where("accategory_id = 2")->where('created_on >=', date('Y-m-d', (strtotime($fiscalStart))))->where('created_on <=', date('Y-m-d', (strtotime($fiscalEnd))));
$CI->db->order_by("account_name ASC");
$Accounts = $CI->db->get("tbl_accounts")->result();
@ -33,9 +108,9 @@
<?php
$html = "";
$html .= "<table class='table table-bordered table-striped longdataTable'>";
$html .= "<table id='myTable'class='table table-bordered table-striped longdataTable'>";
$html .= "<thead>";
$html .= "<tr><th class='text-center'>Sn</th><th class='text-center'>Account</th><th class='text-center'>Account Group</th><th class='text-center'>Dr</th><th class='text-center'>Cr</th><th class='text-center'>Action</th></tr>";
$html .= "<tr><th class='text-center col-1'>Sn</th><th class='text-center'>Account</th><th class='text-center'>Account Group</th><th class='text-center'>Dr</th><th class='text-center'>Cr</th><th class='text-center'>Balance</th><th class='text-center col-1 '>Action</th></tr>";
$html .= "</thead><tbody>";
$sn = 0;
$BalanceTotal = 0;
@ -43,10 +118,10 @@
$balance = getBalance($Account->account_id);
$BalanceTotal += $balance;
// pre($Account);
$html .= "<tr><td class='col-1 text-center'>" . $sn . "</td><td><a href='#' onClick='showLedger(" . $Account->account_id . ")'>" . $Account->account_name . "</a></td><td class='col-2'>" . $Account->Category->accategory_name . "</td><td class='col-1'>" . (($balance >= 0) ? myCurrency($balance) : "") . "</td><td class='col-1'>" . (($balance < 0) ? myCurrency(abs($balance)) : "") . "</td><td class='col-2 text-center'><a title='Show Ledger' class='btn btn-info btn-xs ' onClick='showLedger(" . $Account->account_id . ")'><i class='fa fa-eye'></i></a></td></tr>";
$html .= "<tr><td class='col-1 text-center'>" . $sn . "</td><td><a href='#' onClick='showLedger(" . $Account->account_id . ")'>" . $Account->account_name . "</a></td><td class='col-2'>" . $Account->Category->accategory_name . "</td><td class='col-1'>" . (($balance >= 0) ? myCurrency($balance) : "") . "</td><td class='col-1'>" . (($balance < 0) ? myCurrency(abs($balance)) : "") . "</td><td class='col-1'>" . (myCurrency($balance)) . "</td><td class='text-center'><a title='Show Ledger' class='btn btn-info btn-xs ' onClick='showLedger(" . $Account->account_id . ")'><i class='fa fa-eye'></i></a></td></tr>";
endforeach;
$html .= "</tbody><tfoot>";
$html .= "<tr><th colspan=3 class='text-right'>Total</th><th class='text-right'>" . myCurrency($BalanceTotal) . "</th><th></th><th></th></tr>";
$html .= "<tr><th colspan=3 class='text-right'>Total</th><th class='text-right'>" . (($BalanceTotal > 0) ? myCurrency(abs($BalanceTotal)) : "") . "</th><th class='text-right'>" . (($BalanceTotal < 0) ? myCurrency(abs($BalanceTotal)) : "") . "</th><th class='text-right'>" . myCurrency($BalanceTotal) . "</th></tr>";
$html .= "</tfoot></table>\n";
$html .= " <div class=\"modal fade\" id=\"ledgerdetails_box\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"ledgerdetails_box\" aria-hidden=\"true\">
<div class=\"modal-dialog modal-xl\" role=\"document\">
@ -85,6 +160,116 @@
<?php function footerFunctions()
{
?>
<script>
$(document).ready(function() {
// Prevent the dropdown from closing when clicking inside
$('.dropdown-menu').on('click', function(event) {
event.stopPropagation();
});
});
</script>
<script>
// var exportButton = document.getElementById("exportButton");
// exportButton.addEventListener("click", function() {
// exportTableToCSV("table.csv");
// });
document.addEventListener("DOMContentLoaded", function() {
// Trigger click event on page load
document.getElementById("toggleShowAll").click();
});
document.getElementById("toggleShowAll").addEventListener("click", function(e) {
e.preventDefault();
var nestedRows = document.getElementsByClassName("collapse");
for (var i = 0; i < nestedRows.length; i++) {
if (nestedRows[i].classList.contains("show")) {
nestedRows[i].classList.remove("show");
} else {
nestedRows[i].classList.add("show");
}
}
});
function exportTableToCSV(filename) {
var csv = [];
var rows = document.querySelectorAll("table tr:not(.hide)");
for (var i = 0; i < rows.length; i++) {
var row = [];
var cols = rows[i].querySelectorAll("td:not(.hide), th:not(.hide)");
// Check if the parent row is collapsed or hidden
var parentRow = rows[i].closest(".collapse");
var isParentCollapsed = parentRow && (!parentRow.classList.contains("show"));
if (isParentCollapsed) {
continue; // Skip child table rows if parent is collapsed
}
for (var j = 0; j < cols.length; j++) {
var cellValue = cols[j].innerText.replace(/,/g, ""); // Remove commas from the cell value
row.push(cellValue);
}
csv.push(row.join(","));
}
// Create a CSV file
var csvContent = "data:text/csv;charset=utf-8," + csv.join("\n");
var encodedUri = encodeURI(csvContent);
var link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", filename);
document.body.appendChild(link);
link.click();
}
</script>
<script>
$("#fromDate").nepaliDatePicker({
dateFormat: "%y-%m-%d",
closeOnDateSelect: true,
minDate: $('#fromDate').data('start'),
maxDate: $('#fromDate').data('end'),
});
</script>
<script>
$("#toDate").nepaliDatePicker({
dateFormat: "%y-%m-%d",
closeOnDateSelect: true,
minDate: $('#toDate').data('start'),
maxDate: $('#toDate').data('end'),
});
</script>
<!-- pdf document -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.0/xlsx.full.min.js"></script>
<script>
document.getElementById('downloadCsv').addEventListener('click', function() {
const table = document.getElementById('myTable');
const rows = Array.from(table.rows);
const data = [];
rows.forEach((row) => {
const cells = Array.from(row.cells);
const rowData = [];
cells.forEach((cell) => {
// Handle colspan
const colspan = cell.colSpan || 1;
for (let i = 0; i < (colspan - 1); i++) {
rowData.push(''); // Fill empty cells for merged columns
}
for (let i = 0; i < 1; i++) {
rowData.push(cell.innerText.trim());
}
// Fill empty cells for colspan
});
data.push(rowData);
});
// Create a worksheet
const worksheet = XLSX.utils.aoa_to_sheet(data);
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
// Export to Excel
XLSX.writeFile(workbook, 'table.xlsx');
});
</script>
<!-- pdf document ends-->
<?php
}
?>

View File

@ -4,8 +4,88 @@
<div class="row">
<div class="col">
<div class="card card-primary card-outline ">
<div class="card-header bg-primary disabled color-palette">
<h3 class="card-title"><?php echo $pageTitle; ?> </h3>
<div class="card-header disabled color-palette">
<h3 class="card-title mt-1"><?php echo $pageTitle; ?> </h3>
<div class="card-tools">
<form method="post" action="" id="FilterForm">
<!-- button with a dropdown -->
<div class="btn-group">
<button type="button" class="btn btn-success btn-sm dropdown-toggle" data-toggle="dropdown" data-offset="-52">
Filters
</button>
<div class="dropdown-menu" role="menu">
<div class="form-group p-2 pb-0">
<div class="col">
<div class="form-group">
<label for="fromDate"><?php myLang("Starting Period"); ?></label>
<input type="text" class="form-control " name="fromDate" value="<?php echo (isset($_POST['fromDate'])) ? $_POST['fromDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_from); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="fromDate" aria-describedby="helpId_fromDate" placeholder="Starting Period">
</div>
<div class="form-group">
<label for="toDate"><?php myLang("Ending Period"); ?></label>
<input type="text" class="form-control " name="toDate" value="<?php echo (isset($_POST['toDate'])) ? $_POST['toDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_to); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="toDate" aria-describedby="helpId_toDate" placeholder="Ending Period">
</div>
</div>
<div class="dropdown-divider"></div>
<!-- <div class="form-check">
<input class="form-check-input" type="checkbox">
<label class="form-check-label">Select
All</label>
</div> -->
<div class="form-check">
<!-- <input type="hidden" name="showOB" value="not"> -->
<input type="checkbox" class="form-check-input " name="showOB" id="showOB" aria-describedby="helpId_showOB" placeholder="Show Opening Balance" <?php echo (isset($_POST['showOB'])) ? "CHECKED" : ""; ?>>
<!-- <input class="form-check-input" type="checkbox"> -->
<label class="form-check-label" for="showOB">Opening</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox"> -->
<input type="checkbox" class="form-check-input " name="showClosing" id="showClosing" aria-describedby="helpId_showClosing" placeholder="Show Closing Balance" <?php echo (isset($_POST['showClosing'])) ? "CHECKED" : ""; ?>>
<label class="form-check-label" for="showClosing">Closing</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox" checked> -->
<input type="checkbox" class="form-check-input" name="showPeriod" id="showPeriod" aria-describedby="helpId_showPeriod" placeholder="Show Periodic Balance" <?php echo (isset($_POST['showPeriod'])) ? "CHECKED" : "CHECKED"; ?>>
<label class="form-check-label" for="showPeriod">Period</label>
</div>
</div>
<div class="dropdown-divider"></div>
<div class="form-group p-2 pb-0 text-right">
<button type="button" class="btn btn-info btn-sm " style="width:60px;height:30px;" onclick="resetForm()">Reset</button>
<button type="submit" class="btn btn-primary mr-2 btn-sm" style="width:60px;height:30px;">Search </button>
</div>
</div>
</div>
<div class="btn-group">
<button type="submit" id="downloadCsv" class="btn btn-warning btn-sm ">
Export csv
</button>
<!-- <button id="exportButton">Export to Excel</button> -->
<!-- <button class="btn btn-warning btn-sm " id="downloadBtn">Download CSV</button> -->
<!-- <button type="submit" class="btn btn-warning btn-sm " data-toggle="dropdown" data-offset="-52">
Export
</button> -->
<!-- <div class="dropdown-menu" role="menu">
<a href="#" class="dropdown-item">Export</a>
<a href="#" class="dropdown-item">Pdf</a>
<div class="dropdown-divider"></div>
<a href="#" class="dropdown-item">View calendar</a>
</div> -->
</div>
<button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle Collapse</button>
</form>
<script>
function resetForm() {
document.getElementById("fromDate").value = "<?php echo NepaliDate($this->session->FiscalYear->fiscalyear_from); ?>";
document.getElementById("toDate").value = "<?php echo NepaliDate($this->session->FiscalYear->fiscalyear_to); ?>";
document.getElementById("showOB").checked = <?php echo "false"; ?>;
document.getElementById("showClosing").checked = <?php echo "false"; ?>;
document.getElementById("FilterForm").submit();
}
</script>
</div>
</div>
<div class="card-body">
<div class="row">
@ -18,7 +98,7 @@
$CI = &get_instance();
// $CI->db->where("status", 1)->where("(accategory_id = 2 OR accategory_id = 3)");
$CI->db->where("status", 1)->where("accategory_id = 3");
$CI->db->where("status", 1)->where("accategory_id = 3")->where("created_on >= '$fiscalStart'")->where("created_on >= '$fiscalEnd'");
$CI->db->order_by("account_name ASC");
$Accounts = $CI->db->get("tbl_accounts")->result();
@ -34,9 +114,9 @@
<?php
$html = "";
$html .= "<table class='table table-bordered table-striped longdataTable'>";
$html .= "<table id='myTable' class='table table-bordered table-striped longdataTable'>";
$html .= "<thead>";
$html .= "<tr><th class='text-center'>Sn</th><th class='text-center'>Account</th><th class='text-center'>Account Group</th><th class='text-center'>Dr</th><th class='text-center'>Cr</th><th class='text-center'>Action</th></tr>";
$html .= "<tr><th class='text-center' width='25'>Sn</th><th class='text-center'>Account</th><th class='text-center'>Account Group</th><th class='text-center'>Dr</th><th class='text-center'>Cr</th><th class='text-center'>Balance</th><th class='text-center col-1'>Action</th></tr>";
$html .= "</thead><tbody>";
$sn = 0;
$BalanceTotal = 0;
@ -44,10 +124,10 @@
$balance = getBalance($Account->account_id);
$BalanceTotal += $balance;
// pre($Account);
$html .= "<tr><td class='col-1 text-center'>" . $sn . "</td><td><a href='#' onClick='showLedger(" . $Account->account_id . ")'>" . $Account->account_name . "</a></td><td class='col-2'>" . $Account->Category->accategory_name . "</td><td class='col-1'>" . (($balance >= 0) ? myCurrency($balance) : "") . "</td><td class='col-1'>" . (($balance < 0) ? myCurrency(abs($balance)) : "") . "</td><td class='col-2 text-center'><a title='Show Ledger' class='btn btn-info btn-xs ' onClick='showLedger(" . $Account->account_id . ")'><i class='fa fa-eye'></i></a></td></tr>";
$html .= "<tr><td class='col-1 text-center'>" . $sn . "</td><td><a href='#' onClick='showLedger(" . $Account->account_id . ")'>" . $Account->account_name . "</a></td><td class='col-2'>" . $Account->Category->accategory_name . "</td><td class='col-1'>" . (($balance >= 0) ? myCurrency($balance) : "") . "</td><td class='col-1'>" . (($balance < 0) ? myCurrency(abs($balance)) : "") . "</td><td class='col-1'>" . (myCurrency($balance)) . "</td><td class=' text-center'><a title='Show Ledger' class='btn btn-info btn-xs ' onClick='showLedger(" . $Account->account_id . ")'><i class='fa fa-eye'></i></a></td></tr>";
endforeach;
$html .= "</tbody><tfoot>";
$html .= "<tr><th colspan=3 class='text-right'>Total</th><th class='text-right'>" . myCurrency($BalanceTotal) . "</th><th></th><th></th></tr>";
$html .= "<tr><th colspan=3 class='text-right'>Total</th><th class='text-right'>" . (($BalanceTotal > 0) ? myCurrency(abs($BalanceTotal)) : "") . "</th><th class='text-right'>" . (($BalanceTotal < 0) ? myCurrency(abs($BalanceTotal)) : "") . "</th><th class='text-right'>" . myCurrency($BalanceTotal) . "</th><th></th></tr>";
$html .= "</tfoot></table>\n";
$html .= " <div class=\"modal fade\" id=\"ledgerdetails_box\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"ledgerdetails_box\" aria-hidden=\"true\">
<div class=\"modal-dialog modal-xl\" role=\"document\">
@ -86,6 +166,117 @@
<?php function footerFunctions()
{
?>
<script>
$(document).ready(function() {
// Prevent the dropdown from closing when clicking inside
$('.dropdown-menu').on('click', function(event) {
event.stopPropagation();
});
});
</script>
<script>
// var exportButton = document.getElementById("exportButton");
// exportButton.addEventListener("click", function() {
// exportTableToCSV("table.csv");
// });
document.addEventListener("DOMContentLoaded", function() {
// Trigger click event on page load
document.getElementById("toggleShowAll").click();
});
document.getElementById("toggleShowAll").addEventListener("click", function(e) {
e.preventDefault();
var nestedRows = document.getElementsByClassName("collapse");
for (var i = 0; i < nestedRows.length; i++) {
if (nestedRows[i].classList.contains("show")) {
nestedRows[i].classList.remove("show");
} else {
nestedRows[i].classList.add("show");
}
}
});
function exportTableToCSV(filename) {
var csv = [];
var rows = document.querySelectorAll("table tr:not(.hide)");
for (var i = 0; i < rows.length; i++) {
var row = [];
var cols = rows[i].querySelectorAll("td:not(.hide), th:not(.hide)");
// Check if the parent row is collapsed or hidden
var parentRow = rows[i].closest(".collapse");
var isParentCollapsed = parentRow && (!parentRow.classList.contains("show"));
if (isParentCollapsed) {
continue; // Skip child table rows if parent is collapsed
}
for (var j = 0; j < cols.length; j++) {
var cellValue = cols[j].innerText.replace(/,/g, ""); // Remove commas from the cell value
row.push(cellValue);
}
csv.push(row.join(","));
}
// Create a CSV file
var csvContent = "data:text/csv;charset=utf-8," + csv.join("\n");
var encodedUri = encodeURI(csvContent);
var link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", filename);
document.body.appendChild(link);
link.click();
}
</script>
<script>
$("#fromDate").nepaliDatePicker({
dateFormat: "%y-%m-%d",
closeOnDateSelect: true,
minDate: $('#fromDate').data('start'),
maxDate: $('#fromDate').data('end'),
});
</script>
<script>
$("#toDate").nepaliDatePicker({
dateFormat: "%y-%m-%d",
closeOnDateSelect: true,
minDate: $('#toDate').data('start'),
maxDate: $('#toDate').data('end'),
});
</script>
<!-- pdf document -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.0/xlsx.full.min.js"></script>
<script>
document.getElementById('downloadCsv').addEventListener('click', function() {
const table = document.getElementById('myTable');
const rows = Array.from(table.rows);
const data = [];
rows.forEach((row) => {
const cells = Array.from(row.cells);
const rowData = [];
cells.forEach((cell) => {
// Handle colspan
const colspan = cell.colSpan || 1;
for (let i = 0; i < (colspan - 1); i++) {
rowData.push(''); // Fill empty cells for merged columns
}
for (let i = 0; i < 1; i++) {
rowData.push(cell.innerText.trim());
}
// Fill empty cells for colspan
});
data.push(rowData);
});
// Create a worksheet
const worksheet = XLSX.utils.aoa_to_sheet(data);
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
// Export to Excel
XLSX.writeFile(workbook, 'table.xlsx');
});
</script>
<!-- pdf document ends-->
<?php
}
?>

View File

@ -6,7 +6,7 @@
<div class="col">
<div class="card card-primary card-outline ">
<div class="card-header bg-primary disabled color-palette">
<div class="card-header disabled color-palette">
<h5 class="m-0"><?php echo $pageTitle; ?> </h5>
</div>

View File

@ -1,15 +1,12 @@
<div class="content-wrapper">
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col">
<div class="card card-primary card-outline ">
<div class="card-header bg-primary disabled color-palette">
<div class="card-header disabled color-palette">
<h5 class="m-0"><?php echo $pageTitle; ?></h5>
</div>
<div class="card-body">
<div class="row">
<div class="col">
@ -18,23 +15,18 @@
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php function footerFunctions()
{
?>
<?php
}
?>

View File

@ -4,7 +4,7 @@
<div class="row">
<div class="col">
<div class="card card-primary card-outline ">
<div class="card-header bg-primary disabled color-palette">
<div class="card-header disabled color-palette">
<h3 class="card-title"><?php echo $pageTitle; ?> </h3>
</div>
<div class="card-body">

View File

@ -0,0 +1,430 @@
<?php
$this->load->library("BIBAccounts");
$BIBAccounts = new BIBAccounts();
?>
<!-- Include jQuery -->
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<!-- Include jQuery UI -->
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<style>
table,
td,
tr {
padding: 0px;
margin: 0px;
}
.group-name {
width: 40%;
}
.group-total {
width: 10%;
}
.table-gray {
background-color: #eee;
}
.table td,
.table th {
padding: 0px;
margin: 0px;
}
.bg-darker {
background-color: #ddd;
}
td .table {
border: 0px !important;
margin-bottom: 0rem;
}
table td:first-child {
padding-left: 5px;
}
.table-bordered.vertical-borders td,
.table-bordered.vertical-borders th {
border-left: 1px solid #dee2e6;
border-right: 1px solid #dee2e6;
}
.table-bordered.vertical-borders thead th {
padding: 0.25rem;
border-top: none;
border-bottom: 2px solid #dee2e6;
}
.table-bordered.vertical-borders tfoot th {
padding: 0.25rem;
border-top: 2px solid #dee2e6;
border-bottom: none;
}
.currency {
font-weight: normal !important;
}
.underline {
text-decoration: underline;
}
.form-control {
display: block;
width: 100%;
height: calc(1.5rem + 1px);
padding: 0.375rem 0.75rem;
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #495057;
background-color: #fff;
background-clip: padding-box;
border: 1px solid #ced4da;
border-radius: 0.25rem;
box-shadow: inset 0 0 0 transparent;
transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}
</style>
<div class="content-wrapper">
<div class="content">
<div class="container-fluid">
<div class="card card-primary card-outline ">
<div class="card-header">
<h2 class="card-title mt-1"><?php echo $pageTitle; ?> <?php //myLang("Report");
?></h2>
<div class="card-tools">
<form method="post" action="" id="FilterForm">
<!-- button with a dropdown -->
<div class="btn-group">
<button type="button" class="btn btn-success btn-sm dropdown-toggle" data-toggle="dropdown" data-offset="-52">
Filters
</button>
<div class="dropdown-menu" role="menu">
<div class="form-group p-2 pb-0">
<div class="col">
<div class="form-group">
<label for="fromDate"><?php myLang("Starting Period"); ?></label>
<input type="text" class="form-control " name="fromDate" value="<?php echo (isset($_POST['fromDate'])) ? $_POST['fromDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_from); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="fromDate" aria-describedby="helpId_fromDate" placeholder="Starting Period">
</div>
<div class="form-group">
<label for="toDate"><?php myLang("Ending Period"); ?></label>
<input type="text" class="form-control " name="toDate" value="<?php echo (isset($_POST['toDate'])) ? $_POST['toDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_to); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="toDate" aria-describedby="helpId_toDate" placeholder="Ending Period">
</div>
</div>
<div class="dropdown-divider"></div>
<!-- <div class="form-check">
<input class="form-check-input" type="checkbox">
<label class="form-check-label">Select
All</label>
</div> -->
<div class="form-check">
<!-- <input type="hidden" name="showOB" value="not"> -->
<input type="checkbox" class="form-check-input " name="showOB" id="showOB" aria-describedby="helpId_showOB" placeholder="Show Opening Balance" <?php echo (isset($_POST['showOB'])) ? "CHECKED" : ""; ?>>
<!-- <input class="form-check-input" type="checkbox"> -->
<label class="form-check-label" for="showOB">Opening</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox"> -->
<input type="checkbox" class="form-check-input " name="showClosing" id="showClosing" aria-describedby="helpId_showClosing" placeholder="Show Closing Balance" <?php echo (isset($_POST['showClosing'])) ? "CHECKED" : ""; ?>>
<label class="form-check-label" for="showClosing">Closing</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox" checked> -->
<input type="checkbox" class="form-check-input" name="showPeriod" id="showPeriod" aria-describedby="helpId_showPeriod" placeholder="Show Periodic Balance" <?php echo (isset($_POST['showPeriod'])) ? "CHECKED" : "CHECKED"; ?>>
<label class="form-check-label" for="showPeriod">Period</label>
</div>
</div>
<div class="dropdown-divider"></div>
<div class="form-group p-2 pb-0 text-right">
<button type="button" class="btn btn-info btn-sm " style="width:60px;height:30px;" onclick="resetForm()">Reset</button>
<button type="submit" class="btn btn-primary mr-2 btn-sm" style="width:60px;height:30px;">Search </button>
</div>
</div>
</div>
<div class="btn-group">
<button type="submit" class="btn btn-warning btn-sm " data-toggle="dropdown" data-offset="-52">
Export
</button>
<!-- <div class="dropdown-menu" role="menu">
<a href="#" class="dropdown-item">Export</a>
<a href="#" class="dropdown-item">Pdf</a>
<div class="dropdown-divider"></div>
<a href="#" class="dropdown-item">View calendar</a>
</div> -->
</div>
<button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle Collapse</button>
</form>
<script>
function resetForm() {
document.getElementById("fromDate").value = "<?php echo NepaliDate($this->session->FiscalYear->fiscalyear_from); ?>";
document.getElementById("toDate").value = "<?php echo NepaliDate($this->session->FiscalYear->fiscalyear_to); ?>";
document.getElementById("showOB").checked = <?php echo "false"; ?>;
document.getElementById("showClosing").checked = <?php echo "false"; ?>;
document.getElementById("FilterForm").submit();
}
</script>
</div>
</div>
</div>
</div>
</div>
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col">
<!-- <button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle Collapse</button> -->
<div class="card card-primary card-outline ">
<div class="card-body p-0">
<?php
// echo $_POST['showClosing'];
$ReportOptions = array(
'showZeroBalances' => false,
'showOB' => false,
'showClosing' => true,
'showPeriod' => false,
);
// die;
?>
<table class="table table-bordered">
<thead>
<tr>
<th class="group-name" width="85%">Particulars</th>
<th class="group-total text-center" width="10%">Amount</th>
<th class="group-name" width="85%">Particulars</th>
<th class="group-total text-center" width="15%">Amount</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2" class="p-0">
<?php $AccountGroups = $BIBAccounts->getAccountGroupsWithBalances(3); ?>
<table class="table table-bordered vertical-borders" id="TrialBalanceTable">
<?php
// Initialize variables for column totals
$incomes_totalOpeningDr = 0;
$incomes_totalOpeningCr = 0;
$incomes_totalThisYearDr = 0;
$incomes_totalThisYearCr = 0;
$incomes_totalClosingDr = 0;
$incomes_totalClosingCr = 0;
?>
<?php foreach ($AccountGroups as $group) : ?>
<tr class="group-heading" data-toggle="collapse" data-target="#group_<?php echo $group->acgroup_id; ?>">
<td class="group-name"><b><?php //echo $group->acgroup_name;
?></b></td>
<td class="group-total text-right"><?php //echo myCurrency(($group->posting_side == "CR") ? $group->closing_balance : 0);
?></td>
</tr>
<tr>
<td colspan="7" class="group-details p-0" width="85%">
<div id="group_<?php echo $group->acgroup_id; ?>" class="">
<?php $Accountcategories = $BIBAccounts->getRootCategoriesWithBalances($group->acgroup_id); ?>
<?php $BIBAccounts->renderAccountCategoriesTable($Accountcategories, $ReportOptions, false, array()); ?>
</div>
</td>
</tr>
<?php
// Update column totals
$incomes_totalOpeningDr += ($group->posting_side == "DR") ? $group->opening_balance : 0;
$incomes_totalOpeningCr += ($group->posting_side == "CR") ? $group->opening_balance : 0;
$incomes_totalThisYearDr += ($group->posting_side == "DR") ? $group->regular_balance : 0;
$incomes_totalThisYearCr += ($group->posting_side == "CR") ? $group->regular_balance : 0;
$incomes_totalClosingDr += ($group->posting_side == "DR") ? $group->closing_balance : 0;
$incomes_totalClosingCr += ($group->posting_side == "CR") ? $group->closing_balance : 0;
?>
<?php endforeach; ?>
</table>
</td>
<td colspan="2" class="p-0">
<?php $AccountGroups = $BIBAccounts->getAccountGroupsWithBalances(4); ?>
<table class="table table-bordered vertical-borders" id="TrialBalanceTable">
<?php
// Initialize variables for column totals
$totalOpeningDr = 0;
$totalOpeningCr = 0;
$totalThisYearDr = 0;
$totalThisYearCr = 0;
$totalClosingDr = 0;
$totalClosingCr = 0;
?>
<?php foreach ($AccountGroups as $group) : ?>
<tr class="group-heading" data-toggle="collapse" data-target="#group_<?php echo $group->acgroup_id; ?>">
<td class="group-name" width="85%"> <?php //echo $group->acgroup_name;
?></td>
<td class="group-total" width="15%"><?php //echo myCurrency(($group->posting_side == "DR") ? $group->closing_balance : 0);
?></td>
</tr>
<tr>
<td colspan="7" class="group-details p-0">
<div id="group_<?php echo $group->acgroup_id; ?>" class="">
<i> <?php $Accountcategories = $BIBAccounts->getRootCategoriesWithBalances($group->acgroup_id); ?>
<?php $BIBAccounts->renderAccountCategoriesTable($Accountcategories, $ReportOptions, false, array()); ?>
</i>
</div>
</td>
</tr>
<?php
// Update column totals
$totalOpeningDr += ($group->posting_side == "DR") ? $group->opening_balance : 0;
$totalOpeningCr += ($group->posting_side == "CR") ? $group->opening_balance : 0;
$totalThisYearDr += ($group->posting_side == "DR") ? $group->regular_balance : 0;
$totalThisYearCr += ($group->posting_side == "CR") ? $group->regular_balance : 0;
$totalClosingDr += ($group->posting_side == "DR") ? $group->closing_balance : 0;
$totalClosingCr += ($group->posting_side == "CR") ? $group->closing_balance : 0;
?>
<?php endforeach; ?>
</table>
</td>
</tr>
<?php $PL = $incomes_totalClosingCr - $totalClosingDr; ?>
<?php if ($incomes_totalClosingCr > $totalClosingDr) : ?>
<tr>
<td colspan="2" width="15%">
</td>
<td colspan="2" class="p-0">
<table class="table table-bordered">
<tr>
<th>Total Profit</th>
<th class="cr closing-cr text-right"><?php echo myCurrency($PL); ?></th>
</tr>
</table>
</td>
</tr>
<?php else : ?>
<tr>
<td colspan="2" class="p-0">
<table class="table table-bordered">
<tr>
<th>Total Loss</th>
<th class="cr closing-cr"><?php echo myCurrency(abs($PL)); ?></th>
</tr>
</table>
</td>
<td colspan="2">
</td>
</tr>
<?php endif; ?>
<tr>
<td colspan="2" class="p-0">
<table class="table table-bordered">
<tr>
<th>Total Incomes</th>
<th class="cr closing-cr">
<?php if ($PL > 0) : ?>
<?php echo myCurrency($incomes_totalClosingCr); ?>
<?php else : ?>
<?php echo myCurrency($incomes_totalClosingCr + abs($PL)); ?>
<?php endif; ?>
</th>
</tr>
</table>
</td>
<td colspan="2" class="p-0">
<table class="table table-bordered">
<tr>
<th>Total Expenses</th>
<th class="dr closing-dr">
<?php if ($PL > 0) : ?>
<?php echo myCurrency($totalClosingDr + abs($PL)); ?>
<?php else : ?>
<?php echo myCurrency($totalClosingDr); ?>
<?php endif; ?>
</th>
</tr>
</table>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
function footerfunctions()
{
?>
<script>
$(document).ready(function() {
// Prevent the dropdown from closing when clicking inside
$('.dropdown-menu').on('click', function(event) {
event.stopPropagation();
});
});
</script>
<script>
document.addEventListener("DOMContentLoaded", function() {
// Trigger click event on page load
document.getElementById("toggleShowAll").click();
});
document.getElementById("toggleShowAll").addEventListener("click", function(e) {
e.preventDefault();
var nestedRows = document.getElementsByClassName("collapse");
for (var i = 0; i < nestedRows.length; i++) {
if (nestedRows[i].classList.contains("show")) {
nestedRows[i].classList.remove("show");
} else {
nestedRows[i].classList.add("show");
}
}
});
var exportButton = document.getElementById("exportButton");
exportButton.addEventListener("click", function() {
exportTableToCSV("table.csv");
});
function exportTableToCSV(filename) {
var csv = [];
var rows = document.querySelectorAll("table tr:not(.hide)");
for (var i = 0; i < rows.length; i++) {
var row = [];
var cols = rows[i].querySelectorAll("td:not(.hide), th:not(.hide)");
// Check if the parent row is collapsed or hidden
var parentRow = rows[i].closest(".collapse");
var isParentCollapsed = parentRow && (!parentRow.classList.contains("show"));
if (isParentCollapsed) {
continue; // Skip child table rows if parent is collapsed
}
for (var j = 0; j < cols.length; j++) {
var cellValue = cols[j].innerText.replace(/,/g, ""); // Remove commas from the cell value
row.push(cellValue);
}
csv.push(row.join(","));
}
// Create a CSV file
var csvContent = "data:text/csv;charset=utf-8," + csv.join("\n");
var encodedUri = encodeURI(csvContent);
var link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", filename);
document.body.appendChild(link);
link.click();
}
</script>
<script>
$("#fromDate").nepaliDatePicker({
dateFormat: "%y-%m-%d",
closeOnDateSelect: true,
minDate: $('#fromDate').data('start'),
maxDate: $('#fromDate').data('end'),
});
</script>
<script>
$("#toDate").nepaliDatePicker({
dateFormat: "%y-%m-%d",
closeOnDateSelect: true,
minDate: $('#toDate').data('start'),
maxDate: $('#toDate').data('end'),
});
</script>
<?php
}
?>

View File

@ -17,7 +17,7 @@ $PL = $IncomesTotal - $ExpensesTotal;
<h5 class="m-0"><?php echo $pageTitle; ?> </h5>
</div>
<div class="card-body">
<table class="table table-bordered table-hover">
<table id='myTable'class="table table-bordered table-hover">
<thead>
<tr>
<th colspan="4">Profit & Loss Statement</th>
@ -95,7 +95,7 @@ $PL = $IncomesTotal - $ExpensesTotal;
{
$total = 0;
?>
<table class="table table-bordered table-hover">
<table id='myTable' class="table table-bordered table-hover">
<thead>
<tr>
<th>Account</th>
@ -121,6 +121,41 @@ $PL = $IncomesTotal - $ExpensesTotal;
</tr>
</tfoot> -->
</table>
<!-- pdf document -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.0/xlsx.full.min.js"></script>
<script>
document.getElementById('downloadCsv').addEventListener('click', function() {
const table = document.getElementById('myTable');
const rows = Array.from(table.rows);
const data = [];
rows.forEach((row) => {
const cells = Array.from(row.cells);
const rowData = [];
cells.forEach((cell) => {
// Handle colspan
const colspan = cell.colSpan || 1;
for (let i = 0; i < (colspan - 1); i++) {
rowData.push(''); // Fill empty cells for merged columns
}
for (let i = 0; i < 1; i++) {
rowData.push(cell.innerText.trim());
}
// Fill empty cells for colspan
});
data.push(rowData);
});
// Create a worksheet
const worksheet = XLSX.utils.aoa_to_sheet(data);
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
// Export to Excel
XLSX.writeFile(workbook, 'table.xlsx');
});
</script>
<!-- pdf document ends-->
<?php
}

View File

@ -4,7 +4,6 @@ $BIBAccounts = new BIBAccounts();
?>
<!-- Include jQuery -->
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<!-- Include jQuery UI -->
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
@ -89,76 +88,102 @@ $BIBAccounts = new BIBAccounts();
box-shadow: inset 0 0 0 transparent;
transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}
.table1 {
border: 0px !important;
padding: 0;
margin: 10 !important;
width: 100%;
vertical-align: middle;
}
.table-responsive {
overflow-x: auto;
}
.card-body {
-webkit-flex: 1 1 auto;
-ms-flex: 1 1 auto;
flex: 1 1 auto;
min-height: 1px;
padding: 0;
}
table {
border: 1px solid #ddd;
border-collapse: collapse;
}
.text-bold {
font-weight: 900;
}
</style>
<div class="content-wrapper">
<div class="content">
<div class="container-fluid">
<div class="card card-primary card-outline ">
<div class="card-header">
<h2 class="card-title"><?php echo $pageTitle; ?> <?php myLang("Report"); ?></h2>
<h2 class="card-title mt-1"><?php echo $pageTitle; ?> <?php //myLang("Report");
?></h2>
<div class="card-tools">
<form method="post" action="" id="FilterForm">
<form method="post" action="<?php echo base_url('accounts/reports/pl'); ?>" id="FilterForm">
<!-- button with a dropdown -->
<div class="btn-group">
<button type="button" class="btn btn-success btn-sm dropdown-toggle" data-toggle="dropdown" data-offset="-52">
Filters
</button>
<div class="dropdown-menu" role="menu">
<div class="form-group p-2 pb-0">
<div class="col">
<div class="form-group">
<label for="fromDate"><?php myLang("Starting Period"); ?></label>
<input type="text" class="form-control " name="fromDate" value="<?php echo (isset($_POST['fromDate'])) ? $_POST['fromDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_from); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="fromDate" aria-describedby="helpId_fromDate" placeholder="Starting Period">
</div>
<div class="form-group">
<label for="toDate"><?php myLang("Ending Period"); ?></label>
<input type="text" class="form-control " name="toDate" value="<?php echo (isset($_POST['toDate'])) ? $_POST['toDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_to); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="toDate" aria-describedby="helpId_toDate" placeholder="Ending Period">
</div>
</div>
<div class="dropdown-divider"></div>
<div class="form-check">
<!-- <div class="form-check">
<input class="form-check-input" type="checkbox">
<label class="form-check-label">Select
All</label>
</div>
</div> -->
<div class="form-check">
<input type="hidden" name="showOB" value="not">
<!-- <input type="hidden" name="showOB" value="not"> -->
<input type="checkbox" class="form-check-input " name="showOB" id="showOB" aria-describedby="helpId_showOB" placeholder="Show Opening Balance" <?php echo (isset($_POST['showOB'])) ? "CHECKED" : ""; ?>>
<!-- <input class="form-check-input" type="checkbox"> -->
<label class="form-check-label">Opening</label>
<label class="form-check-label" for="showOB">Opening</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox"> -->
<input type="checkbox" class="form-check-input " name="showClosing" id="showClosing" aria-describedby="helpId_showClosing" placeholder="Show Closing Balance" <?php echo (isset($_POST['showClosing'])) ? "CHECKED" : ""; ?>>
<label class="form-check-label">Closing</label>
<label class="form-check-label" for="showClosing">Closing</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox" checked> -->
<input type="checkbox" class="form-check-input" name="showPeriod" id="showPeriod" aria-describedby="helpId_showPeriod" placeholder="Show Periodic Balance" <?php echo (isset($_POST['showPeriod'])) ? "CHECKED" : "CHECKED"; ?>>
<label class="form-check-label">Period</label>
<label class="form-check-label" for="showPeriod">Period</label>
</div>
</div>
<div class="dropdown-divider"></div>
<button type="submit" class="btn btn-primary mr-2 text-center">Search Now</button>
<div class="form-group p-2 pb-0 text-right">
<button type="button" class="btn btn-info btn-sm " style="width:60px;height:30px;" onclick="resetForm()">Reset</button>
<button type="submit" class="btn btn-primary mr-2 btn-sm" style="width:60px;height:30px;">Search </button>
</div>
</div>
</div>
<div class="btn-group">
<button type="submit" class="btn btn-danger btn-sm " data-toggle="dropdown" data-offset="-52">
<!-- <button type="submit" class="btn btn-warning btn-sm " data-toggle="dropdown" data-offset="-52">
Export
</button> -->
<!-- <button type="submit" onclick="exportTableToCSV('accounts_data.csv')" class="btn btn-warning btn-sm " data-toggle="dropdown" data-offset="-52">
Export
</button> -->
<button type="submit" id="downloadCsv" class="btn btn-warning btn-sm ">
Export csv
</button>
<!-- <div class="dropdown-menu" role="menu">
<a href="#" class="dropdown-item">Export</a>
<a href="#" class="dropdown-item">Pdf</a>
@ -166,10 +191,8 @@ $BIBAccounts = new BIBAccounts();
<a href="#" class="dropdown-item">View calendar</a>
</div> -->
</div>
<button type="button" class="btn btn-warning btn-sm" onclick="resetForm()">Reset</button>
<!-- <button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle Collapse</button> -->
<button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle Collapse</button>
</form>
<script>
function resetForm() {
@ -180,23 +203,21 @@ $BIBAccounts = new BIBAccounts();
document.getElementById("FilterForm").submit();
}
</script>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col">
<button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle Collapse</button>
<!-- <button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle Collapse</button> -->
<div class="card card-primary card-outline">
<div class="card-body p-0">
<div class="card-body pl-2 pr-2">
<div class="row">
<?php
// echo $_POST['showClosing'];
$ReportOptions = array(
'showZeroBalances' => false,
@ -206,25 +227,17 @@ $BIBAccounts = new BIBAccounts();
);
// die;
?>
<table class="table table-bordered">
<div class="col-6 p-0">
<div class="table-responsive">
<table id='myTable' class="table">
<thead>
<tr>
<th class="group-name" width="85%">Particulars</th>
<th class="group-total text-center" width="10%">Amount</th>
<th class="group-name" width="85%">Particulars</th>
<th class="group-total text-center" width="15%">Amount</th>
<th class="group-name pl-1">Particulars</th>
<th class="group-total text-center col-1">Amount</th>
</tr>
</thead>
<tbody>
<tr>
<td colspan="2" class="p-0">
<?php $AccountGroups = $BIBAccounts->getAccountGroupsWithBalances(3); ?>
<table class="table table-bordered vertical-borders" id="TrialBalanceTable">
<?php $AccountGroups = $BIBAccounts->getAccountGroupsWithBalancesNew(3, $fiscalStart, $fiscalEnd); ?>
<?php
// Initialize variables for column totals
$incomes_totalOpeningDr = 0;
@ -235,21 +248,14 @@ $BIBAccounts = new BIBAccounts();
$incomes_totalClosingCr = 0;
?>
<?php foreach ($AccountGroups as $group) : ?>
<tr class="group-heading" data-toggle="collapse" data-target="#group_<?php echo $group->acgroup_id; ?>">
<td class="group-name"><b><?php //echo $group->acgroup_name;
?></b></td>
<td class="group-total text-right"><?php //echo myCurrency(($group->posting_side == "CR") ? $group->closing_balance : 0);
?></td>
</tr>
<tr>
<td colspan="7" class="group-details p-0" width="85%">
<div id="group_<?php echo $group->acgroup_id; ?>" class="collapse">
<td colspan="2" class="p-0">
<div id="group_<?php echo $group->acgroup_id; ?>" class="">
<?php $Accountcategories = $BIBAccounts->getRootCategoriesWithBalances($group->acgroup_id); ?>
<?php $BIBAccounts->renderAccountCategoriesTable($Accountcategories, $ReportOptions, false, array()); ?>
</div>
</td>
</tr>
<?php
// Update column totals
@ -260,14 +266,41 @@ $BIBAccounts = new BIBAccounts();
$incomes_totalClosingDr += ($group->posting_side == "DR") ? $group->closing_balance : 0;
$incomes_totalClosingCr += ($group->posting_side == "CR") ? $group->closing_balance : 0;
?>
<?php endforeach; ?>
</tbody>
<tfoot>
<?php $PL = $incomes_totalClosingCr - $incomes_totalClosingDr; ?>
<tr>
<td class="p-1">Total Incomes</th>
<td class="cr closing-cr text-bold">
<?php if ($PL > 0) : ?>
<?php echo myCurrency($incomes_totalClosingCr); ?>
<?php else : ?>
<?php echo myCurrency($incomes_totalClosingCr + abs($PL)); ?>
<?php endif; ?>
</tr>
</tfoot>
</table>
</td>
<td colspan="2" class="p-0">
<?php $AccountGroups = $BIBAccounts->getAccountGroupsWithBalances(4); ?>
<table class="table table-bordered vertical-borders" id="TrialBalanceTable">
</div>
</div>
<div class="col-6 p-0">
<div class="table-responsive">
<table class="table">
<thead>
<tr>
<th class="group-name pl-1">Particulars</th>
<th class="group-total text-center col-1">Amount</th>
</tr>
</thead>
<tbody>
<?php $AccountGroups = $BIBAccounts->getAccountGroupsWithBalancesNew(4, $fiscalStart, $fiscalEnd); ?>
<?php
// Initialize variables for column totals
$totalOpeningDr = 0;
@ -278,15 +311,9 @@ $BIBAccounts = new BIBAccounts();
$totalClosingCr = 0;
?>
<?php foreach ($AccountGroups as $group) : ?>
<tr class="group-heading" data-toggle="collapse" data-target="#group_<?php echo $group->acgroup_id; ?>">
<td class="group-name" width="85%"> <?php //echo $group->acgroup_name;
?></td>
<td class="group-total" width="15%"><?php //echo myCurrency(($group->posting_side == "DR") ? $group->closing_balance : 0);
?></td>
</tr>
<tr>
<td colspan="7" class="group-details p-0">
<div id="group_<?php echo $group->acgroup_id; ?>" class="collapse">
<td colspan="2" class="p-0">
<div id="group_<?php echo $group->acgroup_id; ?>" class="">
<i> <?php $Accountcategories = $BIBAccounts->getRootCategoriesWithBalances($group->acgroup_id); ?>
<?php $BIBAccounts->renderAccountCategoriesTable($Accountcategories, $ReportOptions, false, array()); ?>
</i>
@ -303,88 +330,37 @@ $BIBAccounts = new BIBAccounts();
$totalClosingCr += ($group->posting_side == "CR") ? $group->closing_balance : 0;
?>
<?php endforeach; ?>
</table>
</td>
</tr>
<?php $PL = $incomes_totalClosingCr - $totalClosingDr; ?>
<?php if ($incomes_totalClosingCr > $totalClosingDr) : ?>
<tr>
<td colspan="2" width="15%">
<!-- <th></th>
<th></th> -->
<th class="pl-1">Total Profit</th>
<th class="cr closing-cr text-right text-bold"><?php echo myCurrency($PL); ?></th>
</tr>
</td>
<td colspan="2" class="p-0">
<table class="table table-bordered">
<tr>
<th>Total Profit</th>
<th class="cr closing-cr text-right"><?php echo myCurrency($PL); ?></th>
</tr>
</table>
</td>
</tr>
<?php else : ?>
<tr>
<td colspan="2" class="p-0">
<table class="table table-bordered">
<tr>
<th>Total Loss</th>
<th class="cr closing-cr"><?php echo myCurrency(abs($PL)); ?></th>
</tr>
</table>
</td>
<td colspan="2">
</td>
</tr>
<?php endif; ?>
<tr>
<td colspan="2" class="p-0">
<table class="table table-bordered">
<tr>
<th>Total Incomes</th>
<th class="cr closing-cr">
<?php if ($PL > 0) : ?>
<?php echo myCurrency($incomes_totalClosingCr); ?>
<?php else : ?>
<?php echo myCurrency($incomes_totalClosingCr + abs($PL)); ?>
<?php endif; ?>
</th>
</tr>
</table>
</td>
<td colspan="2" class="p-0">
<table class="table table-bordered">
<tr>
<th>Total Expenses</th>
<th class="dr closing-dr">
</tbody>
<tfoot>
<th class="pl-1">Total Expenses</th>
<th class="dr closing-dr text-bold">
<?php if ($PL > 0) : ?>
<?php echo myCurrency($totalClosingDr + abs($PL)); ?>
<?php else : ?>
<?php echo myCurrency($totalClosingDr); ?>
<?php endif; ?>
</th>
</tr>
</tfoot>
</table>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
@ -394,6 +370,14 @@ $BIBAccounts = new BIBAccounts();
function footerfunctions()
{
?>
<script>
$(document).ready(function() {
// Prevent the dropdown from closing when clicking inside
$('.dropdown-menu').on('click', function(event) {
event.stopPropagation();
});
});
</script>
<script>
document.addEventListener("DOMContentLoaded", function() {
// Trigger click event on page load
@ -418,27 +402,21 @@ function footerfunctions()
function exportTableToCSV(filename) {
var csv = [];
var rows = document.querySelectorAll("table tr:not(.hide)");
for (var i = 0; i < rows.length; i++) {
var row = [];
var cols = rows[i].querySelectorAll("td:not(.hide), th:not(.hide)");
// Check if the parent row is collapsed or hidden
var parentRow = rows[i].closest(".collapse");
var isParentCollapsed = parentRow && (!parentRow.classList.contains("show"));
if (isParentCollapsed) {
continue; // Skip child table rows if parent is collapsed
}
for (var j = 0; j < cols.length; j++) {
var cellValue = cols[j].innerText.replace(/,/g, ""); // Remove commas from the cell value
row.push(cellValue);
}
csv.push(row.join(","));
}
// Create a CSV file
var csvContent = "data:text/csv;charset=utf-8," + csv.join("\n");
var encodedUri = encodeURI(csvContent);
@ -466,6 +444,42 @@ function footerfunctions()
});
</script>
<!-- pdf document -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.0/xlsx.full.min.js"></script>
<script>
document.getElementById('downloadCsv').addEventListener('click', function() {
const table = document.getElementById('myTable');
const rows = Array.from(table.rows);
const data = [];
rows.forEach((row) => {
const cells = Array.from(row.cells);
const rowData = [];
cells.forEach((cell) => {
// Handle colspan
const colspan = cell.colSpan || 1;
for (let i = 0; i < (colspan - 1); i++) {
rowData.push(''); // Fill empty cells for merged columns
}
for (let i = 0; i < 1; i++) {
rowData.push(cell.innerText.trim());
}
// Fill empty cells for colspan
});
data.push(rowData);
});
// Create a worksheet
const worksheet = XLSX.utils.aoa_to_sheet(data);
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
// Export to Excel
XLSX.writeFile(workbook, 'table.xlsx');
});
</script>
<!-- pdf document ends-->
<?php
}
?>

View File

@ -8,7 +8,6 @@ $ExpenseAccounts = $this->acc->getAccountsByGroup(4);
$IncomesTotal = $this->acc->getAccountBalanceByGroup(3);
$ExpensesTotal = $this->acc->getAccountBalanceByGroup(4);
$PL = $IncomesTotal - $ExpensesTotal;
?>
<style>
table,
@ -91,80 +90,75 @@ $PL = $IncomesTotal - $ExpensesTotal;
box-shadow: inset 0 0 0 transparent;
transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}
.table.table-head-fixed thead tr:nth-child(1) th {
padding-left: 6px;
;
}
</style>
<div class="content-wrapper">
<section class="content">
<div class="container-fluid">
<div class="card card-primary card-outline ">
<div class="card-header">
<h3 class="card-title">Receipts And Payments <?php //echo $pageTitle;
<h3 class="card-title mt-1">Receipts And Payments <?php //echo $pageTitle;
?> </h3>
<div class="card-tools">
<form method="post" action="" id="FilterForm">
<form method="post" action=<?php echo base_url('accounts/reports/receipt_and_payment'); ?> id="FilterForm">
<!-- button with a dropdown -->
<div class="btn-group">
<button type="button" class="btn btn-success btn-sm dropdown-toggle" data-toggle="dropdown" data-offset="-52">
Filters
</button>
<div class="dropdown-menu" role="menu">
<div class="form-group p-2 pb-0">
<div class="col">
<div class="form-group">
<label for="fromDate"><?php myLang("Starting Period"); ?></label>
<input type="text" class="form-control " name="fromDate" value="<?php echo (isset($_POST['fromDate'])) ? $_POST['fromDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_from); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="fromDate" aria-describedby="helpId_fromDate" placeholder="Starting Period">
</div>
<div class="form-group">
<label for="toDate"><?php myLang("Ending Period"); ?></label>
<input type="text" class="form-control " name="toDate" value="<?php echo (isset($_POST['toDate'])) ? $_POST['toDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_to); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="toDate" aria-describedby="helpId_toDate" placeholder="Ending Period">
</div>
</div>
<div class="dropdown-divider"></div>
<div class="form-check">
<!-- <div class="form-check">
<input class="form-check-input" type="checkbox">
<label class="form-check-label">Select
All</label>
</div>
</div> -->
<div class="form-check">
<input type="hidden" name="showOB" value="not">
<!-- <input type="hidden" name="showOB" value="not"> -->
<input type="checkbox" class="form-check-input " name="showOB" id="showOB" aria-describedby="helpId_showOB" placeholder="Show Opening Balance" <?php echo (isset($_POST['showOB'])) ? "CHECKED" : ""; ?>>
<!-- <input class="form-check-input" type="checkbox"> -->
<label class="form-check-label">Opening</label>
<label class="form-check-label" for="showOB">Opening</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox"> -->
<input type="checkbox" class="form-check-input " name="showClosing" id="showClosing" aria-describedby="helpId_showClosing" placeholder="Show Closing Balance" <?php echo (isset($_POST['showClosing'])) ? "CHECKED" : ""; ?>>
<label class="form-check-label">Closing</label>
<label class="form-check-label" for="showClosing">Closing</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox" checked> -->
<input type="checkbox" class="form-check-input" name="showPeriod" id="showPeriod" aria-describedby="helpId_showPeriod" placeholder="Show Periodic Balance" <?php echo (isset($_POST['showPeriod'])) ? "CHECKED" : "CHECKED"; ?>>
<label class="form-check-label">Period</label>
<label class="form-check-label" for="showPeriod">Period</label>
</div>
</div>
<div class="dropdown-divider"></div>
<button type="submit" class="btn btn-primary mr-2 text-center">Search Now</button>
<div class="form-group p-2 pb-0 text-right">
<button type="button" class="btn btn-info btn-sm " style="width:60px;height:30px;" onclick="resetForm()">Reset</button>
<button type="submit" class="btn btn-primary mr-2 btn-sm" style="width:60px;height:30px;">Search </button>
</div>
</div>
</div>
<div class="btn-group">
<button type="submit" class="btn btn-danger btn-sm " data-toggle="dropdown" data-offset="-52">
<!-- <button type="submit" class="btn btn-warning btn-sm " data-toggle="dropdown" data-offset="-52">
Export
</button> -->
<button type="submit" id="downloadCsv" class="btn btn-warning btn-sm ">
Export csv
</button>
<!-- <div class="dropdown-menu" role="menu">
<a href="#" class="dropdown-item">Export</a>
<a href="#" class="dropdown-item">Pdf</a>
@ -172,10 +166,8 @@ $PL = $IncomesTotal - $ExpensesTotal;
<a href="#" class="dropdown-item">View calendar</a>
</div> -->
</div>
<button type="button" class="btn btn-warning btn-sm" onclick="resetForm()">Reset</button>
<!-- <button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle Collapse</button> -->
<!-- <button type="button" class="btn btn-warning btn-sm" onclick="resetForm()">Reset</button> -->
<button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle Collapse</button>
</form>
<script>
function resetForm() {
@ -189,39 +181,43 @@ $PL = $IncomesTotal - $ExpensesTotal;
</div>
<!-- /.card-tools -->
</div>
<!-- <div class="card-body">
<form method="post" action="" id="FilterForm">
<div class="row align-items-end">
<div class="col-2">
<div class="form-group">
<label for="fromDate"><?php myLang("Starting Period"); ?></label>
<input type="text" class="form-control nepaliDatePicker" name="fromDate" value="<?php echo (isset($_POST['fromDate'])) ? $_POST['fromDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_from); ?>" id="fromDate" aria-describedby="helpId_fromDate" placeholder="Starting Period">
<label for="fromDate"><?php //myLang("Starting Period");
?></label>
<input type="text" class="form-control nepaliDatePicker" name="fromDate" value="<?php //echo (isset($_POST['fromDate'])) ? $_POST['fromDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_from);
?>" id="fromDate" aria-describedby="helpId_fromDate" placeholder="Starting Period">
</div>
</div>
<div class="col-2">
<div class="form-group">
<label for="toDate"><?php myLang("Ending Period"); ?></label>
<input type="text" class="form-control nepaliDatePicker" name="toDate" value="<?php echo (isset($_POST['toDate'])) ? $_POST['toDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_to); ?>" id="toDate" aria-describedby="helpId_toDate" placeholder="Ending Period">
<label for="toDate"><?php //myLang("Ending Period");
?></label>
<input type="text" class="form-control nepaliDatePicker" name="toDate" value="<?php //echo (isset($_POST['toDate'])) ? $_POST['toDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_to);
?>" id="toDate" aria-describedby="helpId_toDate" placeholder="Ending Period">
</div>
</div>
<div class="col-1 text-center">
<div class="form-group">
<label for="showOB"><?php myLang("Opening"); ?></label>
<label for="showOB"><?php //myLang("Opening");
?></label>
<input type="checkbox" class="form-control " name="showOB" id="showOB" aria-describedby="helpId_showOB" placeholder="Show Opening Balance" <?php echo (isset($_POST['showOB'])) ? "CHECKED" : "CHECKED"; ?>>
</div>
</div>
<div class="col-1 text-center">
<div class="form-group">
<label for="showClosing"><?php myLang("Closing"); ?></label>
<label for="showClosing"><?php //myLang("Closing");
?></label>
<input type="checkbox" class="form-control " name="showClosing" id="showClosing" aria-describedby="helpId_showClosing" placeholder="Show Closing Balance" <?php echo (isset($_POST['showClosing'])) ? "CHECKED" : "CHECKED"; ?>>
</div>
</div>
<div class="col-1 text-center">
<div class="form-group">
<label for="showPeriod"><?php myLang("Period"); ?></label>
<label for="showPeriod"><?php //myLang("Period");
?></label>
<input type="checkbox" class="form-control " name="showPeriod" id="showPeriod" aria-describedby="helpId_showPeriod" placeholder="Show Periodic Balance" <?php echo (isset($_POST['showPeriod'])) ? "CHECKED" : "CHECKED"; ?>>
</div>
</div>
@ -234,9 +230,7 @@ $PL = $IncomesTotal - $ExpensesTotal;
</div>
</div>
</div>
</form>
<script>
function resetForm() {
document.getElementById("fromDate").value = "2078-4-1";
@ -246,23 +240,20 @@ $PL = $IncomesTotal - $ExpensesTotal;
document.getElementById("FilterForm").submit();
}
</script>
</div> -->
</div>
<div class="card">
<div class="card card-primary card-outline">
<?php $IncomesExpenses = $BIBAccounts->prepareIncomeExpenses() ?>
<table class="table table-head-fixed table-bordered g-0">
<?php $IncomesExpenses = $BIBAccounts->prepareIncomeExpenses($fiscalStart, $fiscalEnd) ?>
<table id='myTable' class="table table-head-fixed table-bordered g-0" id="TrialBalanceTable">
<thead>
<tr>
<th class="" width="35%"><?php myLang("Receipts"); ?></th>
<th class="text-right" width="15%"></th>
<th class="text-right" width="15%"><?php myLang("Amount"); ?></th>
<th class="" width="35%"><?php echo myLang("Payments"); ?></th>
<th class="text-right" width="15%"></th>
<th class="text-right" width="15%"><?php myLang("Amount"); ?></th>
<th class="" width="30%"><?php myLang("Receipts"); ?></th>
<th class="text-right" width="10%"></th>
<th class="text-right pr-2" width="10%"><?php myLang("Amount"); ?></th>
<th class="" width="30%"><?php echo myLang("Payments"); ?></th>
<th class="text-right" width="10%"></th>
<th class="text-right pr-2" width="10%"><?php myLang("Amount"); ?></th>
</tr>
</thead>
<tbody>
@ -270,33 +261,34 @@ $PL = $IncomesTotal - $ExpensesTotal;
<td colspan=3 class="p-0">
<table class="table g-0">
<?php $total1 = 0;
$counter = 0;
$index = 0;
foreach ($IncomesExpenses['Incomes'] as $Incomes) { ?>
<?php if ($Incomes['account'] == "GROUP TOTAL") : ?>
<!--tr>
<td class="" width="70%"><b><?php echo $Incomes['group']; ?></b></td>
<td width="15%"></td>
<td class="text-right" width="15%"><u><?php echo myCurrency($Incomes['amount']); ?></u></td>
</tr-->
<?php elseif ($Incomes['account'] == "CATEGORY TOTAL") : ?>
<tr>
<td class="" width="70%"><b><?php echo $Incomes['category']; ?></b></td>
<td class="text-right" width="15%"><?php echo myCurrency($Incomes['amount']); ?></td>
<td width="15%"></td>
<?php $index++; ?>
<tr class="parent-row" class="group-heading" data-toggle="collapse" data-target="#group_<?php echo $index; ?>">
<td class="" width="60%"><b><?php echo $Incomes['category']; ?></b></td>
<td width="20%"></td>
<td class="text-right pr-2" width="20%"><?php echo myCurrency($Incomes['amount']); ?></td>
</tr>
<?php else : ?>
<?php $total1 += $Incomes['amount']; ?>
<tr>
<td class="" width="70%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $Incomes['account']; ?></td>
<td width="15%"></td>
<td class="text-right" width="15%"><?php echo myCurrency($Incomes['amount']); ?></td>
<tr class="collapse" data-target="#group_<?php echo $index; ?>">
<td class="pr-2" width="60%">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $Incomes['account']; ?>
</td>
<td class="text-right pr-2" width="20%"><?php echo myCurrency($Incomes['amount']); ?></td>
<td width="20%"></td>
</tr>
<?php endif; ?>
<?php $counter = $index ?>
<?php }; ?>
</table>
</td>
<td colspan=3 class="p-0">
@ -308,41 +300,35 @@ $PL = $IncomesTotal - $ExpensesTotal;
<td class="" width="70%"><b><?php echo $Expenses['group']; ?></b></td>
<td width="15%"></td>
<td class="text-right" width="15%"><u><?php echo myCurrency($Expenses['amount']); ?></u></td>
</tr-->
<?php elseif ($Expenses['account'] == "CATEGORY TOTAL") : ?>
<tr>
<td class="" width="70%"><b><?php echo $Expenses['category']; ?></b></td>
<td class="text-right" width="15%"><?php echo myCurrency($Expenses['amount']); ?></td>
<td width="15%"></td>
<?php $counter++; ?>
<tr data-toggle="collapse" data-target="#group_<?php echo $counter; ?>">
<td class="pr-2" width="60%"><b><?php echo $Expenses['category']; ?></b></td>
<td width="20%"></td>
<td class="text-right pr-2" width="20%"><?php echo myCurrency($Expenses['amount']); ?></td>
</tr>
<?php else : ?>
<?php $total += $Expenses['amount']; ?>
<tr>
<td class="" width="70%">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $Expenses['account']; ?></td>
<td width="15%"></td>
<td class="text-right" width="15%"><?php echo myCurrency($Expenses['amount']); ?></td>
<tr class="collapse" data-target="#group_<?php echo $counter; ?>">
<td class="" width="60%">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<?php echo $Expenses['account']; ?>
</td>
<td class="text-right pr-2" width="20%"><?php echo myCurrency($Expenses['amount']); ?></td>
<td width="20%"></td>
</tr>
<?php endif; ?>
<?php }; ?>
</table>
</td>
</tr>
<?php $balance_fi = $total1 - $total; ?>
<?php if ($balance_fi < 0) : $total1 += $balance_fi; ?>
<tr>
<th><?php echo myLang("Closing Balance"); ?></th>
<th class="pl-2"><?php echo myLang("Closing Balance"); ?></th>
<th></th>
<td><span class="text-red"><?php echo myCurrency($balance_fi); ?></span></td>
<td><span class="text-red pr-2"><?php echo myCurrency($balance_fi); ?></span></td>
<th></th>
<th></th>
<td></td>
@ -352,37 +338,84 @@ $PL = $IncomesTotal - $ExpensesTotal;
<th></th>
<th></th>
<td></td>
<th><?php echo myLang("Closing Balance"); ?></th>
<th class="pl-2"><?php echo myLang("Closing Balance"); ?></th>
<th></th>
<td><?php echo myCurrency($balance_fi); ?></td>
<td class="pr-2"><?php echo myCurrency($balance_fi); ?></td>
</tr>
<?php endif; ?>
<tr>
<th>Total</th>
<th class="pl-2">Total</th>
<th></th>
<td><?php echo myCurrency($total1); ?></td>
<th>Total</th>
<td class="pr-2"><?php echo myCurrency($total1); ?></td>
<th class="pl-2">Total</th>
<th></th>
<td><?php echo myCurrency($total); ?></td>
<td class="pr-2"><?php echo myCurrency($total); ?></td>
</tr>
</tbody>
</table>
</div>
</div>
</div><!-- /.container-fluid -->
</section>
<?php function footerFunctions()
{ ?>
<script>
$(document).ready(function() {
// Prevent the dropdown from closing when clicking inside
$('.dropdown-menu').on('click', function(event) {
event.stopPropagation();
});
});
</script>
<script>
// var exportButton = document.getElementById("exportButton");
// exportButton.addEventListener("click", function() {
// exportTableToCSV("table.csv");
// });
document.addEventListener("DOMContentLoaded", function() {
// Trigger click event on page load
document.getElementById("toggleShowAll").click();
});
document.getElementById("toggleShowAll").addEventListener("click", function(e) {
e.preventDefault();
var nestedRows = document.getElementsByClassName("collapse");
for (var i = 0; i < nestedRows.length; i++) {
if (nestedRows[i].classList.contains("show")) {
nestedRows[i].classList.remove("show");
} else {
nestedRows[i].classList.add("show");
}
}
});
function exportTableToCSV(filename) {
var csv = [];
var rows = document.querySelectorAll("table tr:not(.hide)");
for (var i = 0; i < rows.length; i++) {
var row = [];
var cols = rows[i].querySelectorAll("td:not(.hide), th:not(.hide)");
// Check if the parent row is collapsed or hidden
var parentRow = rows[i].closest(".collapse");
var isParentCollapsed = parentRow && (!parentRow.classList.contains("show"));
if (isParentCollapsed) {
continue; // Skip child table rows if parent is collapsed
}
for (var j = 0; j < cols.length; j++) {
var cellValue = cols[j].innerText.replace(/,/g, ""); // Remove commas from the cell value
row.push(cellValue);
}
csv.push(row.join(","));
}
// Create a CSV file
var csvContent = "data:text/csv;charset=utf-8," + csv.join("\n");
var encodedUri = encodeURI(csvContent);
var link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", filename);
document.body.appendChild(link);
link.click();
}
</script>
<script>
$("#fromDate").nepaliDatePicker({
dateFormat: "%y-%m-%d",
@ -399,4 +432,41 @@ $PL = $IncomesTotal - $ExpensesTotal;
maxDate: $('#toDate').data('end'),
});
</script>
<!-- pdf document -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.0/xlsx.full.min.js"></script>
<script>
document.getElementById('downloadCsv').addEventListener('click', function() {
const table = document.getElementById('myTable');
const rows = Array.from(table.rows);
const data = [];
rows.forEach((row) => {
const cells = Array.from(row.cells);
const rowData = [];
cells.forEach((cell) => {
// Handle colspan
const colspan = cell.colSpan || 1;
for (let i = 0; i < (colspan - 1); i++) {
rowData.push(''); // Fill empty cells for merged columns
}
for (let i = 0; i < 1; i++) {
rowData.push(cell.innerText.trim());
}
// Fill empty cells for colspan
});
data.push(rowData);
});
// Create a worksheet
const worksheet = XLSX.utils.aoa_to_sheet(data);
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
// Export to Excel
XLSX.writeFile(workbook, 'table.xlsx');
});
</script>
<!-- pdf document ends-->
<?php } ?>

View File

@ -25,7 +25,7 @@
<div class="card card-primary card-outline">
<div class="card-header">
<h5 class="m-0"><?php echo $pageTitle; ?>
<h5 class="m-0 card-title"><?php echo $pageTitle; ?>
<!-- <a href="<?php //echo site_url("accounts/setup/addsingleentryvoucher"); ?>" class="btn btn-sm btn-primary float-right">Create New <?php //echo $pageTitle; ?></a> -->
</h5>
@ -34,15 +34,15 @@
<div class="card-body">
<?php $TableData = $this->db->query("select * from tbl_vouchertypes")->result(); ?>
<table class="table table-bordered table-striped dataTable">
<table class="table table-bordered table-striped longdataTable">
<thead>
<tr>
<th>Sn</th>
<th>Voucher Name</th>
<th>Default Debits</th>
<th>Default Credits</th>
<th>Voucher Color</th>
<th class="table-col col-2">Action</th>
<th class="text-center">Sn</th>
<th class="col-2">Voucher Name</th>
<th class="col-4">Default Debits</th>
<th class="col-4">Default Credits</th>
<th class="col-1 text-center">Voucher Color</th>
<th class=" text-center">Action</th>
</tr>
</thead>
<tbody>
@ -51,14 +51,14 @@
<?php foreach ($TableRow as $cols) : $id = $cols;
break;
endforeach; ?><tr class="<?php echo ($TableRow->status == 0) ? "table-danger" : ""; ?>">
<td><?php echo $sn; ?></td>
<td class="text-center"><?php echo $sn; ?></td>
<td><?php echo $TableRow->voucher_name; ?></td>
<td><?php echo showAccountCategoriesByIds(($TableRow->default_debits!="")?explode(",",$TableRow->default_debits):array()); ?></td>
<td><?php echo showAccountCategoriesByIds(($TableRow->default_credits!="")?explode(",",$TableRow->default_credits):array()); ?></td>
<td><span class="inline-block" style="padding:0px 8px;border:1px solid <?php echo $TableRow->voucher_color; ?>;background:<?php echo $TableRow->voucher_color; ?>">&nbsp;</span> </td>
<td>
<td class="text-center"><span class="inline-block " style="padding:0px 8px;text-align:center;border:1px solid <?php echo $TableRow->voucher_color; ?>;background:<?php echo $TableRow->voucher_color; ?>">&nbsp;</span> </td>
<td class="text-center">
<?php showEditButton($commandURL = "accounts/setup/editvouchertype/" . $TableRow->vouchertype_id , "Edit", ""); ?>
</td>

View File

@ -1,6 +1,7 @@
<?php
$this->load->library("BIBAccounts");
$BIBAccounts = new BIBAccounts();
?>
<!-- Include jQuery -->
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
@ -21,6 +22,7 @@ $BIBAccounts = new BIBAccounts();
.group-total {
width: 10%;
}
.table-gray {
@ -31,9 +33,10 @@ $BIBAccounts = new BIBAccounts();
.table th {
padding: 0px;
margin: 0px;
}
.bg-darker {
.table t .bg-darker {
background-color: #ddd;
}
@ -72,6 +75,10 @@ $BIBAccounts = new BIBAccounts();
text-decoration: underline;
}
.text-right {
padding-right: 5px;
}
.form-control {
display: block;
width: 100%;
@ -88,16 +95,21 @@ $BIBAccounts = new BIBAccounts();
box-shadow: inset 0 0 0 transparent;
transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}
.bg-gray tr th {
vertical-align: middle;
}
</style>
<div class="content-wrapper">
<div class="content">
<div class="container-fluid">
<div class="card card-primary card-outline">
<div class="card-header">
<h2 class="card-title"><?php echo $pageTitle; ?> <?php myLang("Report"); ?></h2>
<h2 class="card-title mt-1"><?php echo $pageTitle; ?> <?php //myLang("Report");
?></h2>
<div class="card-tools">
<form method="post" action="" id="FilterForm">
<form method="post" action=<?php echo site_url('/Accounts/Reports/trialbalance'); ?> id="FilterForm">
<!-- button with a dropdown -->
<div class="btn-group">
@ -105,52 +117,53 @@ $BIBAccounts = new BIBAccounts();
Filters
</button>
<div class="dropdown-menu" role="menu">
<div class="form-group p-2 pb-0">
<div class="col">
<div class="form-group">
<label for="fromDate"><?php myLang("Starting Period"); ?></label>
<input type="text" class="form-control " name="fromDate" value="<?php echo (isset($_POST['fromDate'])) ? $_POST['fromDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_from); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="fromDate" aria-describedby="helpId_fromDate" placeholder="Starting Period">
</div>
<div class="form-group">
<label for="toDate"><?php myLang("Ending Period"); ?></label>
<input type="text" class="form-control " name="toDate" value="<?php echo (isset($_POST['toDate'])) ? $_POST['toDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_to); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="toDate" aria-describedby="helpId_toDate" placeholder="Ending Period">
</div>
</div>
<div class="dropdown-divider"></div>
<div class="form-check">
<!-- <div class="form-check">
<input class="form-check-input" type="checkbox">
<label class="form-check-label">Select
All</label>
</div>
</div> -->
<div class="form-check">
<input type="hidden" name="showOB" value="not">
<!-- <input type="hidden" name="showOB" value="not"> -->
<input type="checkbox" class="form-check-input " name="showOB" id="showOB" aria-describedby="helpId_showOB" placeholder="Show Opening Balance" <?php echo (isset($_POST['showOB'])) ? "CHECKED" : ""; ?>>
<!-- <input class="form-check-input" type="checkbox"> -->
<label class="form-check-label">Opening</label>
<label class="form-check-label" for="showOB">Opening</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox"> -->
<input type="checkbox" class="form-check-input " name="showClosing" id="showClosing" aria-describedby="helpId_showClosing" placeholder="Show Closing Balance" <?php echo (isset($_POST['showClosing'])) ? "CHECKED" : ""; ?>>
<label class="form-check-label">Closing</label>
<label class="form-check-label" for="showClosing">Closing</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox" checked> -->
<input type="checkbox" class="form-check-input" name="showPeriod" id="showPeriod" aria-describedby="helpId_showPeriod" placeholder="Show Periodic Balance" <?php echo (isset($_POST['showPeriod'])) ? "CHECKED" : "CHECKED"; ?>>
<label class="form-check-label">Period</label>
<label class="form-check-label" for="showPeriod">Period</label>
</div>
</div>
<div class="dropdown-divider"></div>
<button type="submit" class="btn btn-primary mr-2 text-center">Search Now</button>
<div class="form-group p-2 pb-0 text-right">
<button type="button" class="btn btn-info btn-sm " style="width:60px;height:30px;" onclick="resetForm()">Reset</button>
<button type="submit" class="btn btn-primary mr-2 btn-sm" style="width:60px;height:30px;">Search </button>
</div>
</div>
</div>
<div class="btn-group">
<button type="submit" class="btn btn-danger btn-sm " data-toggle="dropdown" data-offset="-52">
<!-- <button type="submit" class="btn btn-warning btn-sm" data-toggle="dropdown" data-offset="-52">
Export
</button> -->
<button type="submit" id="downloadCsv" class="btn btn-warning btn-sm ">
Export csv
</button>
@ -161,7 +174,7 @@ $BIBAccounts = new BIBAccounts();
<a href="#" class="dropdown-item">View calendar</a>
</div> -->
</div>
<button type="button" class="btn btn-warning btn-sm" onclick="resetForm()">Reset</button>
<!-- <button type="button" class="btn btn-info btn-sm" onclick="resetForm()">Reset</button> -->
<button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle Collapse</button>
@ -200,10 +213,10 @@ $BIBAccounts = new BIBAccounts();
$showZeroBalances = false;
?>
<?php $AccountGroups = $BIBAccounts->getAccountGroupsWithBalances(); ?>
<table class="table table-bordered vertical-borders" id="TrialBalanceTable">
<table id='myTable' class="table table-bordered vertical-borders" id="TrialBalanceTable">
<thead class="bg-gray">
<tr>
<th rowspan="2">Particulars</th>
<th rowspan="2 class="">Particulars</th>
<?php if ($ReportOptions['showOB']) : ?>
<th colspan=" 2" class="text-center">Opening</th>
<?php endif; ?>
@ -309,6 +322,14 @@ $BIBAccounts = new BIBAccounts();
function footerfunctions()
{
?>
<script>
$(document).ready(function() {
// Prevent the dropdown from closing when clicking inside
$('.dropdown-menu').on('click', function(event) {
event.stopPropagation();
});
});
</script>
<script>
// var exportButton = document.getElementById("exportButton");
// exportButton.addEventListener("click", function() {
@ -374,6 +395,43 @@ function footerfunctions()
maxDate: $('#toDate').data('end'),
});
</script>
<!-- pdf document -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.0/xlsx.full.min.js"></script>
<script>
document.getElementById('downloadCsv').addEventListener('click', function() {
const table = document.getElementById('myTable');
const rows = Array.from(table.rows);
const data = [];
rows.forEach((row) => {
const cells = Array.from(row.cells);
const rowData = [];
cells.forEach((cell) => {
// Handle colspan
const colspan = cell.colSpan || 1;
for (let i = 0; i < (colspan - 1); i++) {
rowData.push(''); // Fill empty cells for merged columns
}
for (let i = 0; i < 1; i++) {
rowData.push(cell.innerText.trim());
}
// Fill empty cells for colspan
});
data.push(rowData);
});
// Create a worksheet
const worksheet = XLSX.utils.aoa_to_sheet(data);
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
// Export to Excel
XLSX.writeFile(workbook, 'table.xlsx');
});
</script>
<!-- pdf document ends-->
<?php
}
?>

View File

@ -1,121 +1,82 @@
<div class="content-wrapper">
<div class="content-header">
<div class="container-fluid">
<div class="row mb-2">
<div class="col-sm-6">
<h1 class="m-0">
<?php echo $pageTitle; ?></h1>
</div>
<div class="col-sm-6">
<ol class="breadcrumb float-sm-right">
<li class="breadcrumb-item">
<a href="<?php echo base_url(); ?>">
Dashboard</a>
</li>
<li class="breadcrumb-item active">
<?php echo $pageTitle; ?></li>
</ol>
</div>
</div>
</div>
</div>
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col">
<div class="card card-primary card-outline">
<div class="card-header">
<h5 class="m-0">
<?php echo $pageTitle; ?> <a href="<?php echo site_url("accounts/vouchers/" . $VoucherType->voucher_alias . "/create"); ?>" class="btn btn-sm btn-primary float-right">
Create New <?php echo $pageTitle; ?></a></h5>
</div>
<div class="card-body">
<?php $TableData = $Vouchers ?>
<table class="table table-bordered table-striped" id="voucherList">
<thead>
<tr>
<th>ID#</th>
<th>Voucher No</th>
<th>Voucher Date</th>
<th>Voucher Type</th>
<th>Voucher State</th>
<th class="table-col col-2">Action</th>
</tr>
</thead>
<tbody>
<?php $a=0; foreach ($TableData as $TableRow) : $a++; ?>
<?php $a = 0;
foreach ($TableData as $TableRow) : $a++; ?>
<?php foreach ($TableRow as $cols) : $id = $cols;
break;
endforeach; ?><tr data-id="<?php echo $TableRow->voucher_id; ?>" class="<?php echo ($TableRow->voucher_state == "Reversed") ? "table-danger" : ""; ?>">
<td><?php echo $TableRow->voucher_id; ?></td>
<td><?php echo $TableRow->voucher_no; ?></td>
<td><?php echo $TableRow->voucher_date; ?></td>
<td><?php echo $TableRow->voucher_type; ?></td>
<td><?php echo $TableRow->voucher_state; ?></td>
<td class="col-1">
<a onClick="javascript:showDetails(<?php echo $id; ?>);" class="btn btn-success btn-xs" title="View Details">
<i class="fa fa-eye">
</i></a>
</td>
</tr>
<?php endforeach; ?>
<tbody>
</table>
<div class="modal fade" id="voucherdetails_box" tabindex="-1" role="dialog" aria-labelledby="voucherdetails_box" aria-hidden="true">
<div class="modal-dialog modal-xl" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">
Voucher Details</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">
&times;</span>
</button>
</div>
<div class="modal-body" id="details_container">
Voucher Details Goes Here
</div>
<div class="modal-footer">
<button type="button" onClick='reversalEntry()' id="reversalBtn" class="btn btn-secondary" data-dismiss="modal" data-id="">
Revarsal Entry</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">
@ -138,7 +99,6 @@
function reversalEntry() {
var id = $("#reversalBtn").data("id");
if (confirm("Are you sure you want to post reversal for this voucher?")) {
window.location = "<?php echo site_url("accounts/vouchers/reversal/"); ?>" + id;
}
@ -158,7 +118,6 @@ function footerfunctions()
<script>
$(document).ready(function() {
var table = $('#voucherList').DataTable();
var tableRows = $('table#voucherList tbody').find('tr');
tableRows.each(function() {
async: false;
@ -169,8 +128,6 @@ function footerfunctions()
Transactions = getVoucherDetails(id);
row.child(Transactions).show();
});
});
function getVoucherDetails(id) {

View File

@ -81,7 +81,7 @@ button:hover {
<div class="row">
<div class="col">
<div class="card card-primary card-outline">
<!-- <div class="card-header" style="background-color: <?php echo $VoucherType->voucher_color; ?>;">
<!-- <div class="card-header" style="background-color: <?php //echo $VoucherType->voucher_color; ?>;">
<h5 class="m-0">
<?php //echo $pageTitle;
?>
@ -99,7 +99,7 @@ button:hover {
</fieldset>
</div>
<div class="col-8">
<h1 class="text-center"><?php echo $pageTitle; ?> Voucher</h1>
<h1 class="text-center"><?php echo $pageTitle; ?></h1>
<!-- <fieldset>
<legend><span id="selectedAccountName"></span> Balance</legend><span id="selectedAccountBalance" style="padding: 6px 0px; display: inline-block; text-align: right; width: 100%;">Choose A/C First</span>
</fieldset> -->

View File

@ -1,17 +1,12 @@
<div class="content-wrapper">
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col">
<div class="card card-primary card-outline">
<div class="card-header">
<h5 class="m-0"><?php echo $pageTitle; ?> </h5>
</div>
<div class="card-body">
<form method="GET" action="">
<div class="row">
@ -26,11 +21,10 @@
</div>
<!-- <div class="col"><?php $this->myaccounts->showAccountsCombo("account_id", "Account", "account_id", "status=1", isset($_GET['account_id']) ? $_GET['account_id'] : ''); //fillComboWithValue("account_id","Account","account_id","tbl_accounts","account_name","account_id",isset($_GET['account_id'])?$_GET['account_id']:'');
?></div> -->
<div class="col-2"><?php createNepaliDateInput("from_date", "From Date", "from_date", isset($fromDate_bs) ? $fromDate_bs : FYStart()); ?></div>
<div class="col-2"><?php createNepaliDateInput("to_date", "To Date", "to_date", isset($toDate_bs) ? $toDate_bs : FYEnd()); ?></div>
<div class="col-1"><?php createButton("show_voucher", "Show", "show_voucher", "Submit", "mt-30"); ?></div>
<div class="col-1"><?php createButton("show_voucher_reset", "Reset", "reset", site_url("accounts/vouchers/listvouchers"), "mt-30"); ?></div>
<div class="col-1"><?php createButton("show_voucher", "Show", "show_voucher", "Submit", "mt-26"); ?></div>
<div class="col-1"><?php createButton("show_voucher_reset", "Reset", "reset", site_url("accounts/vouchers/listvouchers"), "mt-26"); ?></div>
</div>
</form>
<div id="dataTable_Commands"></div>
@ -40,14 +34,13 @@
// echo $toDate;
$account_id = isset($_GET['account_id']) ? $_GET['account_id'] : '';
$vouchertype_id = isset($_GET['vouchertypes']) ? $_GET['vouchertypes'] : '';
$this->myaccounts->listVouchers($fromDate, $toDate, $account_id, $vouchertype_id, true);
$this->myaccounts->listVouchers($fromDate, $toDate, $account_id, $vouchertype_id, true, false, $fiscalStart, $fiscalEnd);
?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -8,7 +8,7 @@
<div class="card card-primary card-outline">
<div class="card-header">
<!-- <?php echo isset($item) ? 'Edit' : 'Create'; ?> -->
<h5 class="m-0">Create <?php echo $pageTitle; ?>
<h5 class="m-0 card-title">Create <?php echo $pageTitle; ?>
<?php //showListButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/list","List ".$pageTitle);
?>
</h5>
@ -80,7 +80,7 @@
<div class="col-9">
<div class="card card-primary card-outline">
<div class="card-header">
<h5 class="m-0">
<h5 class="m-0 card-title">
Current Fiscal Year :
<?php $currentFiscalYear = showFiscalYear(); ?>
@ -95,12 +95,12 @@
<table class="table table-bordered table-striped longdataTable">
<thead>
<tr>
<th>Fiscal Year </th>
<th> Code</th>
<th class="col-2">Fiscal Year </th>
<th class="col-4"> Code</th>
<th>From</th>
<th>To</th>
<!-- <th>Created By</th> -->
<th>Action</th>
<th class="col-1 text-center">Action</th>
</tr>
</thead>
<tbody>
@ -115,7 +115,7 @@
<td><?php echo $TableRow->fiscalyear_to; ?></td>
<!-- <td><?php //echo $TableRow->created_by;
?></td> -->
<td>
<td class="text-center">
<!-- <?php //showEditButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/edit/$id"); ?> -->

View File

@ -39,6 +39,80 @@
<link rel="stylesheet" href="<?php echo base_url(); ?>plugins/select2-bootstrap4-theme/select2-bootstrap4.min.css">
<link rel="stylesheet" href="<?php echo base_url(); ?>plugins/bstreeview/css/bstreeview.min.css">
<link rel="stylesheet" href="<?php echo base_url(); ?>dist/css/bbnepalcustom.css">
<!-- CSV File create -->
<script>
// document.getElementById('downloadBtn').addEventListener('click', function() {
// const table = document.getElementById('myTable');
// const csvData = [];
// const rowCount = table.rows.length;
// const output = [];
// for (let i = 0; i < rowCount; i++) {
// const row = table.rows[i];
// const rowArray = [];
// let skipCell = 0;
// for (let j = 0; j < row.cells.length; j++) {
// const cell = row.cells[j];
// if (skipCell > 0) {
// skipCell--;
// continue; // Skip this cell due to rowspan
// }
// const cellContent = cell.textContent.trim();
// const colspan = cell.colSpan || 1;
// const rowspan = cell.rowSpan || 1;
// // Fill the rowArray for the colspan
// for (let k = 0; k < colspan; k++) {
// if (k === colspan - 1) {
// rowArray.push(cellContent); // Last cell of colspan gets content
// } else {
// rowArray.push(''); // Fill empty for additional colspan cells
// }
// }
// // Set skipCell to account for rowspan
// skipCell = rowspan - 1;
// // Ensure that the row length matches the maximum number of columns
// while (rowArray.length < output.length) {
// rowArray.push(''); // Fill empty cells
// }
// // Fill the output structure
// output[i] = rowArray;
// }
// }
// // Join rows for CSV format
// output.forEach(row => {
// const filledRow = row.map(cell => cell === undefined ? '' : cell);
// csvData.push(filledRow.join(','));
// });
// const csvContent = csvData.join('\n');
// const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' });
// const url = URL.createObjectURL(blob);
// const link = document.createElement('a');
// link.setAttribute('href', url);
// link.setAttribute('download', 'table_with_colspan_rowspan.csv');
// document.body.appendChild(link);
// link.click();
// document.body.removeChild(link);
// });
</script>
<!-- csv printing ends -->
<!-- Override Defaults By Prajwal -->
<style>
body {
@ -301,12 +375,12 @@
}
}
.narration_display
{
.narration_display {
font-style: italic;
}
.text-bold .currency
{
.text-bold .currency {
font-weight: 600 !important;
}
</style>

View File

@ -1,7 +1,7 @@
<!-- Navbar -->
<nav class="main-header navbar navbar-expand navbar-white navbar-light ">
<nav class="main-header navbar navbar-expand navbar-white navbar-light hidden-navbar ">
<!-- Left navbar links -->

View File

@ -4,7 +4,6 @@ $param = $this->uri->segment(2);
$subparam = $this->uri->segment(3);
$subparam2 = $this->uri->segment(4);
?>
<!-- Main Sidebar Container -->
<aside class="main-sidebar main-sidebar-custom sidebar-dark-primary elevation-4">
<!-- Brand Logo --> <a href="<?php echo base_url(); ?>" class="brand-link"> <img src="<?php echo base_url(); ?>dist/img/AdminLTELogo.png" alt="AdminLTE Logo" class="brand-image img-circle elevation-3" style="opacity: .8"> <span class="brand-text font-weight-light">
@ -15,8 +14,7 @@ $subparam2 = $this->uri->segment(4);
<!-- Sidebar user panel (optional) -->
<div class="user-panel mt-3 pb-3 mb-3 d-flex">
<div class="image"> <img src="<?php echo base_url(); ?>dist/img/user2-160x160.jpg" class="img-circle elevation-2" alt="User Image"> </div>
<div class="info"> <a href="#" class="d-block"><?php echo $this->session->userdata("CompanyName"); ?> (<?php echo ($this->session->userdata("FiscalYear")->fiscalyear_year); ?>)</a></div>
<div class="info"> <a href="#" class="d-block"><?php echo $this->session->userdata("CompanyName"); ?> (<?php echo ($this->session->userdata("FiscalYear")?->fiscalyear_year); ?>)</a></div>
</div> <!-- SidebarSearch Form -->
<div class="form-inline pb-2">
<div class="input-group" data-widget="sidebar-search">
@ -52,14 +50,14 @@ $subparam2 = $this->uri->segment(4);
<!-- <li class="nav-item"><a href="<?php echo site_url("master/acgroups"); ?>" class="nav-link <?php echo ($param == "acgroups") ? "active" : ""; ?>">
<p>Account Types</p>
</a></li> -->
<li class="nav-item"><a href="<?php echo site_url("master/accategories/parent");
<!-- <li class="nav-item"><a href="<?php echo site_url("master/accategories/parent");
?>" class="nav-link <?php echo (($param == "accategories" && $subparam == "parent") ||
($param == "accategories" && $subparam == "edit_parent") ||
($param == "accategories" && $subparam == "add_parent")
) ? "active" : "";
?>">
<p>Account Categories</p>
</a></li>
</a></li> -->
<li class="nav-item"><a href="<?php echo site_url("master/accategories/childs"); ?>" class="nav-link <?php echo (($param == "accategories" && $subparam == "childs") ||
($param == "accategories" && $subparam == "add_child") ||
($param == "accategories" && $subparam == "edit_child")
@ -74,7 +72,7 @@ $subparam2 = $this->uri->segment(4);
<?php if ($LoggedUser == "admin") : ?>
<?php //showMenu("Create New Ledger", "accounts/accountheads/add");
?>
<?php showMenu("List of Ledgers", "accounts/accountheads/list"); ?>
<?php showMenu("Ledgers", "accounts/accountheads/list"); ?>
<?php endif; ?>
</ul>
</li>
@ -118,7 +116,7 @@ $subparam2 = $this->uri->segment(4);
<?php if ($LoggedUser == "admin") : ?>
<?php foreach ($VoucherTypes as $VoucherType) : if ($VoucherType->voucher_alias != "sales" && $VoucherType->voucher_alias != "purchase") : ?>
<li class="nav-item"><a href="<?php echo site_url("accounts/vouchers/" . $VoucherType->voucher_alias . "/create"); ?>" class="nav-link <?php echo ($subparam == $VoucherType->voucher_alias && $subparam2 == "create") ? "active" : ""; ?>">
<p><?php echo $VoucherType->voucher_name; ?> Voucher</p>
<p><?php echo $VoucherType->voucher_name; ?></p>
</a></li>
<?php endif;
endforeach; ?>
@ -140,7 +138,6 @@ $subparam2 = $this->uri->segment(4);
<?php if ($LoggedUser == "admin") :
// showMenu("Inventory Stock", "inventory/stocks/list");
showMenu("Stock Report", "inventory/stocks/summary");
showMenu("Sales Register", "inventory/sales/sales_register");
showMenu("Purchase Register", "inventory/purchases/purchase_register");
showMenu("Purchase Vs Sales", "inventory/reports/purchase_vs_sales");
@ -163,7 +160,7 @@ $subparam2 = $this->uri->segment(4);
showMenu("Profit and Loss Statement", "accounts/reports/pl");
showMenu("Balance Sheet", "accounts/reports/balance_sheet");
// showMenu("Balance Sheet (Vertical)", "accounts/reports/balance_sheet_vertical");
showMenu("Receipt And Payments", "accounts/reports/receipt_and_payment");
showMenu("Receipt and Payment", "accounts/reports/receipt_and_payment");
// showMenu("Income And Expenses", "accounts/reports/incomes_and_expenses");
showMenu("Cash Flow", "accounts/reports/cash_flow");
showMenu("Ratio Analysis", "accounts/reports/ratio_analysis");
@ -189,7 +186,6 @@ $subparam2 = $this->uri->segment(4);
// showMenu("Group Summary", "accounts/ledger/partyledger");
showMenu("Group Summary", "accounts/reports/balance_by_group");
// showMenu("Balance by Category", "accounts/reports/balance_by_category");
showMenu("Accounts Receivables", "accounts/ledger/receiveables");
showMenu("Accounts Payables", "accounts/ledger/payables");
showMenu("Purchase Summary", "inventory/purchases/list");

View File

@ -91,7 +91,7 @@
<th width="30%"><?php myLang('Inventory Group'); ?></th>
<!-- <th width="5%"><?php //myLang('Unit'); ?></th> -->
<th width="57%"><?php myLang('Remarks'); ?></th>
<td width="8%"><?php myLang("Action"); ?></th>
<td class="text-center col-1"><?php myLang("Action"); ?></th>
</tr>
</thead>
<tbody>
@ -100,11 +100,11 @@
<?php foreach ($TableRow as $cols) : $id = $cols;
break;
endforeach; ?><tr>
<td><?php echo $a; ?></td>
<td class="text-center"><?php echo $a; ?></td>
<td><?php echo $TableRow->title; ?></td>
<!-- <td><?php //echo getFieldfromValue("tbl_units", "title", "unit_id", $TableRow->units_id); ?></td> -->
<td><?php echo $TableRow->description; ?></td>
<td>
<td class="text-center">
<?php showEditButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/edit/$id"); ?>
<?php showDeleteButton($id); ?>
</td>

View File

@ -38,7 +38,7 @@
<!--COL START-->
<div class="col-6">
<div class="form-group">
<?php fillComboWithValue("units_id", "Units", "units_id", "tbl_units", "title", "unit_id", isset($item) ? $item->units_id : '',); ?>
<?php fillComboWithValue("units_id", "Units <span class='text-danger'>*</span>", "units_id", "tbl_units", "title", "unit_id", isset($item) ? $item->units_id : '', "", false, "", true); ?>
</div>
</div>
<!--COL END-->
@ -47,7 +47,7 @@
<!--COL START-->
<div class="col">
<div class="form-group">
<?php fillComboWithValue("itemcategories_id", "Group", "itemcategories_id", "tbl_itemcategories", "title", "itemcategory_id", isset($item) ? $item->itemcategories_id : ''); ?>
<?php fillComboWithValue("itemcategories_id", "Group <span class='text-danger'>*</span>", "itemcategories_id", "tbl_itemcategories", "title", "itemcategory_id", isset($item) ? $item->itemcategories_id : '', "", false, "", true); ?>
</div>
</div>
<!--COL END-->
@ -117,7 +117,7 @@
<table class="table table-bordered table-striped longdataTable">
<thead>
<tr>
<th width="5%"><?php myLang('S.N'); ?></th>
<th width="5%" class="text-center"><?php myLang('S.N'); ?></th>
<th width="25%"><?php myLang('Name'); ?></th>
<th width="10%"><?php myLang('Code'); ?></th>
<th width="10%"><?php myLang('Units'); ?></th>
@ -125,7 +125,7 @@
<th width="10%" class="text-right"><?php myLang('Qty'); ?></th>
<th width="10%" class="text-right"><?php myLang('Rate'); ?></th>
<th width="10%" class="text-right"><?php myLang('Total'); ?></th>
<td width="10%" class="text-bold"><?php myLang("Action"); ?></th>
<td width="7%" class="col-1 text-bold text-center"><?php myLang("Action"); ?></th>
</tr>
</thead>
<tbody>
@ -134,15 +134,18 @@
<?php foreach ($TableRow as $cols) : $id = $cols;
break;
endforeach; ?><tr>
<td><?php echo $a; ?></td>
<td class="text-center"><?php echo $a; ?></td>
<td><?php echo $TableRow->title; ?></td>
<td><?php echo $TableRow->item_code; ?></td>
<td><?php echo getFieldfromValue("tbl_units", "title", "unit_id", $TableRow->units_id); ?></td>
<td><?php echo number_format((int)getFieldfromValue("tbl_units", "title", "unit_id", $TableRow->units_id),2); ?></td>
<td><?php echo getFieldfromValue("tbl_itemcategories", "title", "itemcategory_id", $TableRow->itemcategories_id); ?></td>
<td class="text-right"><?php echo $TableRow->Stock->qty; ?></td>
<td class="text-right"><?php echo $TableRow->Stock->rate; ?></td>
<td class="text-right"><?php echo $TableRow->Stock->amount; ?></td>
<td>
<td class="text-right"><?php echo number_format((int)$TableRow->Stock->qty,2); ?></td>
<td class="text-right"><?php echo number_format((int)$TableRow->Stock->rate,2); ?></td>
<td class="text-right"><?php echo number_format((int)$TableRow->Stock->amount,2); ?></td>
<td class="text-center">
<?php showEditButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/edit/$id"); ?>
<?php showDeleteButton($id); ?>
</td>

View File

@ -143,6 +143,7 @@
<th class="text-right">Qty</th>
<th class="text-right">Units</th>
<th class="text-right">Rate</th>
<th class="text-right" width=13%>VAT<span class="text-danger">*</span></th>
<th class="text-right">Amount</th>
<th></th>
</tr>
@ -154,6 +155,8 @@
<td width=10%> <input type="text" class="form-control input-group-sm" name="quantity[]"></td>
<td width=5%><input type="text" class="form-control item_unit" name="pcs/dozen/kgs" required> </td>
<td width=15%><input type="text" class="form-control" name="rate[]"></td>
<td><input type="number" name="vat[]" class="form-control vat" required></td>
<td width=15%><input type="text" class="form-control" name="total[]"></td>
<td width="5%">
<button type="button" class="btn btn-primary btn-xs addPurchaseDetail" id="addPurchaseDetail">
@ -174,9 +177,9 @@
<br>
<br>
<label for="vatToggle">VAT</label>
<input type="checkbox" id="vatToggle" checked>
<input type="hidden" id="vatToggleValue" name="vatToggleValue" value="1">
<label for="vatToggle" class="d-none">VAT</label>
<input class="d-none" type="checkbox" id="vatToggle" checked>
<input type="hidden" class="d-none" id="vatToggleValue" name="vatToggleValue" value="1">
</td>
<td class="text-right "><b>Total Amount</b></td>
<td class="text-right">
@ -198,11 +201,13 @@
</tr>
<tr>
<td class="text-right "><b>13% VAT</b></td>
<td class="text-right">
<td class="text-right d-none "><b>13% VAT</b></td>
<td class="text-right d-none">
<input type="text" class="form-control" name="tax" id="tax" />
</td>
<td></td>
<td>
<input type="hidden" name="vat_checkbox_value" id="vat_checkbox_value" value="0">
</td>
</tr>
<tr>
<td class="text-right "><b>Grand Total Amount</b></td>
@ -404,7 +409,7 @@
calculateTotals();
});
// Calculate totals on change of rate or quantity
$(document).on("change", ".purchase-detail input[name^='quantity'], .purchase-detail input[name^='rate']", function() {
$(document).on("change", ".purchase-detail input[name^='quantity'], .purchase-detail input[name^='rate'],.purchase-detail input[name^='vat']", function() {
calculateRowTotal($(this).closest(".purchase-detail"));
calculateTotals();
});
@ -419,6 +424,9 @@
calculateTotals('amount');
});
});
function updateSerialNumbers(){
$('.purchase-detail').each(function(index){
$(this).find('.bbsn').text(index + 1);
@ -429,7 +437,15 @@
function calculateRowTotal(row) {
var quantity = parseFloat(row.find("input[name^='quantity']").val()) || 0;
var rate = parseFloat(row.find("input[name^='rate']").val()) || 0;
var total = quantity * rate;
var vat = parseFloat(row.find('input[name^="vat"]').val()) || 0;
//
var lineTotal = quantity * rate;
var vat_amt =(vat/100)*lineTotal;
var total =lineTotal + vat_amt ;
//
// var total = quantity * rate;
row.find("input[name^='total']").val(total.toFixed(2));
}
// Calculate totals
@ -441,10 +457,8 @@
});
if(type=='amount'){
alert("amount");
discountamount = parseFloat($("input[name='discount']").val());
discountpercent = (discountamount * 100) / subtotal;
alert(discountamount);
$("#discountpercentage").val(discountpercent.toFixed(2));
}else{
discountpercent = parseFloat($("input[name='discountpercentage']").val());
@ -455,18 +469,19 @@
// var discountamount = subtotal * (discountpercent/100);
var taxable = subtotal - discountamount;
var tax = 0;
if ($('#vatToggle').is(':checked')) {
tax = taxable * 0.13; // Include 13% VAT if checkbox is checked
}
var grandTotal = taxable + tax;
// if ($('#vatToggle').is(':checked')) {
// tax = taxable * 0.13; // Include 13% VAT if checkbox is checked
// }
// var grandTotal = taxable + tax;
var grandTotal = taxable;
$("#subtotal").val(subtotal.toFixed(2));
// $("#discount").val(discountamount.toFixed(2));
$("#taxable").val(taxable.toFixed(2));
$("#tax").val(tax.toFixed(2));
$("#grand_total").val(grandTotal.toFixed(2));
}
});
};
</script>
<?php function footerFunctions()

View File

@ -12,12 +12,11 @@
<table class="table table-bordered table-striped dataTable">
<thead>
<tr>
<th><?php myLang('S.N'); ?></th>
<th class="text-center"><?php myLang('S.N'); ?></th>
<th><?php myLang('Date'); ?></th>
<th><?php myLang('Purchase Transaction'); ?></th>
<th><?php myLang('Amount'); ?></th>
<td><b>Action</b></th>
<th class="text-center"><?php myLang('Amount'); ?></th>
<td class="text-center"><b>Action</b></th>
</tr>
</thead>
<tbody>
@ -28,11 +27,12 @@
endforeach; ?><tr>
<td><?php echo $TableRow->purchase_ref; ?></td>
<td><?php echo $TableRow->purchase_date; ?></td>
<td><b><?php echo $this->myaccounts->getAccountDetails($TableRow->accounts_id)->account_name; ?></b>
<td><b><?php echo (($this->myaccounts->getAccountDetails($TableRow->accounts_id)->account_name ?? "")); ?></b>
<div class="row ml-2 mr-2" style="border-bottom: 1px solid;">
<span class="col item_name"><?php echo myLang("Particulars") ?></span>
<span class="col item_qty"><?php echo myLang("Qty") ?></span>
<span class="col item_rate"><?php echo myLang("Rate") ?></span>
<span class="col item_vat"><?php echo myLang("vat") ?></span>
<span class="col item_amount"><?php echo myLang("Amount") ?></span>
</div>
<?php $l = 0;
@ -40,8 +40,9 @@
<div class="row ml-2 mr-2">
<span class="col item_name"><?php echo $r->Item->title; ?></span>
<span class="col item_qty"><?php echo $r->qty; ?></span>
<span class="col item_rate text-right"><?php echo myCurrency($r->rate, true); ?></span>
<span class="col item_amount text-right"><?php echo myCurrency($r->qty * $r->rate, true); ?></span>
<span class="col item_rate"><?php echo myCurrency($r->rate, true); ?></span>
<span class="col item_vat"><?php echo myCurrency($r->vat, true); ?></span>
<span class="col item_amount"><?php echo myCurrency($r->qty * $r->rate, true); ?></span>
</div>
<?php endforeach; ?>
<div class="row ml-2 mr-2" style="border-top: 1px dotted;">
@ -52,9 +53,7 @@
</div>
</td>
<td><?php echo myCurrency($TableRow->TotalPurchase); ?></td>
<td><?php showDetailsButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/details/$id"); ?>
<td class="text-center"><?php showDetailsButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/details/$id"); ?>
<?php showDeleteButton($id); ?>
</td>
</tr>

View File

@ -5,31 +5,100 @@
<div class="col">
<div class="card card-primary card-outline">
<div class="card-header">
<h5 class="m-0"><?php echo $pageTitle; ?> <?php showCreateButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/add", "Create New " . $pageTitle); ?></h5>
<!-- <h5 class="m-0"><?php echo $pageTitle; ?> <?php showCreateButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/add", "Create New " . $pageTitle); ?></h5> -->
</div>
<form class="ml-4" method="post" action="<?php echo base_url('accounts/reports/pl'); ?>" id="FilterForm">
<!-- button with a dropdown -->
<div class="btn-group">
<button type="button" class="btn btn-success btn-sm dropdown-toggle" data-toggle="dropdown" data-offset="-52">
Filters
</button>
<div class="dropdown-menu" role="menu">
<div class="form-group p-2 pb-0">
<div class="col">
<div class="form-group">
<label for="fromDate"><?php myLang("Starting Period"); ?></label>
<input type="text" class="form-control " name="fromDate" value="<?php echo (isset($_POST['fromDate'])) ? $_POST['fromDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_from); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="fromDate" aria-describedby="helpId_fromDate" placeholder="Starting Period">
</div>
<div class="form-group">
<label for="toDate"><?php myLang("Ending Period"); ?></label>
<input type="text" class="form-control " name="toDate" value="<?php echo (isset($_POST['toDate'])) ? $_POST['toDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_to); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="toDate" aria-describedby="helpId_toDate" placeholder="Ending Period">
</div>
</div>
<div class="dropdown-divider"></div>
<!-- <div class="form-check">
<input class="form-check-input" type="checkbox">
<label class="form-check-label">Select
All</label>
</div> -->
<div class="form-check">
<!-- <input type="hidden" name="showOB" value="not"> -->
<input type="checkbox" class="form-check-input " name="showOB" id="showOB" aria-describedby="helpId_showOB" placeholder="Show Opening Balance" <?php echo (isset($_POST['showOB'])) ? "CHECKED" : ""; ?>>
<!-- <input class="form-check-input" type="checkbox"> -->
<label class="form-check-label" for="showOB">Opening</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox"> -->
<input type="checkbox" class="form-check-input " name="showClosing" id="showClosing" aria-describedby="helpId_showClosing" placeholder="Show Closing Balance" <?php echo (isset($_POST['showClosing'])) ? "CHECKED" : ""; ?>>
<label class="form-check-label" for="showClosing">Closing</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox" checked> -->
<input type="checkbox" class="form-check-input" name="showPeriod" id="showPeriod" aria-describedby="helpId_showPeriod" placeholder="Show Periodic Balance" <?php echo (isset($_POST['showPeriod'])) ? "CHECKED" : "CHECKED"; ?>>
<label class="form-check-label" for="showPeriod">Period</label>
</div>
</div>
<div class="dropdown-divider"></div>
<div class="form-group p-2 pb-0 text-right">
<button type="button" class="btn btn-info btn-sm " style="width:60px;height:30px;" onclick="resetForm()">Reset</button>
<button type="submit" class="btn btn-primary mr-2 btn-sm" style="width:60px;height:30px;">Search </button>
</div>
</div>
</div>
<div class="btn-group">
<!-- <button type="submit" class="btn btn-warning btn-sm " data-toggle="dropdown" data-offset="-52">
Export
</button> -->
<!-- <button type="submit" onclick="exportTableToCSV('accounts_data.csv')" class="btn btn-warning btn-sm " data-toggle="dropdown" data-offset="-52">
Export
</button> -->
<button type="submit" id="downloadCsv" class="btn btn-warning btn-sm ">
Export csv
</button>
<!-- <div class="dropdown-menu" role="menu">
<a href="#" class="dropdown-item">Export</a>
<a href="#" class="dropdown-item">Pdf</a>
<div class="dropdown-divider"></div>
<a href="#" class="dropdown-item">View calendar</a>
</div> -->
</div>
<button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle Collapse</button>
</form>
<div class="card-body">
<?php $TableData = $this->db->query("select * from tbl_purchases where status=1")->result(); ?>
<table class="table table-bordered table-striped dataTable">
<table class="table table-bordered table-striped dataTable" id="myTable">
<thead>
<tr>
<th><?php myLang('S.N'); ?></th>
<th><?php myLang('Date'); ?></th>
<th><?php myLang('Purchase Transaction'); ?></th>
<th><?php myLang('Amount'); ?></th>
<th width="3%" class="text-center"><?php myLang('S.N'); ?></th>
<th width="10%" class="col-1"><?php myLang('Date'); ?></th>
<th class="table-col col-9"><?php myLang('Purchase Transaction'); ?></th>
<th width="8%" class="col-2"><?php myLang('Amount'); ?></th>
<td><b>Action</b></th>
<td class="col-1 text-center"><b>Action</b></th>
</tr>
</thead>
<tbody>
<?php $a = 0;
$n = 0;
foreach ($PurchaseRecords as $TableRow) : $a++;
$id = $TableRow->purchase_id; ?>
<tr>
<td><?php echo $TableRow->purchase_ref; ?></td>
<td><?php echo ++$n; ?></td>
<td><?php echo $TableRow->purchase_date; ?></td>
<td><?php echo $this->myaccounts->getAccountDetails($TableRow->accounts_id)->account_name; ?></td>
<td><?php echo ($this->myaccounts->getAccountDetails($TableRow->accounts_id)->account_name) ?? ""; ?></td>
<td><?php echo myCurrency($TableRow->TotalPurchase); ?></td>
<td><?php showDetailsButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/details/$id"); ?>
<td class="text-center"><?php showDetailsButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/details/$id"); ?>
<?php showDeleteButton($id); ?>
</td>
</tr>
@ -50,3 +119,40 @@
</div>
</div>
</div>
<!-- pdf document -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.0/xlsx.full.min.js"></script>
<script>
document.getElementById('downloadCsv').addEventListener('click', function() {
const table = document.getElementById('myTable');
const rows = Array.from(table.rows);
const data = [];
rows.forEach((row) => {
const cells = Array.from(row.cells);
const rowData = [];
cells.forEach((cell) => {
// Handle colspan
const colspan = cell.colSpan || 1;
for (let i = 0; i < (colspan - 1); i++) {
rowData.push(''); // Fill empty cells for merged columns
}
for (let i = 0; i < 1; i++) {
rowData.push(cell.innerText.trim());
}
// Fill empty cells for colspan
});
data.push(rowData);
});
// Create a worksheet
const worksheet = XLSX.utils.aoa_to_sheet(data);
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
// Export to Excel
XLSX.writeFile(workbook, 'table.xlsx');
});
</script>
<!-- pdf document ends-->

View File

@ -7,11 +7,11 @@
<div class="card card-primary card-outline">
<div class="card-header">
<!-- <button class="btn btn-primary btn-xs float-right" style="margin-left: 2px;" onclick="printDiv('printableArea')"><i class="fas fa-print"></i></button> -->
<h5 class="m-0"><?php echo $pageTitle; ?> <?php showCreateButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/add","Create New ".$pageTitle); ?></h5>
</div>
<div id="printableArea">
<div class="card-body">
<div class="row bill-header">
@ -23,7 +23,7 @@
<div class="col">
<p><strong>Bill Number:</strong> <?php echo $Purchase->purchase_id; ?></p>
<p><strong>Date:</strong> <?php echo dbDate($Purchase->purchase_date); ?></p>
<p><strong>Vendor:</strong> <?php echo $this->myaccounts->getAccountDetails($Purchase->accounts_id)->account_name; ?></p>
<p><strong>Vendor:</strong> <?php echo (($this->myaccounts->getAccountDetails($Purchase->accounts_id)->account_name ?? "")); ?></p>
</div>
</div>
@ -40,6 +40,9 @@
<div class="col">
<p class="text-right"><strong>Price</strong></p>
</div>
<div class="col">
<p class="text-right"><strong>VAT</strong></p>
</div>
<div class="col">
<p class="text-right"><strong>Total</strong></p>
</div>
@ -58,7 +61,10 @@
<p><?php $rate=$PurchaseDetail->rate; echo myCurrency($rate); ?></p>
</div>
<div class="col">
<p><?php $ltotal=$rate*$qty; $total+=$ltotal; echo myCurrency($ltotal); ?></p>
<p><?php $vat=$PurchaseDetail->vat; echo myCurrency($vat); ?></p>
</div>
<div class="col">
<p><?php $ltotal=$rate*$qty*((100-$vat)/100); $total+=$ltotal; echo myCurrency($ltotal); ?></p>
</div>
</div>
</div>
@ -88,11 +94,24 @@
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
function printDiv(divName) {
var printContents = document.getElementById(divName).innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
}
</script>

View File

@ -45,7 +45,9 @@
<?php $PTotal = 0;
$a = 0;
foreach ($PurchaseDetails as $Purchase) : $a++; ?>
<?php// var_dump($Purchase->Item->title);die(); ?>
<tr>
<td><?php echo $a; ?></td>
<td><?php echo $Purchase->Item->title; ?></td>
<td class="text-right"><?php echo $Purchase->total_qty; ?></td>
@ -184,8 +186,9 @@
<?php $a = 0;
foreach ($StockItems as $Stock) : $a++; ?>
<tr>
<td><?php echo $a; ?></td>
<td><?php echo $Stock->Item->title; ?></td>
<td class="text-center"><?php echo $a; ?></td>
<?php //echo "<pre>";print_r($Stock->Summary->Item->title); die() ;?>
<td><?php echo $Stock->Summary->Item->title; ?></td>
<td><?php echo $Stock->Summary->Unit->title; ?></td>
<td class="text-right"><?php echo $oqty = $Stock->Summary->Opening->qty; ?></td>
<td class="text-right"><?php echo myCurrency($orate = $Stock->Summary->Opening->rate); ?></td>

View File

@ -49,6 +49,7 @@
<th width=50%>Items <span class="text-danger">*</span></th>
<th class="text-center" width=5%>Qty <span class="text-danger">*</span></th>
<th class="text-center" width=5%>Units</th>
<th class="text-center" width=13%>VAT<span class="text-danger">*</span></th>
<th class="text-center" width=13%>Rate <span class="text-danger">*</span></th>
<th class="text-right" width=20%>Amount</th>
<th width=5%></th>
@ -65,7 +66,9 @@
</select></td>
<td> <input type="text" class="form-control input-group-sm" name="qty[]" required></td>
<td><input type="text" class="form-control item_unit" name="pcs/dozen/kgs" required> </td>
<td><input type="number" name="vat[]" class="form-control vat" required></td>
<td><input type="text" class="form-control" name="rate[]" required></td>
<span class="total-price"></span>
<td><input type="text" class="form-control" name="ltotal[]" required></td>
<td>
<button type="button" class="btn btn-primary btn-xs add-row">
@ -98,10 +101,13 @@
<td></td>
</tr>
<tr>
<td class="text-right "><b>13% VAT</b></td>
<td class="text-right">
<td class="text-right d-none"><b><input type="checkbox" name="vat_checkbox" id="vat_checkbox"
>13% VAT</b></td>
<td class="text-right d-none">
<input type="text" class="form-control" id="tax">
<td></td>
<input type="hidden" name="vat_checkbox_value" id="vat_checkbox_value" value="0">
</tr>
<tr>
<td class="text-right "><b>Grand Total Amount</b></td>
@ -147,7 +153,7 @@
}
});
$(document).on('input', '.sales-detail-duplicator input[name^="qty"], .sales-detail-duplicator input[name^="rate"]', function() {
$(document).on('input', '.sales-detail-duplicator input[name^="qty"],.sales-detail-duplicator input[name^="vat"], .sales-detail-duplicator input[name^="rate"]', function() {
calculateLineTotal($(this).closest('tr'));
calculateTotals();
});
@ -161,7 +167,10 @@
calculateLineTotal($(this).closest("tr"));
calculateTotals('amount');
});
$(document).on("change", "input[name=vat_checkbox]", function() {
calculateLineTotal($(this).closest("tr"));
calculateTotals('vat');
});
function updateSerialNumbers() {
$('.purchase-detail').each(function(index) {
$(this).find('.bbsn').text(index + 1);
@ -172,9 +181,13 @@
function calculateLineTotal(row) {
var quantity = parseFloat(row.find('input[name^="qty"]').val());
var rate = parseFloat(row.find('input[name^="rate"]').val());
if (!isNaN(quantity) && !isNaN(rate)) {
var vat = parseFloat(row.find('input[name^="vat"]').val());
if (!isNaN(quantity) && !isNaN(rate) && !isNaN(vat)) {
var lineTotal = quantity * rate;
row.find("input[name^='ltotal[]']").val(lineTotal.toFixed(2));
var vat_amt =(vat/100)*lineTotal;
var ltotal =lineTotal + vat_amt ;
console.log(lineTotal,vat_amt,ltotal);
row.find("input[name^='ltotal[]']").val(ltotal.toFixed(2));
}
@ -239,27 +252,39 @@
});
var discountamount = 0;
var discountpercent = 0;
var tax_percentage =0;
if (type == 'amount') {
alert("amount");
discountamount = parseFloat($("input[name='discount']").val());
discountpercent = (discountamount * 100) / subtotal;
alert(discountamount);
$("#discountpercentage").val(discountpercent.toFixed(2));
} else if(type == 'vat'){
checkBox = $("input[name='vat_checkbox_value']").val();
if(checkBox == "0"){
// if(checkBox){
tax_percentage= 0.13;
$("input[name='vat_checkbox_value']").val('13');
}else{
tax_percentage =0;
$("input[name='vat_checkbox_value']").val('0');
}
// }
}
else {
discountpercent = parseFloat($("input[name='discountpercentage']").val());
discountamount = subtotal * (discountpercent / 100);
$("#discount").val(discountamount.toFixed(2));
}
var taxable = subtotal - discountamount;
var tax = taxable * 0.13;
var grandTotal = taxable + tax;
var tax = taxable * tax_percentage;
// var grandTotal = taxable + tax;
var grandTotal = taxable;
$('#subtotal').val(subtotal.toFixed(2));
$("#taxable").val(taxable.toFixed(2));
$('#tax').val(tax.toFixed(2));
$('#grandtotal').val(grandTotal.toFixed(2));
}
</script>
<?php function footerFunctions()

View File

@ -12,23 +12,24 @@
<table class="table table-bordered table-striped dataTable">
<thead>
<tr>
<th class="table-col col-1"><?php myLang('Sales Voucher #'); ?></th>
<th class="table-col col-1 text-center"><?php myLang('Sales Voucher #'); ?></th>
<th width="10%"><?php myLang('Date'); ?></th>
<th><?php myLang('Transaction'); ?></th>
<th class="table-col col-1"><?php myLang('Amount'); ?></th>
<th class="table-col col-1"><?php myLang('Action'); ?></th>
<th class="table-col col-1 text-center"><?php myLang('Amount'); ?></th>
<th class="table-col col-1 text-center"><?php myLang('Action'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($SalesRecords as $TableRow) : ?>
<tr>
<td><?php echo $TableRow->sales_id; ?></td>
<td class="text-center"><?php echo $TableRow->sales_id; ?></td>
<td><?php echo $TableRow->sales_date; ?></td>
<td><b><?php echo $this->myaccounts->getAccountDetails($TableRow->accounts_id)->account_name; ?></b>
<td><b><?php echo (($this->myaccounts->getAccountDetails($TableRow->accounts_id)->account_name) ?? ""); ?></b>
<div class="row ml-2 mr-2" style="border-bottom: 1px solid;">
<span class="col item_name"><?php echo myLang("Particulars") ?></span>
<span class="col item_qty"><?php echo myLang("Qty") ?></span>
<span class="col item_rate"><?php echo myLang("Rate") ?></span>
<span class="col item_vat"><?php echo myLang("VAT") ?></span>
<span class="col item_amount"><?php echo myLang("Amount") ?></span>
</div>
<?php $l = 0;
@ -36,8 +37,9 @@
<div class="row ml-2 mr-2">
<span class="col item_name"><?php echo $r->Item->title; ?></span>
<span class="col item_qty"><?php echo $r->qty; ?></span>
<span class="col item_rate text-right"><?php echo myCurrency($r->rate, true); ?></span>
<span class="col item_amount text-right"><?php echo myCurrency($r->qty * $r->rate, true); ?></span>
<span class="col item_rate"><?php echo myCurrency($r->rate, true); ?></span>
<span class="col item_vat"><?php echo myCurrency($r->vat, true); ?></span>
<span class="col item_amount"><?php echo myCurrency($r->qty * $r->rate, true); ?></span>
</div>
<?php endforeach; ?>
<div class="row ml-2 mr-2" style="border-top: 1px dotted;">
@ -48,7 +50,7 @@
</div>
</td>
<td><?php echo myCurrency($TableRow->totalsales); ?></td>
<td><?php showDetailsButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/details/$TableRow->sales_id"); ?>
<td class="text-center"><?php showDetailsButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/details/$TableRow->sales_id"); ?>
<?php showDeleteButton($TableRow->sales_id); ?>
</td>
</tr>

View File

@ -5,31 +5,87 @@
<div class="col">
<div class="card card-primary card-outline">
<div class="card-header">
<h5 class="m-0"><?php echo $pageTitle; ?> <a href="<?php echo site_url($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/create"); ?>" class="btn btn-sm btn-primary float-right">Create New <?php echo $pageTitle; ?></a></h5>
<h5 class="m-0 card-title"><?php echo $pageTitle; ?> </h5><a href="<?php echo site_url($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/create"); ?>" class="btn btn-sm btn-primary float-right">Create New <?php echo $pageTitle; ?></a>
<!-- Filter Start -->
<form method="post" action="" id="FilterForm">
<!-- button with a dropdown -->
<div class="btn-group">
<button type="button" class="btn btn-success btn-sm dropdown-toggle" data-toggle="dropdown" data-offset="-52">
Filters
</button>
<div class="dropdown-menu" role="menu">
<div class="form-group p-2 pb-0">
<div class="col">
<div class="form-group">
<label for="fromDate"><?php myLang("Starting Period"); ?></label>
<input type="text" class="form-control " name="fromDate" value="<?php echo (isset($_POST['fromDate'])) ? $_POST['fromDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_from); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="fromDate" aria-describedby="helpId_fromDate" placeholder="Starting Period">
</div>
<div class="form-group">
<label for="toDate"><?php myLang("Ending Period"); ?></label>
<input type="text" class="form-control " name="toDate" value="<?php echo (isset($_POST['toDate'])) ? $_POST['toDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_to); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="toDate" aria-describedby="helpId_toDate" placeholder="Ending Period">
</div>
</div>
<div class="dropdown-divider"></div>
<div class="form-check">
<!-- <input type="hidden" name="showOB" value="not"> -->
<input type="checkbox" class="form-check-input " name="showOB" id="showOB" aria-describedby="helpId_showOB" placeholder="Show Opening Balance" <?php echo (isset($_POST['showOB'])) ? "CHECKED" : ""; ?>>
<!-- <input class="form-check-input" type="checkbox"> -->
<label class="form-check-label" for="showOB">Opening</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox"> -->
<input type="checkbox" class="form-check-input " name="showClosing" id="showClosing" aria-describedby="helpId_showClosing" placeholder="Show Closing Balance" <?php echo (isset($_POST['showClosing'])) ? "CHECKED" : ""; ?>>
<label class="form-check-label" for="showClosing">Closing</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox" checked> -->
<input type="checkbox" class="form-check-input" name="showPeriod" id="showPeriod" aria-describedby="helpId_showPeriod" placeholder="Show Periodic Balance" <?php echo (isset($_POST['showPeriod'])) ? "CHECKED" : "CHECKED"; ?>>
<label class="form-check-label" for="showPeriod">Period</label>
</div>
</div>
<div class="dropdown-divider"></div>
<div class="form-group p-2 pb-0 text-right">
<button type="button" class="btn btn-info btn-sm " style="width:60px;height:30px;" onclick="resetForm()">Reset</button>
<button type="submit" class="btn btn-primary mr-2 btn-sm" style="width:60px;height:30px;">Search </button>
</div>
</div>
</div>
<div class="btn-group">
<button type="submit" id="downloadCsv" class="btn btn-warning btn-sm ">
Export csv
</button>
</div>
<!-- <button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle Collapse</button> -->
</form>
<!-- Filter Ends -->
</div>
<div class="card-body">
<?php $TableData = $this->db->query("select * from tbl_sales where status=1")->result(); ?>
<table class="table table-bordered table-striped dataTable">
<table class="table table-bordered table-striped dataTable" id='myTable'>
<thead>
<tr>
<th class="table-col col-1"><?php myLang('Sales Voucher #'); ?></th>
<th width="10%"><?php myLang('Date'); ?></th>
<th class=" col-1 text-center"><?php myLang('ID'); ?></th>
<th class=" col-1 text-center"><?php myLang('Sales Voucher #'); ?></th>
<th class=" col-1 text-center"><?php myLang('Item'); ?></th>
<th class="col-1"><?php myLang('Date'); ?></th>
<th><?php myLang('Transaction'); ?></th>
<th class="table-col col-1"><?php myLang('Amount'); ?></th>
<th class="table-col col-1"><?php myLang('Action'); ?></th>
<th class="table-col col-1 text-center"><?php myLang('Amount'); ?></th>
<th class="text-center" width="5%"> <?php myLang('Action'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($SalesRecords as $TableRow) : ?>
<?php $n = 0; ?>
<?php foreach ($SalesRecords as $key => $TableRow) : ?>
<tr>
<td><?php echo $TableRow->sales_id; ?></td>
<td class="text-center"><?php echo ++$n; ?></td>
<td class="text-center"><?php echo $TableRow->sales_id; ?></td>
<td class="text-center"><?php echo ($TableRow->Details[$key]->Item->title) ?? ""; ?></td>
<td><?php echo $TableRow->sales_date; ?></td>
<td><?php echo $this->myaccounts->getAccountDetails($TableRow->accounts_id)->account_name; ?>
<td><?php echo (($this->myaccounts->getAccountDetails($TableRow->accounts_id)->account_name) ?? ""); ?>
</td>
<td><?php echo myCurrency($TableRow->totalsales); ?></td>
<td><?php showDetailsButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/details/$TableRow->sales_id"); ?>
<td class="text-center"><?php showDetailsButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/details/$TableRow->sales_id"); ?>
<?php showDeleteButton($TableRow->sales_id); ?>
</td>
</tr>
@ -50,3 +106,40 @@
</div>
</div>
</div>
<!-- pdf document -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.0/xlsx.full.min.js"></script>
<script>
document.getElementById('downloadCsv').addEventListener('click', function() {
const table = document.getElementById('myTable');
const rows = Array.from(table.rows);
const data = [];
rows.forEach((row) => {
const cells = Array.from(row.cells);
const rowData = [];
cells.forEach((cell) => {
// Handle colspan
const colspan = cell.colSpan || 1;
for (let i = 0; i < (colspan - 1); i++) {
rowData.push(''); // Fill empty cells for merged columns
}
for (let i = 0; i < 1; i++) {
rowData.push(cell.innerText.trim());
}
// Fill empty cells for colspan
});
data.push(rowData);
});
// Create a worksheet
const worksheet = XLSX.utils.aoa_to_sheet(data);
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
// Export to Excel
XLSX.writeFile(workbook, 'table.xlsx');
});
</script>
<!-- pdf document ends-->

View File

@ -7,11 +7,11 @@
<div class="card card-primary card-outline">
<div class="card-header">
<!-- <button class="btn btn-primary btn-xs float-right" style="margin-left: 2px;" onclick="printDiv('printableArea')"><i class="fas fa-print"></i></button> -->
<h5 class="m-0"><?php echo $pageTitle; ?> <a href="<?php echo site_url($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/create"); ?>" class="btn btn-sm btn-primary float-right">Create New <?php echo $pageTitle; ?></a></h5>
</div>
<div id="printableArea">
<div class="card-body">
<div class="row bill-header">
@ -23,7 +23,7 @@
<div class="col">
<p><strong>Bill Number:</strong> <?php echo $Sales->sales_id; ?></p>
<p><strong>Date:</strong> <?php echo dbDate($Sales->sales_date); ?></p>
<p><strong>Vendor:</strong> <?php echo $this->myaccounts->getAccountDetails($Sales->accounts_id)->account_name; ?></p>
<p><strong>Vendor:</strong> <?php echo (($this->myaccounts->getAccountDetails($Sales->accounts_id)->account_name ?? "")); ?></p>
</div>
</div>
@ -40,6 +40,9 @@
<div class="col text-right">
<p><strong>Price</strong></p>
</div>
<div class="col text-right">
<p><strong>VAT</strong></p>
</div>
<div class="col text-right">
<p><strong>Total</strong></p>
</div>
@ -57,6 +60,9 @@
<div class="col">
<p><?php $rate=$SalesDetail->rate; echo myCurrency($rate); ?></p>
</div>
<div class="col">
<p><?php $vat=($SalesDetail->vat); echo myCurrency($vat); ?></p>
</div>
<div class="col">
<p><?php $ltotal=$rate*$qty; $total+=$ltotal; echo myCurrency($ltotal); ?></p>
</div>
@ -80,12 +86,13 @@
<?php //print_r($Purchase->vatToggle);die; ?>
<!-- <?php //if($Sales->vatToggle != 1): ?> -->
<p><strong>Taxable amount:</strong> <?php echo myCurrency($taxable,true); ?></p>
<p><strong>Tax (13%):</strong> <?php echo myCurrency($tax=($taxable*13)/100,true); ?></p>
<!-- <p><strong>Tax (13%):</strong> <?php echo myCurrency($tax=($taxable*13)/100,true); ?></p> -->
<!-- <?php //endif; ?> -->
<p><strong>Total:</strong> <?php echo myCurrency(($taxable+$tax),true); ?></p>
</div>
</div>
<!-- <p><strong>Total:</strong> <?php echo myCurrency(($taxable+$tax),true); ?></p> -->
<p><strong>Total:</strong> <?php echo myCurrency(($taxable),true); ?></p>
</div>
</div>
</div>
</div>
@ -94,3 +101,4 @@
</div>
</div>
</div>
</div>

View File

@ -2,21 +2,14 @@
<!-- <div class="content">
<div class="container-fluid">
<div class="card card-primary ">
<div class="card-header">
<h3 class="card-title"><?php //echo $pageTitle;
?> </h3>
<div class="card-tools">
<button type="button" class="btn btn-tool" data-card-widget="collapse"><i class="fas fa-plus"></i>
</button>
</div>
</div>
<div class="card-body">
<form method="post" action="" id="FilterForm">
<div class="row align-items-end">
@ -62,7 +55,6 @@
</div>
<div class="col">
<div class="form-group d-flex justify-content-end">
<button type="submit" class="btn btn-primary mr-2">Choose</button>
<button type="submit" class="btn btn-primary mr-2">Filter</button>
<button type="submit" class="btn btn-success mr-2">Export</button>
@ -70,7 +62,6 @@
</div>
</div>
</div>
</form>
<script>
function resetForm() {
@ -89,10 +80,7 @@
</div>
</div>
</div> -->
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col">
@ -100,68 +88,77 @@
<div class="card-header">
<h5 class="card-title">
<?php echo $pageTitle; ?>
<!-- <?php //echo $pageTitle;
?> <a href="<?php //echo site_url("inventory/purchases/add");
?>" class="btn btn-sm btn-primary float-right">Create New <?php //echo $pageTitle;
?></a> -->
</h5>
<div class="card-tools">
<!-- test -->
<!-- test ends -->
<form method="post" action=<?php echo site_url('/Inventory/Stocks/summary'); ?> id="FilterForm">
<!-- button with a dropdown -->
<input type="hidden" name="stocklocations_id" value="1" />
<div class="btn-group">
<button type="button" class="btn btn-success btn-sm dropdown-toggle" data-toggle="dropdown" data-offset="-52">
Filters
</button>
<div class="dropdown-menu" role="menu">
<div class="form-group p-2 pb-0">
<div class="col">
<div class="form-group">
<label for="fromDate"><?php myLang("Starting Period"); ?></label>
<input type="text" class="form-control nepaliDatePicker" name="fromDate" value="<?php echo (isset($_POST['fromDate'])) ? $_POST['fromDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_from); ?>" id="fromDate" aria-describedby="helpId_fromDate" placeholder="Starting Period">
<input type="text" class="form-control " name="fromDate" value="<?php echo (isset($_POST['fromDate'])) ? $_POST['fromDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_from); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="fromDate" aria-describedby="helpId_fromDate" placeholder="Starting Period">
<!-- <input type="text" class="form-control " name="fromDate" value="" data-end="<?php echo $fiscalEnd; ?>" id="fromDate" aria-describedby="helpId_fromDate" placeholder="Starting Period"> -->
</div>
<div class="form-group">
<label for="toDate"><?php myLang("Ending Period"); ?></label>
<input type="text" class="form-control nepaliDatePicker" name="toDate" value="<?php echo (isset($_POST['toDate'])) ? $_POST['toDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_to); ?>" id="toDate" aria-describedby="helpId_toDate" placeholder="Ending Period">
<input type="text" class="form-control " name="toDate" value="<?php echo (isset($_POST['toDate'])) ? $_POST['toDate'] : NepaliDate($this->session->FiscalYear->fiscalyear_to); ?>" data-start="<?php echo $fiscalStart; ?>" data-end="<?php echo $fiscalEnd; ?>" id="toDate" aria-describedby="helpId_toDate" placeholder="Ending Period">
</div>
</div>
<div class="dropdown-divider"></div>
<div class="form-check">
<!-- <div class="form-check">
<input class="form-check-input" type="checkbox">
<label class="form-check-label">Select
All</label>
</div>
</div> -->
<div class="form-check">
<!-- <input type="hidden" name="showOB" value="not"> -->
<input type="checkbox" class="form-check-input " name="showOB" id="showOB" aria-describedby="helpId_showOB" placeholder="Show Opening Balance" <?php echo (isset($_POST['showOB'])) ? "CHECKED" : ""; ?>>
<!-- <input class="form-check-input" type="checkbox"> -->
<label class="form-check-label">Opening</label>
<label class="form-check-label" for="showOB">Opening</label>
StockRecords
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox"> -->
<input type="checkbox" class="form-check-input " name="showClosing" id="showClosing" aria-describedby="helpId_showClosing" placeholder="Show Closing Balance" <?php echo (isset($_POST['showClosing'])) ? "CHECKED" : ""; ?>>
<label class="form-check-label">Closing</label>
<label class="form-check-label" for="showClosing">Closing</label>
</div>
<div class="form-check">
<!-- <input class="form-check-input" type="checkbox" checked> -->
<input type="checkbox" class="form-check-input" name="showPeriod" id="showPeriod" aria-describedby="helpId_showPeriod" placeholder="Show Periodic Balance" <?php echo (isset($_POST['showPeriod'])) ? "CHECKED" : "CHECKED"; ?>>
<label class="form-check-label">Period</label>
<label class="form-check-label" for="showPeriod">Period</label>
</div>
</div>
<div class="dropdown-divider"></div>
<button type="submit" class="btn btn-primary mr-2 text-center">Search Now</button>
<div class="form-group p-2 pb-0 text-right">
<button type="button" class="btn btn-info btn-sm " style="width:60px;height:30px;" onclick="resetForm()">Reset</button>
<button type="submit" class="btn btn-primary mr-2 btn-sm" style="width:60px;height:30px;">Search </button>
</div>
</div>
</div>
<div class="btn-group">
<button type="button" class="btn btn-danger btn-sm " data-toggle="dropdown" data-offset="-52">
<!-- <button type="submit" class="btn btn-warning btn-sm " data-toggle="dropdown" data-offset="-52">
Export
</button> -->
<button type="submit" id="downloadCsv" class="btn btn-warning btn-sm ">
Export csv
</button>
<!-- <button class="btn btn-warning btn-sm " onclick="exportTableToCSV('accounts_data.csv')">Export to CSV</button> -->
<!-- <div class="dropdown-menu" role="menu">
<a href="#" class="dropdown-item">Export</a>
<a href="#" class="dropdown-item">Pdf</a>
@ -170,26 +167,33 @@
</div> -->
</div>
<!-- <button class="btn btn-secondary toggle-collapse btn-sm" id="toggleShowAll">Toggle Collapse</button> -->
</form>
<script>
function resetForm() {
document.getElementById("fromDate").value = "<?php echo NepaliDate($this->session->FiscalYear->fiscalyear_from); ?>";
document.getElementById("toDate").value = "<?php echo NepaliDate($this->session->FiscalYear->fiscalyear_to); ?>";
document.getElementById("showOB").checked = <?php echo "false"; ?>;
document.getElementById("showClosing").checked = <?php echo "false"; ?>;
document.getElementById("FilterForm").submit();
}
</script>
</div>
</div>
<div class="card-body">
<table class="table table-bordered table-striped dataTable">
<table id='myTable' class="table table-bordered table-striped dataTable">
<thead>
<tr>
<th rowspan="2"><?php myLang('Item'); ?></th>
<th rowspan="2" width="80"><?php myLang('Units'); ?></th>
<th rowspan="2" width="40" style="vertical-align: middle;"><?php myLang('S.No.'); ?></th>
<th rowspan="2" style="vertical-align: middle;"> <?php myLang('Item'); ?></th>
<th rowspan="2" width="80" style="vertical-align: middle;"><?php myLang('Units'); ?></th>
<th colspan="3" class="text-center"><?php myLang('Opening'); ?></th>
<th colspan="3" class="text-center"><?php myLang('Purchase'); ?></th>
<th colspan="3" class="text-center"><?php myLang('Sales'); ?></th>
<th colspan="3" class="text-center"><?php myLang('Closing'); ?></th>
</tr>
<tr>
<th class="text-center" width="80"><?php myLang('Qty'); ?></th>
<th class="text-center" width="80"><?php myLang('Avg. Rate'); ?></th>
<th class="text-center" width="80"><?php myLang('Amount'); ?></th>
@ -202,17 +206,20 @@
<th class="text-center" width="80"><?php myLang('Qty'); ?></th>
<th class="text-center" width="80"><?php myLang('Avg. Rate'); ?></th>
<th class="text-center" width="80"><?php myLang('Amount'); ?></th>
</tr>
</thead>
<tbody>
<?php $Total = 0;$PTotal=0;$STotal=0;$CTotal=0;
foreach ($StockRecords as $TableRow) : ?>
<?php $Total = 0;
$PTotal = 0;
$STotal = 0;
$CTotal = 0;
foreach ($StockRecords as $index => $TableRow) : ?>
<?php if ((count($TableRow->Item)) > 0):; ?>
<tr>
<td><?php echo ($TableRow->Item)?$TableRow->Item->title:"N/A"; ?></td>
<td><?php echo getFieldfromValue("tbl_units", "title", "unit_id", $TableRow->Item->units_id); ?></td>
<td class="text-center"><?php echo $index + 1; ?></td>
<td><?php echo ($TableRow->Summary->Item->title) ? $TableRow->Summary->Item->title : "N/A"; ?></td>
<!-- $StockRecord->Summary->Unit->unit_id -->
<td><?php echo getFieldfromValue("tbl_units", "title", "unit_id", $TableRow->Summary->Unit->unit_id); ?></td>
<td class="text-right"><?php echo $TableRow->Summary->Opening->qty; ?></td>
<td class="text-right"><?php echo $TableRow->Summary->Opening->rate; ?></td>
<td><?php echo myCurrency($lTotal = $TableRow->Summary->Opening->amount);
@ -229,14 +236,13 @@
<td class="text-right"><?php echo $TableRow->Summary->Closing->rate; ?></td>
<td><?php echo myCurrency($cTotal = $TableRow->Summary->Closing->amount);
$CTotal += $cTotal; ?></td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
<tbody>
<tfoot>
<tr>
<td colspan="4" class="text-right"><b><?php echo myLang("Total"); ?></b></td>
<td colspan="5" class="text-right"><b><?php echo myLang("Total"); ?></b></td>
<td><?php echo myCurrency($Total); ?></td>
<td colspan="2"></td>
<td><?php echo myCurrency($PTotal); ?></td>
@ -244,6 +250,7 @@
<td><?php echo myCurrency($STotal); ?></td>
<td colspan="2"></td>
<td><?php echo myCurrency($CTotal); ?></td>
</tr>
</tfoot>
</table>
@ -254,3 +261,120 @@
</div>
</div>
</div>
<?php function footerFunctions()
{
?>
<script>
$(document).ready(function() {
// Prevent the dropdown from closing when clicking inside
$('.dropdown-menu').on('click', function(event) {
event.stopPropagation();
});
});
</script>
<script>
// var exportButton = document.getElementById("exportButton");
// exportButton.addEventListener("click", function() {
// exportTableToCSV("table.csv");
// });
document.addEventListener("DOMContentLoaded", function() {
// Trigger click event on page load
document.getElementById("toggleShowAll").click();
});
document.getElementById("toggleShowAll").addEventListener("click", function(e) {
e.preventDefault();
var nestedRows = document.getElementsByClassName("collapse");
for (var i = 0; i < nestedRows.length; i++) {
if (nestedRows[i].classList.contains("show")) {
nestedRows[i].classList.remove("show");
} else {
nestedRows[i].classList.add("show");
}
}
});
function exportTableToCSV(filename) {
var csv = [];
var rows = document.querySelectorAll("table tr:not(.hide)");
for (var i = 0; i < rows.length; i++) {
var row = [];
var cols = rows[i].querySelectorAll("td:not(.hide), th:not(.hide)");
// Check if the parent row is collapsed or hidden
var parentRow = rows[i].closest(".collapse");
var isParentCollapsed = parentRow && (!parentRow.classList.contains("show"));
if (isParentCollapsed) {
continue; // Skip child table rows if parent is collapsed
}
for (var j = 0; j < cols.length; j++) {
var cellValue = cols[j].innerText.replace(/,/g, ""); // Remove commas from the cell value
row.push(cellValue);
}
csv.push(row.join(","));
}
// Create a CSV file
var csvContent = "data:text/csv;charset=utf-8," + csv.join("\n");
var encodedUri = encodeURI(csvContent);
var link = document.createElement("a");
link.setAttribute("href", encodedUri);
link.setAttribute("download", filename);
document.body.appendChild(link);
link.click();
}
</script>
<script>
$("#fromDate").nepaliDatePicker({
dateFormat: "%y-%m-%d",
closeOnDateSelect: true,
minDate: $('#fromDate').data('start'),
maxDate: $('#fromDate').data('end'),
});
</script>
<script>
$("#toDate").nepaliDatePicker({
dateFormat: "%y-%m-%d",
closeOnDateSelect: true,
minDate: $('#toDate').data('start'),
maxDate: $('#toDate').data('end'),
});
</script>
<!-- pdf document -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.17.0/xlsx.full.min.js"></script>
<script>
document.getElementById('downloadCsv').addEventListener('click', function() {
const table = document.getElementById('myTable');
const rows = Array.from(table.rows);
const data = [];
rows.forEach((row) => {
const cells = Array.from(row.cells);
const rowData = [];
cells.forEach((cell) => {
// Handle colspan
const colspan = cell.colSpan || 1;
for (let i = 0; i < (colspan - 1); i++) {
rowData.push(''); // Fill empty cells for merged columns
}
for (let i = 0; i < 1; i++) {
rowData.push(cell.innerText.trim());
}
// Fill empty cells for colspan
});
data.push(rowData);
});
// Create a worksheet
const worksheet = XLSX.utils.aoa_to_sheet(data);
const workbook = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
// Export to Excel
XLSX.writeFile(workbook, 'table.xlsx');
});
</script>
<!-- pdf document ends-->
<?php
}
?>

View File

@ -5,7 +5,7 @@
<div class="col-3">
<div class="card card-primary card-outline">
<div class="card-header">
<h5 class="m-0"><?php echo isset($unit) ? 'Edit' : 'Add'; ?>
<h5 class="m-0 card-title"><?php echo isset($unit) ? 'Edit' : 'Add'; ?>
<?php myLang('Inventory Unit'); ?>
<?php //echo $pageTitle; ?>
<?php //showListButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/list","List ".$pageTitle); ?>
@ -59,7 +59,7 @@
<div class="col-9">
<div class="card card-primary card-outline">
<div class="card-header">
<h5 class="m-0"> <?php myLang(' List Inventory Units'); ?> <?php //echo $pageTitle; ?>
<h5 class="m-0 card-title"> <?php myLang(' List Inventory Units'); ?> <?php //echo $pageTitle; ?>
<?php //showCreateButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/add", "Create New " . $pageTitle); ?>
</h5>
</div>
@ -68,10 +68,10 @@
<table class="table table-bordered table-striped longdataTable">
<thead>
<tr>
<th class="table-col col-1"><?php myLang('S.N'); ?></th>
<th><?php myLang('Unit Name '); ?></th>
<th><?php myLang('Unit Code'); ?></th>
<th class="table-col col-1">Action</th>
<th class="text-center" width="5%"><?php myLang('S.N'); ?></th>
<th class="col-5" width="30%"><?php myLang('Unit Name '); ?></th>
<th class="col-5" width="57%"><?php myLang('Unit Code'); ?></th>
<th class="col-1 text-center" >Action</th>
</tr>
</thead>
<tbody>
@ -80,10 +80,10 @@
<?php foreach ($TableRow as $cols) : $id = $cols;
break;
endforeach; ?><tr>
<td><?php echo $a; ?></td>
<td class="text-center"><?php echo $a; ?></td>
<td><?php echo $TableRow->title; ?></td>
<td><?php echo $TableRow->description; ?></td>
<td><?php showEditButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/edit/$id"); ?>
<td class="text-center"><?php showEditButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/edit/$id"); ?>
<?php showDeleteButton($id); ?>
</td>
</tr>

View File

@ -1,39 +1,34 @@
<div class="content-wrapper">
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col">
<div class="card card-primary card-outline">
<div class="card-header">
<h5 class="m-0"><?php echo $pageTitle; ?> <?php showCreateButton($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/add", "Create New " . $pageTitle); ?></h5>
</div>
<div class="card-body ">
<?php $TableData = $this->db->query("select * from tbl_translations where status=1")->result(); ?>
<table class="table table-bordered table-striped longdataTable">
<thead>
<tr>
<th class="text-center col-1"><?php myLang('Translation Id'); ?></th>
<th class="text-center col-2"><?php myLang('English'); ?></th>
<th class="text-center col-2"><?php myLang('Nepali'); ?></th>
<th class="text-center col-5"><?php myLang('English'); ?></th>
<th class="text-center col-5"><?php myLang('Nepali'); ?></th>
<th class="text-center col-1"><?php myLang('Action'); ?></th>
</tr>
</thead>
<tbody>
<?php $a=0; foreach ($TableData as $TableRow) : $a++; ?>
<?php $a = 0;
foreach ($TableData as $TableRow) : $a++; ?>
<?php foreach ($TableRow as $cols) : $id = $cols;
break;
endforeach; ?><tr>
<td class="text-center"><?php echo $TableRow->translation_id; ?></td>
<td><?php echo $TableRow->english; ?></td>
<td><?php echo $TableRow->nepali; ?></td>
<td class="text-center"><a href="<?php echo site_url($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/edit/$id"); ?>" class="btn btn-info btn-xs"><i class="fas fa-edit"></i> Edit</a>
<a onClick="javascript:doDelete(<?php echo $id; ?>);" class="btn btn-danger btn-xs"><i class="fas fa-trash"></i> Delete</a>
<td class="text-center"><a href="<?php echo site_url($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/edit/$id"); ?>" class="btn btn-info btn-xs"><i class="fas fa-edit"></i></a>
<a onClick="javascript:doDelete(<?php echo $id; ?>);" class="btn btn-danger btn-xs"><i class="fas fa-trash"></i></a>
</td>
</tr>
<?php endforeach; ?>

View File

@ -123,12 +123,22 @@ margin-bottom: .5rem;
.select2-container--default .select2-selection--single .select2-selection__arrow b {
margin-top: 0 !important;
}
.card-body.p-0 .table tbody>tr>td:last-of-type, .card-body.p-0 .table tbody>tr>th:last-of-type, .card-body.p-0 .table tfoot>tr>td:last-of-type, .card-body.p-0 .table tfoot>tr>th:last-of-type, .card-body.p-0 .table thead>tr>td:last-of-type, .card-body.p-0 .table thead>tr>th:last-of-type {
padding-right: 0!important;
}
/* .card-body.p-0 .table tbody>tr>td:last-of-type, .card-body.p-0 .table tbody>tr>th:last-of-type, .card-body.p-0 .table tfoot>tr>td:last-of-type, .card-body.p-0 .table tfoot>tr>th:last-of-type, .card-body.p-0 .table thead>tr>td:last-of-type, .card-body.p-0 .table thead>tr>th:last-of-type {
padding-right: 0px!important;
} */
.form-group textarea.form-control {
height: 50px !important;
}
.select2-container .select2-selection--single {
height: 30px!important;
}
.mt-26{
margin-top: 26px;
}
table.dataTable>thead>tr>th:not(.sorting_disabled), table.dataTable>thead>tr>td:not(.sorting_disabled) {
vertical-align: middle;
}
.text-right{
padding-right: 10px;
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

View File

@ -25,6 +25,7 @@ SET time_zone = "+00:00";
--
-- Table structure for table `tbl_accategories`
--
CREATE TABLE `tbl_accategories` (

View File

@ -74,6 +74,12 @@ $route['student/admission_payment'] = 'Student/admission-payment';
$route['student/get_installdetails'] = 'Student/get-installdetails';
$route['student/paypalipn_admission'] = 'Student/paypalipn-admission';
//inventory
$route['inventory/stocks/summary'] = 'Inventory/Stocks/summary';
//inventory ends
$route['admin'] = 'Admin/index';
$route['admin-logout'] = 'Admin/admin_logout';

View File

@ -75,6 +75,7 @@
$('[data-toggle="tooltip"]').tooltip()
})
</script>
</body>
</html>

634
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,9 @@
APP_NAME="BIB-Accounts"
APP_URL=http://localhost/School-With-Accounts/account/
APP_URL=http://localhost/bbnepal/BBnepal-Accounts
DB_CONNECTION=mysql
DB_HOST=127.0.0.1:3309
DB_PORT=3309
DATABASE_OPTIONS=bbnepal_accounting,myurlsco_accounts1,myurlsco_accounts2,myurlsco_accounts3
DATABASE_OPTIONS=bbnepal_accounting,myurlsco_accounts1,myurlsco_accounts2,myurlsco_accounts3 #given
DB_DATABASE=bbnepal_accounting
DB_USERNAME=root
DB_PASSWORD=

17
vendor/autoload.php vendored
View File

@ -3,8 +3,21 @@
// autoload.php @generated by Composer
if (PHP_VERSION_ID < 50600) {
echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
exit(1);
if (!headers_sent()) {
header('HTTP/1.1 500 Internal Server Error');
}
$err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
if (!ini_get('display_errors')) {
if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
fwrite(STDERR, $err);
} elseif (!headers_sent()) {
echo $err;
}
}
trigger_error(
$err,
E_USER_ERROR
);
}
require_once __DIR__ . '/composer/autoload_real.php';

View File

@ -42,35 +42,37 @@ namespace Composer\Autoload;
*/
class ClassLoader
{
/** @var ?string */
/** @var \Closure(string):void */
private static $includeFile;
/** @var string|null */
private $vendorDir;
// PSR-4
/**
* @var array[]
* @psalm-var array<string, array<string, int>>
* @var array<string, array<string, int>>
*/
private $prefixLengthsPsr4 = array();
/**
* @var array[]
* @psalm-var array<string, array<int, string>>
* @var array<string, list<string>>
*/
private $prefixDirsPsr4 = array();
/**
* @var array[]
* @psalm-var array<string, string>
* @var list<string>
*/
private $fallbackDirsPsr4 = array();
// PSR-0
/**
* @var array[]
* @psalm-var array<string, array<string, string[]>>
* List of PSR-0 prefixes
*
* Structured as array('F (first letter)' => array('Foo\Bar (full prefix)' => array('path', 'path2')))
*
* @var array<string, array<string, list<string>>>
*/
private $prefixesPsr0 = array();
/**
* @var array[]
* @psalm-var array<string, string>
* @var list<string>
*/
private $fallbackDirsPsr0 = array();
@ -78,8 +80,7 @@ class ClassLoader
private $useIncludePath = false;
/**
* @var string[]
* @psalm-var array<string, string>
* @var array<string, string>
*/
private $classMap = array();
@ -87,29 +88,29 @@ class ClassLoader
private $classMapAuthoritative = false;
/**
* @var bool[]
* @psalm-var array<string, bool>
* @var array<string, bool>
*/
private $missingClasses = array();
/** @var ?string */
/** @var string|null */
private $apcuPrefix;
/**
* @var self[]
* @var array<string, self>
*/
private static $registeredLoaders = array();
/**
* @param ?string $vendorDir
* @param string|null $vendorDir
*/
public function __construct($vendorDir = null)
{
$this->vendorDir = $vendorDir;
self::initializeIncludeClosure();
}
/**
* @return string[]
* @return array<string, list<string>>
*/
public function getPrefixes()
{
@ -121,8 +122,7 @@ class ClassLoader
}
/**
* @return array[]
* @psalm-return array<string, array<int, string>>
* @return array<string, list<string>>
*/
public function getPrefixesPsr4()
{
@ -130,8 +130,7 @@ class ClassLoader
}
/**
* @return array[]
* @psalm-return array<string, string>
* @return list<string>
*/
public function getFallbackDirs()
{
@ -139,8 +138,7 @@ class ClassLoader
}
/**
* @return array[]
* @psalm-return array<string, string>
* @return list<string>
*/
public function getFallbackDirsPsr4()
{
@ -148,8 +146,7 @@ class ClassLoader
}
/**
* @return string[] Array of classname => path
* @psalm-return array<string, string>
* @return array<string, string> Array of classname => path
*/
public function getClassMap()
{
@ -157,8 +154,7 @@ class ClassLoader
}
/**
* @param string[] $classMap Class to filename map
* @psalm-param array<string, string> $classMap
* @param array<string, string> $classMap Class to filename map
*
* @return void
*/
@ -176,23 +172,24 @@ class ClassLoader
* appending or prepending to the ones previously set for this prefix.
*
* @param string $prefix The prefix
* @param string[]|string $paths The PSR-0 root directories
* @param list<string>|string $paths The PSR-0 root directories
* @param bool $prepend Whether to prepend the directories
*
* @return void
*/
public function add($prefix, $paths, $prepend = false)
{
$paths = (array) $paths;
if (!$prefix) {
if ($prepend) {
$this->fallbackDirsPsr0 = array_merge(
(array) $paths,
$paths,
$this->fallbackDirsPsr0
);
} else {
$this->fallbackDirsPsr0 = array_merge(
$this->fallbackDirsPsr0,
(array) $paths
$paths
);
}
@ -201,19 +198,19 @@ class ClassLoader
$first = $prefix[0];
if (!isset($this->prefixesPsr0[$first][$prefix])) {
$this->prefixesPsr0[$first][$prefix] = (array) $paths;
$this->prefixesPsr0[$first][$prefix] = $paths;
return;
}
if ($prepend) {
$this->prefixesPsr0[$first][$prefix] = array_merge(
(array) $paths,
$paths,
$this->prefixesPsr0[$first][$prefix]
);
} else {
$this->prefixesPsr0[$first][$prefix] = array_merge(
$this->prefixesPsr0[$first][$prefix],
(array) $paths
$paths
);
}
}
@ -223,7 +220,7 @@ class ClassLoader
* appending or prepending to the ones previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param string[]|string $paths The PSR-4 base directories
* @param list<string>|string $paths The PSR-4 base directories
* @param bool $prepend Whether to prepend the directories
*
* @throws \InvalidArgumentException
@ -232,17 +229,18 @@ class ClassLoader
*/
public function addPsr4($prefix, $paths, $prepend = false)
{
$paths = (array) $paths;
if (!$prefix) {
// Register directories for the root namespace.
if ($prepend) {
$this->fallbackDirsPsr4 = array_merge(
(array) $paths,
$paths,
$this->fallbackDirsPsr4
);
} else {
$this->fallbackDirsPsr4 = array_merge(
$this->fallbackDirsPsr4,
(array) $paths
$paths
);
}
} elseif (!isset($this->prefixDirsPsr4[$prefix])) {
@ -252,18 +250,18 @@ class ClassLoader
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
}
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
$this->prefixDirsPsr4[$prefix] = (array) $paths;
$this->prefixDirsPsr4[$prefix] = $paths;
} elseif ($prepend) {
// Prepend directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
(array) $paths,
$paths,
$this->prefixDirsPsr4[$prefix]
);
} else {
// Append directories for an already registered namespace.
$this->prefixDirsPsr4[$prefix] = array_merge(
$this->prefixDirsPsr4[$prefix],
(array) $paths
$paths
);
}
}
@ -273,7 +271,7 @@ class ClassLoader
* replacing any others previously set for this prefix.
*
* @param string $prefix The prefix
* @param string[]|string $paths The PSR-0 base directories
* @param list<string>|string $paths The PSR-0 base directories
*
* @return void
*/
@ -291,7 +289,7 @@ class ClassLoader
* replacing any others previously set for this namespace.
*
* @param string $prefix The prefix/namespace, with trailing '\\'
* @param string[]|string $paths The PSR-4 base directories
* @param list<string>|string $paths The PSR-4 base directories
*
* @throws \InvalidArgumentException
*
@ -425,7 +423,8 @@ class ClassLoader
public function loadClass($class)
{
if ($file = $this->findFile($class)) {
includeFile($file);
$includeFile = self::$includeFile;
$includeFile($file);
return true;
}
@ -476,9 +475,9 @@ class ClassLoader
}
/**
* Returns the currently registered loaders indexed by their corresponding vendor directories.
* Returns the currently registered loaders keyed by their corresponding vendor directories.
*
* @return self[]
* @return array<string, self>
*/
public static function getRegisteredLoaders()
{
@ -555,6 +554,14 @@ class ClassLoader
return false;
}
/**
* @return void
*/
private static function initializeIncludeClosure()
{
if (self::$includeFile !== null) {
return;
}
/**
@ -564,9 +571,9 @@ class ClassLoader
*
* @param string $file
* @return void
* @private
*/
function includeFile($file)
{
self::$includeFile = \Closure::bind(static function($file) {
include $file;
}, null, null);
}
}

View File

@ -98,7 +98,7 @@ class InstalledVersions
{
foreach (self::getInstalled() as $installed) {
if (isset($installed['versions'][$packageName])) {
return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']);
return $includeDevRequirements || !isset($installed['versions'][$packageName]['dev_requirement']) || $installed['versions'][$packageName]['dev_requirement'] === false;
}
}
@ -119,7 +119,7 @@ class InstalledVersions
*/
public static function satisfies(VersionParser $parser, $packageName, $constraint)
{
$constraint = $parser->parseConstraints($constraint);
$constraint = $parser->parseConstraints((string) $constraint);
$provided = $parser->parseConstraints(self::getVersionRanges($packageName));
return $provided->matches($constraint);
@ -328,7 +328,9 @@ class InstalledVersions
if (isset(self::$installedByVendor[$vendorDir])) {
$installed[] = self::$installedByVendor[$vendorDir];
} elseif (is_file($vendorDir.'/composer/installed.php')) {
$installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php';
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = require $vendorDir.'/composer/installed.php';
$installed[] = self::$installedByVendor[$vendorDir] = $required;
if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
self::$installed = $installed[count($installed) - 1];
}
@ -340,12 +342,17 @@ class InstalledVersions
// only require the installed.php file if this file is loaded from its dumped location,
// and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937
if (substr(__DIR__, -8, 1) !== 'C') {
self::$installed = require __DIR__ . '/installed.php';
/** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
$required = require __DIR__ . '/installed.php';
self::$installed = $required;
} else {
self::$installed = array();
}
}
if (self::$installed !== array()) {
$installed[] = self::$installed;
}
return $installed;
}

View File

@ -471,6 +471,5 @@ return array(
'SebastianBergmann\\RecursionContext\\InvalidArgumentException' => $vendorDir . '/sebastian/recursion-context/src/InvalidArgumentException.php',
'SebastianBergmann\\ResourceOperations\\ResourceOperations' => $vendorDir . '/sebastian/resource-operations/src/ResourceOperations.php',
'SebastianBergmann\\Version' => $vendorDir . '/sebastian/version/src/Version.php',
'Stringable' => $vendorDir . '/myclabs/php-enum/stubs/Stringable.php',
'Text_Template' => $vendorDir . '/phpunit/php-text-template/src/Template.php',
);

View File

@ -7,11 +7,8 @@ $baseDir = dirname($vendorDir);
return array(
'7b11c4dc42b3b3023073cb14e519683c' => $vendorDir . '/ralouphie/getallheaders/src/getallheaders.php',
'c964ee0ededf28c96ebd9db5099ef910' => $vendorDir . '/guzzlehttp/promises/src/functions_include.php',
'6e3fae29631ef280660b3cdad06f25a8' => $vendorDir . '/symfony/deprecation-contracts/function.php',
'320cde22f66dd4f5d3fd621d3e88b98f' => $vendorDir . '/symfony/polyfill-ctype/bootstrap.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => $vendorDir . '/symfony/polyfill-mbstring/bootstrap.php',
'2cffec82183ee1cea088009cef9a6fc3' => $vendorDir . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => $vendorDir . '/guzzlehttp/guzzle/src/functions_include.php',
'6124b4c8570aa390c21fafd04a26c69f' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php',
'3109cb1a231dcd04bee1f9f620d46975' => $vendorDir . '/paragonie/sodium_compat/autoload.php',

View File

@ -7,5 +7,4 @@ $baseDir = dirname($vendorDir);
return array(
'org\\bovigo\\vfs' => array($vendorDir . '/mikey179/vfsstream/src/main/php'),
'HTMLPurifier' => array($vendorDir . '/ezyang/htmlpurifier/library'),
);

View File

@ -9,23 +9,23 @@ return array(
'phpDocumentor\\Reflection\\' => array($vendorDir . '/phpdocumentor/reflection-common/src', $vendorDir . '/phpdocumentor/reflection-docblock/src', $vendorDir . '/phpdocumentor/type-resolver/src'),
'ZipStream\\' => array($vendorDir . '/maennchen/zipstream-php/src'),
'Webmozart\\Assert\\' => array($vendorDir . '/webmozart/assert/src'),
'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'),
'Symfony\\Polyfill\\Ctype\\' => array($vendorDir . '/symfony/polyfill-ctype'),
'Symfony\\Component\\Yaml\\' => array($vendorDir . '/symfony/yaml'),
'Pusher\\' => array($vendorDir . '/pusher/pusher-php-server/src'),
'Psr\\SimpleCache\\' => array($vendorDir . '/psr/simple-cache/src'),
'Psr\\Log\\' => array($vendorDir . '/psr/log/Psr/Log'),
'Psr\\Log\\' => array($vendorDir . '/psr/log/src'),
'Psr\\Http\\Message\\' => array($vendorDir . '/psr/http-factory/src', $vendorDir . '/psr/http-message/src'),
'Psr\\Http\\Client\\' => array($vendorDir . '/psr/http-client/src'),
'Prophecy\\' => array($vendorDir . '/phpspec/prophecy/src/Prophecy'),
'PhpOffice\\PhpSpreadsheet\\' => array($vendorDir . '/phpoffice/phpspreadsheet/src/PhpSpreadsheet'),
'PHPStan\\PhpDocParser\\' => array($vendorDir . '/phpstan/phpdoc-parser/src'),
'Nilambar\\NepaliDate\\' => array($vendorDir . '/ernilambar/nepali-date/src'),
'MyCLabs\\Enum\\' => array($vendorDir . '/myclabs/php-enum/src'),
'Matrix\\' => array($vendorDir . '/markbaker/matrix/classes/src'),
'GuzzleHttp\\Psr7\\' => array($vendorDir . '/guzzlehttp/psr7/src'),
'GuzzleHttp\\Promise\\' => array($vendorDir . '/guzzlehttp/promises/src'),
'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'),
'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'),
'Doctrine\\Deprecations\\' => array($vendorDir . '/doctrine/deprecations/lib/Doctrine/Deprecations'),
'DeepCopy\\' => array($vendorDir . '/myclabs/deep-copy/src/DeepCopy'),
'Complex\\' => array($vendorDir . '/markbaker/complex/classes/src'),
);

View File

@ -31,25 +31,18 @@ class ComposerAutoloaderInitade43c0983b611153cb43d6dce42fdb7
$loader->register(true);
$includeFiles = \Composer\Autoload\ComposerStaticInitade43c0983b611153cb43d6dce42fdb7::$files;
foreach ($includeFiles as $fileIdentifier => $file) {
composerRequireade43c0983b611153cb43d6dce42fdb7($fileIdentifier, $file);
}
return $loader;
}
}
/**
* @param string $fileIdentifier
* @param string $file
* @return void
*/
function composerRequireade43c0983b611153cb43d6dce42fdb7($fileIdentifier, $file)
{
$filesToLoad = \Composer\Autoload\ComposerStaticInitade43c0983b611153cb43d6dce42fdb7::$files;
$requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
$GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
require $file;
}
}, null, null);
foreach ($filesToLoad as $fileIdentifier => $file) {
$requireFile($fileIdentifier, $file);
}
return $loader;
}
}

View File

@ -8,11 +8,8 @@ class ComposerStaticInitade43c0983b611153cb43d6dce42fdb7
{
public static $files = array (
'7b11c4dc42b3b3023073cb14e519683c' => __DIR__ . '/..' . '/ralouphie/getallheaders/src/getallheaders.php',
'c964ee0ededf28c96ebd9db5099ef910' => __DIR__ . '/..' . '/guzzlehttp/promises/src/functions_include.php',
'6e3fae29631ef280660b3cdad06f25a8' => __DIR__ . '/..' . '/symfony/deprecation-contracts/function.php',
'320cde22f66dd4f5d3fd621d3e88b98f' => __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php',
'0e6d7bf4a5811bfa5cf40c5ccd6fae6a' => __DIR__ . '/..' . '/symfony/polyfill-mbstring/bootstrap.php',
'2cffec82183ee1cea088009cef9a6fc3' => __DIR__ . '/..' . '/ezyang/htmlpurifier/library/HTMLPurifier.composer.php',
'37a3dc5111fe8f707ab4c132ef1dbc62' => __DIR__ . '/..' . '/guzzlehttp/guzzle/src/functions_include.php',
'6124b4c8570aa390c21fafd04a26c69f' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php',
'3109cb1a231dcd04bee1f9f620d46975' => __DIR__ . '/..' . '/paragonie/sodium_compat/autoload.php',
@ -33,7 +30,6 @@ class ComposerStaticInitade43c0983b611153cb43d6dce42fdb7
),
'S' =>
array (
'Symfony\\Polyfill\\Mbstring\\' => 26,
'Symfony\\Polyfill\\Ctype\\' => 23,
'Symfony\\Component\\Yaml\\' => 23,
),
@ -46,6 +42,7 @@ class ComposerStaticInitade43c0983b611153cb43d6dce42fdb7
'Psr\\Http\\Client\\' => 16,
'Prophecy\\' => 9,
'PhpOffice\\PhpSpreadsheet\\' => 25,
'PHPStan\\PhpDocParser\\' => 21,
),
'N' =>
array (
@ -53,7 +50,6 @@ class ComposerStaticInitade43c0983b611153cb43d6dce42fdb7
),
'M' =>
array (
'MyCLabs\\Enum\\' => 13,
'Matrix\\' => 7,
),
'G' =>
@ -65,6 +61,7 @@ class ComposerStaticInitade43c0983b611153cb43d6dce42fdb7
'D' =>
array (
'Doctrine\\Instantiator\\' => 22,
'Doctrine\\Deprecations\\' => 22,
'DeepCopy\\' => 9,
),
'C' =>
@ -88,10 +85,6 @@ class ComposerStaticInitade43c0983b611153cb43d6dce42fdb7
array (
0 => __DIR__ . '/..' . '/webmozart/assert/src',
),
'Symfony\\Polyfill\\Mbstring\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/polyfill-mbstring',
),
'Symfony\\Polyfill\\Ctype\\' =>
array (
0 => __DIR__ . '/..' . '/symfony/polyfill-ctype',
@ -110,7 +103,7 @@ class ComposerStaticInitade43c0983b611153cb43d6dce42fdb7
),
'Psr\\Log\\' =>
array (
0 => __DIR__ . '/..' . '/psr/log/Psr/Log',
0 => __DIR__ . '/..' . '/psr/log/src',
),
'Psr\\Http\\Message\\' =>
array (
@ -129,14 +122,14 @@ class ComposerStaticInitade43c0983b611153cb43d6dce42fdb7
array (
0 => __DIR__ . '/..' . '/phpoffice/phpspreadsheet/src/PhpSpreadsheet',
),
'PHPStan\\PhpDocParser\\' =>
array (
0 => __DIR__ . '/..' . '/phpstan/phpdoc-parser/src',
),
'Nilambar\\NepaliDate\\' =>
array (
0 => __DIR__ . '/..' . '/ernilambar/nepali-date/src',
),
'MyCLabs\\Enum\\' =>
array (
0 => __DIR__ . '/..' . '/myclabs/php-enum/src',
),
'Matrix\\' =>
array (
0 => __DIR__ . '/..' . '/markbaker/matrix/classes/src',
@ -157,6 +150,10 @@ class ComposerStaticInitade43c0983b611153cb43d6dce42fdb7
array (
0 => __DIR__ . '/..' . '/doctrine/instantiator/src/Doctrine/Instantiator',
),
'Doctrine\\Deprecations\\' =>
array (
0 => __DIR__ . '/..' . '/doctrine/deprecations/lib/Doctrine/Deprecations',
),
'DeepCopy\\' =>
array (
0 => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy',
@ -175,13 +172,6 @@ class ComposerStaticInitade43c0983b611153cb43d6dce42fdb7
0 => __DIR__ . '/..' . '/mikey179/vfsstream/src/main/php',
),
),
'H' =>
array (
'HTMLPurifier' =>
array (
0 => __DIR__ . '/..' . '/ezyang/htmlpurifier/library',
),
),
);
public static $classMap = array (
@ -650,7 +640,6 @@ class ComposerStaticInitade43c0983b611153cb43d6dce42fdb7
'SebastianBergmann\\RecursionContext\\InvalidArgumentException' => __DIR__ . '/..' . '/sebastian/recursion-context/src/InvalidArgumentException.php',
'SebastianBergmann\\ResourceOperations\\ResourceOperations' => __DIR__ . '/..' . '/sebastian/resource-operations/src/ResourceOperations.php',
'SebastianBergmann\\Version' => __DIR__ . '/..' . '/sebastian/version/src/Version.php',
'Stringable' => __DIR__ . '/..' . '/myclabs/php-enum/stubs/Stringable.php',
'Text_Template' => __DIR__ . '/..' . '/phpunit/php-text-template/src/Template.php',
);

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,9 @@
<?php return array(
'root' => array(
'name' => 'codeigniter/framework',
'pretty_version' => '1.0.0+no-version-set',
'version' => '1.0.0.0',
'reference' => NULL,
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => '497f567cba71733b286514954ef72c9fe5d46c51',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
@ -11,14 +11,23 @@
),
'versions' => array(
'codeigniter/framework' => array(
'pretty_version' => '1.0.0+no-version-set',
'version' => '1.0.0.0',
'reference' => NULL,
'pretty_version' => 'dev-main',
'version' => 'dev-main',
'reference' => '497f567cba71733b286514954ef72c9fe5d46c51',
'type' => 'project',
'install_path' => __DIR__ . '/../../',
'aliases' => array(),
'dev_requirement' => false,
),
'doctrine/deprecations' => array(
'pretty_version' => '1.1.3',
'version' => '1.1.3.0',
'reference' => 'dfbaa3c2d2e9a9df1118213f3b8b0c597bb99fab',
'type' => 'library',
'install_path' => __DIR__ . '/../doctrine/deprecations',
'aliases' => array(),
'dev_requirement' => true,
),
'doctrine/instantiator' => array(
'pretty_version' => '1.5.0',
'version' => '1.5.0.0',
@ -29,54 +38,45 @@
'dev_requirement' => true,
),
'ernilambar/nepali-date' => array(
'pretty_version' => '1.0.5',
'version' => '1.0.5.0',
'reference' => '8ac91a49267e3821bf03f052d3cb6b7876af4a12',
'pretty_version' => '1.0.7',
'version' => '1.0.7.0',
'reference' => '886dcb25b10760b4f9c35083d0a1d3ef6fb98584',
'type' => 'library',
'install_path' => __DIR__ . '/../ernilambar/nepali-date',
'aliases' => array(),
'dev_requirement' => false,
),
'ezyang/htmlpurifier' => array(
'pretty_version' => 'v4.16.0',
'version' => '4.16.0.0',
'reference' => '523407fb06eb9e5f3d59889b3978d5bfe94299c8',
'type' => 'library',
'install_path' => __DIR__ . '/../ezyang/htmlpurifier',
'aliases' => array(),
'dev_requirement' => false,
),
'guzzlehttp/guzzle' => array(
'pretty_version' => '7.5.0',
'version' => '7.5.0.0',
'reference' => 'b50a2a1251152e43f6a37f0fa053e730a67d25ba',
'pretty_version' => '7.9.2',
'version' => '7.9.2.0',
'reference' => 'd281ed313b989f213357e3be1a179f02196ac99b',
'type' => 'library',
'install_path' => __DIR__ . '/../guzzlehttp/guzzle',
'aliases' => array(),
'dev_requirement' => false,
),
'guzzlehttp/promises' => array(
'pretty_version' => '1.5.2',
'version' => '1.5.2.0',
'reference' => 'b94b2807d85443f9719887892882d0329d1e2598',
'pretty_version' => '2.0.3',
'version' => '2.0.3.0',
'reference' => '6ea8dd08867a2a42619d65c3deb2c0fcbf81c8f8',
'type' => 'library',
'install_path' => __DIR__ . '/../guzzlehttp/promises',
'aliases' => array(),
'dev_requirement' => false,
),
'guzzlehttp/psr7' => array(
'pretty_version' => '2.4.3',
'version' => '2.4.3.0',
'reference' => '67c26b443f348a51926030c83481b85718457d3d',
'pretty_version' => '2.7.0',
'version' => '2.7.0.0',
'reference' => 'a70f5c95fb43bc83f07c9c948baa0dc1829bf201',
'type' => 'library',
'install_path' => __DIR__ . '/../guzzlehttp/psr7',
'aliases' => array(),
'dev_requirement' => false,
),
'maennchen/zipstream-php' => array(
'pretty_version' => '2.2.6',
'version' => '2.2.6.0',
'reference' => '30ad6f93cf3efe4192bc7a4c9cad11ff8f4f237f',
'pretty_version' => '3.1.0',
'version' => '3.1.0.0',
'reference' => 'b8174494eda667f7d13876b4a7bfef0f62a7c0d1',
'type' => 'library',
'install_path' => __DIR__ . '/../maennchen/zipstream-php',
'aliases' => array(),
@ -110,23 +110,14 @@
'dev_requirement' => true,
),
'myclabs/deep-copy' => array(
'pretty_version' => '1.11.0',
'version' => '1.11.0.0',
'reference' => '14daed4296fae74d9e3201d2c4925d1acb7aa614',
'pretty_version' => '1.12.0',
'version' => '1.12.0.0',
'reference' => '3a6b9a42cd8f8771bd4295d13e1423fa7f3d942c',
'type' => 'library',
'install_path' => __DIR__ . '/../myclabs/deep-copy',
'aliases' => array(),
'dev_requirement' => true,
),
'myclabs/php-enum' => array(
'pretty_version' => '1.8.4',
'version' => '1.8.4.0',
'reference' => 'a867478eae49c9f59ece437ae7f9506bfaa27483',
'type' => 'library',
'install_path' => __DIR__ . '/../myclabs/php-enum',
'aliases' => array(),
'dev_requirement' => false,
),
'paragonie/random_compat' => array(
'pretty_version' => 'v9.99.100',
'version' => '9.99.100.0',
@ -137,9 +128,9 @@
'dev_requirement' => false,
),
'paragonie/sodium_compat' => array(
'pretty_version' => 'v1.19.0',
'version' => '1.19.0.0',
'reference' => 'cb15e403ecbe6a6cc515f855c310eb6b1872a933',
'pretty_version' => 'v1.21.1',
'version' => '1.21.1.0',
'reference' => 'bb312875dcdd20680419564fe42ba1d9564b9e37',
'type' => 'library',
'install_path' => __DIR__ . '/../paragonie/sodium_compat',
'aliases' => array(),
@ -155,27 +146,27 @@
'dev_requirement' => true,
),
'phpdocumentor/reflection-docblock' => array(
'pretty_version' => '5.3.0',
'version' => '5.3.0.0',
'reference' => '622548b623e81ca6d78b721c5e029f4ce664f170',
'pretty_version' => '5.4.1',
'version' => '5.4.1.0',
'reference' => '9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c',
'type' => 'library',
'install_path' => __DIR__ . '/../phpdocumentor/reflection-docblock',
'aliases' => array(),
'dev_requirement' => true,
),
'phpdocumentor/type-resolver' => array(
'pretty_version' => '1.6.2',
'version' => '1.6.2.0',
'reference' => '48f445a408c131e38cab1c235aa6d2bb7a0bb20d',
'pretty_version' => '1.8.2',
'version' => '1.8.2.0',
'reference' => '153ae662783729388a584b4361f2545e4d841e3c',
'type' => 'library',
'install_path' => __DIR__ . '/../phpdocumentor/type-resolver',
'aliases' => array(),
'dev_requirement' => true,
),
'phpoffice/phpspreadsheet' => array(
'pretty_version' => '1.26.0',
'version' => '1.26.0.0',
'reference' => '5b6ceea9705b068f993e268e4debc566c2637063',
'pretty_version' => '2.2.2',
'version' => '2.2.2.0',
'reference' => 'ffbcee68069b073bff07a71eb321dcd9f2763513',
'type' => 'library',
'install_path' => __DIR__ . '/../phpoffice/phpspreadsheet',
'aliases' => array(),
@ -190,6 +181,15 @@
'aliases' => array(),
'dev_requirement' => true,
),
'phpstan/phpdoc-parser' => array(
'pretty_version' => '1.31.0',
'version' => '1.31.0.0',
'reference' => '249f15fb843bf240cf058372dad29e100cee6c17',
'type' => 'library',
'install_path' => __DIR__ . '/../phpstan/phpdoc-parser',
'aliases' => array(),
'dev_requirement' => true,
),
'phpunit/php-code-coverage' => array(
'pretty_version' => '4.0.8',
'version' => '4.0.8.0',
@ -254,9 +254,9 @@
'dev_requirement' => true,
),
'psr/http-client' => array(
'pretty_version' => '1.0.1',
'version' => '1.0.1.0',
'reference' => '2dfb5f6c5eff0e91e20e913f8c5452ed95b86621',
'pretty_version' => '1.0.3',
'version' => '1.0.3.0',
'reference' => 'bb5906edc1c324c9a05aa0873d40117941e5fa90',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/http-client',
'aliases' => array(),
@ -269,9 +269,9 @@
),
),
'psr/http-factory' => array(
'pretty_version' => '1.0.1',
'version' => '1.0.1.0',
'reference' => '12ac7fcd07e5b077433f5f2bee95b3a771bf61be',
'pretty_version' => '1.1.0',
'version' => '1.1.0.0',
'reference' => '2b4765fddfe3b508ac62f829e852b1501d3f6e8a',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/http-factory',
'aliases' => array(),
@ -284,9 +284,9 @@
),
),
'psr/http-message' => array(
'pretty_version' => '1.0.1',
'version' => '1.0.1.0',
'reference' => 'f6561bf28d520154e4b0ec72be95418abe6d9363',
'pretty_version' => '2.0',
'version' => '2.0.0.0',
'reference' => '402d35bcb92c70c026d1a6a9883f06b2ead23d71',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/http-message',
'aliases' => array(),
@ -299,27 +299,27 @@
),
),
'psr/log' => array(
'pretty_version' => '1.1.4',
'version' => '1.1.4.0',
'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11',
'pretty_version' => '3.0.2',
'version' => '3.0.2.0',
'reference' => 'f16e1d5863e37f8d8c2a01719f5b34baa2b714d3',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/log',
'aliases' => array(),
'dev_requirement' => false,
),
'psr/simple-cache' => array(
'pretty_version' => '1.0.1',
'version' => '1.0.1.0',
'reference' => '408d5eafb83c57f6365a3ca330ff23aa4a5fa39b',
'pretty_version' => '3.0.0',
'version' => '3.0.0.0',
'reference' => '764e0b3939f5ca87cb904f570ef9be2d78a07865',
'type' => 'library',
'install_path' => __DIR__ . '/../psr/simple-cache',
'aliases' => array(),
'dev_requirement' => false,
),
'pusher/pusher-php-server' => array(
'pretty_version' => '7.2.2',
'version' => '7.2.2.0',
'reference' => '4ace4873873b06c25cecb2dd6d9fdcbf2f20b640',
'pretty_version' => '7.2.4',
'version' => '7.2.4.0',
'reference' => 'de2f72296808f9cafa6a4462b15a768ff130cddb',
'type' => 'library',
'install_path' => __DIR__ . '/../pusher/pusher-php-server',
'aliases' => array(),
@ -335,9 +335,9 @@
'dev_requirement' => false,
),
'sebastian/code-unit-reverse-lookup' => array(
'pretty_version' => '1.0.2',
'version' => '1.0.2.0',
'reference' => '1de8cd5c010cb153fcd68b8d0f64606f523f7619',
'pretty_version' => '1.0.3',
'version' => '1.0.3.0',
'reference' => '92a1a52e86d34cde6caa54f1b5ffa9fda18e5d54',
'type' => 'library',
'install_path' => __DIR__ . '/../sebastian/code-unit-reverse-lookup',
'aliases' => array(),
@ -425,32 +425,23 @@
'dev_requirement' => true,
),
'symfony/deprecation-contracts' => array(
'pretty_version' => 'v2.5.2',
'version' => '2.5.2.0',
'reference' => 'e8b495ea28c1d97b5e0c121748d6f9b53d075c66',
'pretty_version' => 'v3.5.0',
'version' => '3.5.0.0',
'reference' => '0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/deprecation-contracts',
'aliases' => array(),
'dev_requirement' => false,
),
'symfony/polyfill-ctype' => array(
'pretty_version' => 'v1.27.0',
'version' => '1.27.0.0',
'reference' => '5bbc823adecdae860bb64756d639ecfec17b050a',
'pretty_version' => 'v1.31.0',
'version' => '1.31.0.0',
'reference' => 'a3cc8b044a6ea513310cbd48ef7333b384945638',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/polyfill-ctype',
'aliases' => array(),
'dev_requirement' => true,
),
'symfony/polyfill-mbstring' => array(
'pretty_version' => 'v1.27.0',
'version' => '1.27.0.0',
'reference' => '8ad114f6b39e2c98a8b0e3bd907732c207c2b534',
'type' => 'library',
'install_path' => __DIR__ . '/../symfony/polyfill-mbstring',
'aliases' => array(),
'dev_requirement' => false,
),
'symfony/yaml' => array(
'pretty_version' => 'v4.4.45',
'version' => '4.4.45.0',

19
vendor/doctrine/deprecations/LICENSE vendored Normal file
View File

@ -0,0 +1,19 @@
Copyright (c) 2020-2021 Doctrine Project
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

157
vendor/doctrine/deprecations/README.md vendored Normal file
View File

@ -0,0 +1,157 @@
# Doctrine Deprecations
A small (side-effect free by default) layer on top of
`trigger_error(E_USER_DEPRECATED)` or PSR-3 logging.
- no side-effects by default, making it a perfect fit for libraries that don't know how the error handler works they operate under
- options to avoid having to rely on error handlers global state by using PSR-3 logging
- deduplicate deprecation messages to avoid excessive triggering and reduce overhead
We recommend to collect Deprecations using a PSR logger instead of relying on
the global error handler.
## Usage from consumer perspective:
Enable Doctrine deprecations to be sent to a PSR3 logger:
```php
\Doctrine\Deprecations\Deprecation::enableWithPsrLogger($logger);
```
Enable Doctrine deprecations to be sent as `@trigger_error($message, E_USER_DEPRECATED)`
messages by setting the `DOCTRINE_DEPRECATIONS` environment variable to `trigger`.
Alternatively, call:
```php
\Doctrine\Deprecations\Deprecation::enableWithTriggerError();
```
If you only want to enable deprecation tracking, without logging or calling `trigger_error`
then set the `DOCTRINE_DEPRECATIONS` environment variable to `track`.
Alternatively, call:
```php
\Doctrine\Deprecations\Deprecation::enableTrackingDeprecations();
```
Tracking is enabled with all three modes and provides access to all triggered
deprecations and their individual count:
```php
$deprecations = \Doctrine\Deprecations\Deprecation::getTriggeredDeprecations();
foreach ($deprecations as $identifier => $count) {
echo $identifier . " was triggered " . $count . " times\n";
}
```
### Suppressing Specific Deprecations
Disable triggering about specific deprecations:
```php
\Doctrine\Deprecations\Deprecation::ignoreDeprecations("https://link/to/deprecations-description-identifier");
```
Disable all deprecations from a package
```php
\Doctrine\Deprecations\Deprecation::ignorePackage("doctrine/orm");
```
### Other Operations
When used within PHPUnit or other tools that could collect multiple instances of the same deprecations
the deduplication can be disabled:
```php
\Doctrine\Deprecations\Deprecation::withoutDeduplication();
```
Disable deprecation tracking again:
```php
\Doctrine\Deprecations\Deprecation::disable();
```
## Usage from a library/producer perspective:
When you want to unconditionally trigger a deprecation even when called
from the library itself then the `trigger` method is the way to go:
```php
\Doctrine\Deprecations\Deprecation::trigger(
"doctrine/orm",
"https://link/to/deprecations-description",
"message"
);
```
If variable arguments are provided at the end, they are used with `sprintf` on
the message.
```php
\Doctrine\Deprecations\Deprecation::trigger(
"doctrine/orm",
"https://github.com/doctrine/orm/issue/1234",
"message %s %d",
"foo",
1234
);
```
When you want to trigger a deprecation only when it is called by a function
outside of the current package, but not trigger when the package itself is the cause,
then use:
```php
\Doctrine\Deprecations\Deprecation::triggerIfCalledFromOutside(
"doctrine/orm",
"https://link/to/deprecations-description",
"message"
);
```
Based on the issue link each deprecation message is only triggered once per
request.
A limited stacktrace is included in the deprecation message to find the
offending location.
Note: A producer/library should never call `Deprecation::enableWith` methods
and leave the decision how to handle deprecations to application and
frameworks.
## Usage in PHPUnit tests
There is a `VerifyDeprecations` trait that you can use to make assertions on
the occurrence of deprecations within a test.
```php
use Doctrine\Deprecations\PHPUnit\VerifyDeprecations;
class MyTest extends TestCase
{
use VerifyDeprecations;
public function testSomethingDeprecation()
{
$this->expectDeprecationWithIdentifier('https://github.com/doctrine/orm/issue/1234');
triggerTheCodeWithDeprecation();
}
public function testSomethingDeprecationFixed()
{
$this->expectNoDeprecationWithIdentifier('https://github.com/doctrine/orm/issue/1234');
triggerTheCodeWithoutDeprecation();
}
}
```
## What is a deprecation identifier?
An identifier for deprecations is just a link to any resource, most often a
Github Issue or Pull Request explaining the deprecation and potentially its
alternative.

View File

@ -0,0 +1,38 @@
{
"name": "doctrine/deprecations",
"description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.",
"license": "MIT",
"type": "library",
"homepage": "https://www.doctrine-project.org/",
"require": {
"php": "^7.1 || ^8.0"
},
"require-dev": {
"doctrine/coding-standard": "^9",
"phpstan/phpstan": "1.4.10 || 1.10.15",
"phpstan/phpstan-phpunit": "^1.0",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
"psalm/plugin-phpunit": "0.18.4",
"psr/log": "^1 || ^2 || ^3",
"vimeo/psalm": "4.30.0 || 5.12.0"
},
"suggest": {
"psr/log": "Allows logging deprecations via PSR-3 logger implementation"
},
"autoload": {
"psr-4": {
"Doctrine\\Deprecations\\": "lib/Doctrine/Deprecations"
}
},
"autoload-dev": {
"psr-4": {
"DeprecationTests\\": "test_fixtures/src",
"Doctrine\\Foo\\": "test_fixtures/vendor/doctrine/foo"
}
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}

View File

@ -0,0 +1,313 @@
<?php
declare(strict_types=1);
namespace Doctrine\Deprecations;
use Psr\Log\LoggerInterface;
use function array_key_exists;
use function array_reduce;
use function assert;
use function debug_backtrace;
use function sprintf;
use function str_replace;
use function strpos;
use function strrpos;
use function substr;
use function trigger_error;
use const DEBUG_BACKTRACE_IGNORE_ARGS;
use const DIRECTORY_SEPARATOR;
use const E_USER_DEPRECATED;
/**
* Manages Deprecation logging in different ways.
*
* By default triggered exceptions are not logged.
*
* To enable different deprecation logging mechanisms you can call the
* following methods:
*
* - Minimal collection of deprecations via getTriggeredDeprecations()
* \Doctrine\Deprecations\Deprecation::enableTrackingDeprecations();
*
* - Uses @trigger_error with E_USER_DEPRECATED
* \Doctrine\Deprecations\Deprecation::enableWithTriggerError();
*
* - Sends deprecation messages via a PSR-3 logger
* \Doctrine\Deprecations\Deprecation::enableWithPsrLogger($logger);
*
* Packages that trigger deprecations should use the `trigger()` or
* `triggerIfCalledFromOutside()` methods.
*/
class Deprecation
{
private const TYPE_NONE = 0;
private const TYPE_TRACK_DEPRECATIONS = 1;
private const TYPE_TRIGGER_ERROR = 2;
private const TYPE_PSR_LOGGER = 4;
/** @var int-mask-of<self::TYPE_*>|null */
private static $type;
/** @var LoggerInterface|null */
private static $logger;
/** @var array<string,bool> */
private static $ignoredPackages = [];
/** @var array<string,int> */
private static $triggeredDeprecations = [];
/** @var array<string,bool> */
private static $ignoredLinks = [];
/** @var bool */
private static $deduplication = true;
/**
* Trigger a deprecation for the given package and identfier.
*
* The link should point to a Github issue or Wiki entry detailing the
* deprecation. It is additionally used to de-duplicate the trigger of the
* same deprecation during a request.
*
* @param float|int|string $args
*/
public static function trigger(string $package, string $link, string $message, ...$args): void
{
$type = self::$type ?? self::getTypeFromEnv();
if ($type === self::TYPE_NONE) {
return;
}
if (isset(self::$ignoredLinks[$link])) {
return;
}
if (array_key_exists($link, self::$triggeredDeprecations)) {
self::$triggeredDeprecations[$link]++;
} else {
self::$triggeredDeprecations[$link] = 1;
}
if (self::$deduplication === true && self::$triggeredDeprecations[$link] > 1) {
return;
}
if (isset(self::$ignoredPackages[$package])) {
return;
}
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
$message = sprintf($message, ...$args);
self::delegateTriggerToBackend($message, $backtrace, $link, $package);
}
/**
* Trigger a deprecation for the given package and identifier when called from outside.
*
* "Outside" means we assume that $package is currently installed as a
* dependency and the caller is not a file in that package. When $package
* is installed as a root package then deprecations triggered from the
* tests folder are also considered "outside".
*
* This deprecation method assumes that you are using Composer to install
* the dependency and are using the default /vendor/ folder and not a
* Composer plugin to change the install location. The assumption is also
* that $package is the exact composer packge name.
*
* Compared to {@link trigger()} this method causes some overhead when
* deprecation tracking is enabled even during deduplication, because it
* needs to call {@link debug_backtrace()}
*
* @param float|int|string $args
*/
public static function triggerIfCalledFromOutside(string $package, string $link, string $message, ...$args): void
{
$type = self::$type ?? self::getTypeFromEnv();
if ($type === self::TYPE_NONE) {
return;
}
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 2);
// first check that the caller is not from a tests folder, in which case we always let deprecations pass
if (isset($backtrace[1]['file'], $backtrace[0]['file']) && strpos($backtrace[1]['file'], DIRECTORY_SEPARATOR . 'tests' . DIRECTORY_SEPARATOR) === false) {
$path = DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $package) . DIRECTORY_SEPARATOR;
if (strpos($backtrace[0]['file'], $path) === false) {
return;
}
if (strpos($backtrace[1]['file'], $path) !== false) {
return;
}
}
if (isset(self::$ignoredLinks[$link])) {
return;
}
if (array_key_exists($link, self::$triggeredDeprecations)) {
self::$triggeredDeprecations[$link]++;
} else {
self::$triggeredDeprecations[$link] = 1;
}
if (self::$deduplication === true && self::$triggeredDeprecations[$link] > 1) {
return;
}
if (isset(self::$ignoredPackages[$package])) {
return;
}
$message = sprintf($message, ...$args);
self::delegateTriggerToBackend($message, $backtrace, $link, $package);
}
/**
* @param list<array{function: string, line?: int, file?: string, class?: class-string, type?: string, args?: mixed[], object?: object}> $backtrace
*/
private static function delegateTriggerToBackend(string $message, array $backtrace, string $link, string $package): void
{
$type = self::$type ?? self::getTypeFromEnv();
if (($type & self::TYPE_PSR_LOGGER) > 0) {
$context = [
'file' => $backtrace[0]['file'] ?? null,
'line' => $backtrace[0]['line'] ?? null,
'package' => $package,
'link' => $link,
];
assert(self::$logger !== null);
self::$logger->notice($message, $context);
}
if (! (($type & self::TYPE_TRIGGER_ERROR) > 0)) {
return;
}
$message .= sprintf(
' (%s:%d called by %s:%d, %s, package %s)',
self::basename($backtrace[0]['file'] ?? 'native code'),
$backtrace[0]['line'] ?? 0,
self::basename($backtrace[1]['file'] ?? 'native code'),
$backtrace[1]['line'] ?? 0,
$link,
$package
);
@trigger_error($message, E_USER_DEPRECATED);
}
/**
* A non-local-aware version of PHPs basename function.
*/
private static function basename(string $filename): string
{
$pos = strrpos($filename, DIRECTORY_SEPARATOR);
if ($pos === false) {
return $filename;
}
return substr($filename, $pos + 1);
}
public static function enableTrackingDeprecations(): void
{
self::$type = self::$type ?? 0;
self::$type |= self::TYPE_TRACK_DEPRECATIONS;
}
public static function enableWithTriggerError(): void
{
self::$type = self::$type ?? 0;
self::$type |= self::TYPE_TRIGGER_ERROR;
}
public static function enableWithPsrLogger(LoggerInterface $logger): void
{
self::$type = self::$type ?? 0;
self::$type |= self::TYPE_PSR_LOGGER;
self::$logger = $logger;
}
public static function withoutDeduplication(): void
{
self::$deduplication = false;
}
public static function disable(): void
{
self::$type = self::TYPE_NONE;
self::$logger = null;
self::$deduplication = true;
self::$ignoredLinks = [];
foreach (self::$triggeredDeprecations as $link => $count) {
self::$triggeredDeprecations[$link] = 0;
}
}
public static function ignorePackage(string $packageName): void
{
self::$ignoredPackages[$packageName] = true;
}
public static function ignoreDeprecations(string ...$links): void
{
foreach ($links as $link) {
self::$ignoredLinks[$link] = true;
}
}
public static function getUniqueTriggeredDeprecationsCount(): int
{
return array_reduce(self::$triggeredDeprecations, static function (int $carry, int $count) {
return $carry + $count;
}, 0);
}
/**
* Returns each triggered deprecation link identifier and the amount of occurrences.
*
* @return array<string,int>
*/
public static function getTriggeredDeprecations(): array
{
return self::$triggeredDeprecations;
}
/**
* @return int-mask-of<self::TYPE_*>
*/
private static function getTypeFromEnv(): int
{
switch ($_SERVER['DOCTRINE_DEPRECATIONS'] ?? $_ENV['DOCTRINE_DEPRECATIONS'] ?? null) {
case 'trigger':
self::$type = self::TYPE_TRIGGER_ERROR;
break;
case 'track':
self::$type = self::TYPE_TRACK_DEPRECATIONS;
break;
default:
self::$type = self::TYPE_NONE;
break;
}
return self::$type;
}
}

Some files were not shown because too many files have changed in this diff Show More