From 7008ec0310a839bd120f5cecf97285d85d39e25e Mon Sep 17 00:00:00 2001 From: Roshan Date: Thu, 17 Oct 2024 17:06:13 +0545 Subject: [PATCH] New changes in BBNepal --- .../controllers/accounts/Reports.php | 6 +- .../controllers/inventory/Purchases.php | 22 +++- .../controllers/inventory/Sales.php | 39 ++++-- account/application/models/MPurchases.php | 4 +- account/application/models/MSales.php | 6 +- .../views/inventory/purchases/register.php | 114 +++++++++++++++++- .../views/inventory/sales/register.php | 108 +++++++++++++++-- 7 files changed, 261 insertions(+), 38 deletions(-) diff --git a/account/application/controllers/accounts/Reports.php b/account/application/controllers/accounts/Reports.php index b238497..68c73e8 100644 --- a/account/application/controllers/accounts/Reports.php +++ b/account/application/controllers/accounts/Reports.php @@ -162,7 +162,7 @@ class Reports extends CI_Controller $data['pageTitle'] = "Profit & Loss Statement"; loadView("accounts/pl", $data); break; - case 'pl': + case 'pl': if (!isset($_POST['fromDate'])) { $data['fromDate'] = null; } @@ -170,12 +170,12 @@ class Reports extends CI_Controller $data['toDate'] = null; } if (isset($_POST)) { - $data = $_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); + loadView("accounts/pl_new", $data); break; case 'pl_grouped': diff --git a/account/application/controllers/inventory/Purchases.php b/account/application/controllers/inventory/Purchases.php index 5351777..36567a3 100644 --- a/account/application/controllers/inventory/Purchases.php +++ b/account/application/controllers/inventory/Purchases.php @@ -77,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,8 +93,22 @@ class Purchases extends CI_Controller $this->db->delete('tbl_purchasedetails'); redirect("inventory/purchases/list"); break; - case 'purchase_register': - $data['PurchaseRecords'] = $this->MPurchases->getPurchaseRecords(); + case 'purchase_register': + 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; diff --git a/account/application/controllers/inventory/Sales.php b/account/application/controllers/inventory/Sales.php index 2540937..6176395 100644 --- a/account/application/controllers/inventory/Sales.php +++ b/account/application/controllers/inventory/Sales.php @@ -10,8 +10,8 @@ class Sales extends CI_Controller checkLogin(); } - - + + public function _remap($alias = "", $params = array()) { $data['dataValue'] = $this->session; @@ -62,13 +62,27 @@ class Sales extends CI_Controller } // print_r($TableData); // die; - - // $this->db->where('sales_id', $sales_id); - $this->MStocks->addSalesToStock($this->db->where('sales_id', $sales_id)->get('tbl_salesdetails')->result()); + + // $this->db->where('sales_id', $sales_id); + $this->MStocks->addSalesToStock($this->db->where('sales_id', $sales_id)->get('tbl_salesdetails')->result()); 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': @@ -105,19 +119,18 @@ class Sales extends CI_Controller redirect("inventory/sales/list"); break; - case 'getunitbyitem': - $id = $this->uri->segment(4); - $unit = $this->MStocks->getUnitByItemId($id); - echo json_encode($unit); - break; + case 'getunitbyitem': + $id = $this->uri->segment(4); + $unit = $this->MStocks->getUnitByItemId($id); + echo json_encode($unit); + break; default: $data['SalesRecords'] = $this->MSales->getSalesRecords(); loadView("inventory/sales/list", $data); } - } - + // public function getUnitByItemId($id) { // $unitName = $this->MStocks->getUnitByItemId($id); diff --git a/account/application/models/MPurchases.php b/account/application/models/MPurchases.php index f9efa55..7b4b3a4 100644 --- a/account/application/models/MPurchases.php +++ b/account/application/models/MPurchases.php @@ -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); diff --git a/account/application/models/MSales.php b/account/application/models/MSales.php index e94b3be..78c9157 100644 --- a/account/application/models/MSales.php +++ b/account/application/models/MSales.php @@ -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); @@ -57,7 +57,7 @@ class MSales extends CI_Model } $this->db->group_by('items_id'); $query = $this->db->get(); - $SalesRecords=$query->result(); + $SalesRecords = $query->result(); foreach ($SalesRecords as $SalesRecord) { $SalesRecord->Item = $this->db->where("item_id", $SalesRecord->items_id)->get("tbl_items")->row(); } diff --git a/account/application/views/inventory/purchases/register.php b/account/application/views/inventory/purchases/register.php index 6231fcc..da415d7 100644 --- a/account/application/views/inventory/purchases/register.php +++ b/account/application/views/inventory/purchases/register.php @@ -7,21 +7,90 @@
+
+ +
+ + +
+
+ + + + +
+ + +
db->query("select * from tbl_purchases where status=1")->result(); ?> - +
- + - purchase_id; ?> @@ -49,4 +118,41 @@ - \ No newline at end of file + + + + + + + \ No newline at end of file diff --git a/account/application/views/inventory/sales/register.php b/account/application/views/inventory/sales/register.php index 0f11011..27b12bd 100644 --- a/account/application/views/inventory/sales/register.php +++ b/account/application/views/inventory/sales/register.php @@ -6,13 +6,66 @@
uri->segment(2) . "/create"); ?>" class="btn btn-sm btn-primary float-right">Create New + +
+ +
+ + +
+
+ +
+ + + +
db->query("select * from tbl_sales where status=1")->result(); ?> -
Action
+
- + @@ -21,22 +74,22 @@ - - - $TableRow) : ?> + + + $TableRow) : ?> - + - +
sales_id; ?> Details[$key]->Item->title) ?? ""; ?> sales_date; ?>myaccounts->getAccountDetails($TableRow->accounts_id)->account_name)?? ""); ?> - myaccounts->getAccountDetails($TableRow->accounts_id)->account_name) ?? ""); ?> + totalsales); ?> uri->segment(1) . "/" . $this->uri->segment(2) . "/details/$TableRow->sales_id"); ?> sales_id); ?>
+ + + \ No newline at end of file