diff --git a/account/application/controllers/Welcome.php b/account/application/controllers/Welcome.php index 32fb56f..1e948ed 100644 --- a/account/application/controllers/Welcome.php +++ b/account/application/controllers/Welcome.php @@ -111,6 +111,7 @@ class Welcome extends CI_Controller `created_by` VARCHAR(50) NOT NULL, `remarks` TEXT NOT NULL, `status` int(11) DEFAULT NULL, + `discount` DOUBLE(10, 2) NULL, PRIMARY KEY (`purchase_id`) )"); $this->db->query("CREATE TABLE IF NOT EXISTS `tbl_purchasedetails` ( @@ -134,6 +135,7 @@ class Welcome extends CI_Controller `created_by` VARCHAR(50) NOT NULL, `remarks` TEXT NOT NULL, `status` int(11) DEFAULT NULL, + `discount` DOUBLE(10, 2) NULL, PRIMARY KEY (`sales_id`) )"); $this->db->query("CREATE TABLE IF NOT EXISTS `tbl_salesdetails` ( diff --git a/account/application/controllers/accounts/Vouchers.php b/account/application/controllers/accounts/Vouchers.php index ce70755..030f4e7 100644 --- a/account/application/controllers/accounts/Vouchers.php +++ b/account/application/controllers/accounts/Vouchers.php @@ -143,6 +143,57 @@ class Vouchers extends CI_Controller endif; redirect("accounts/vouchers/listvouchers"); break; + + case 'saveaccount': + if (isset($_POST['submit'])) { + if (!$this->checkifAccountExists($_POST['account_name'])) { + $TableData = array( + 'accategory_id' => filter_var($_POST['accategory_id']), + // 'account_code' => generateAccountCode(filter_var($_POST['account_code'])), + 'account_name' => filter_var($_POST['account_name']), + // 'account_type' => filter_var($_POST['account_type']), + // 'account_plcategory' => filter_var($_POST['account_plcategory']), + // 'account_currency' => filter_var($_POST['account_currency']), + // 'account_partyname' => filter_var($_POST['account_partyname']), + // 'account_partyaddress' => filter_var($_POST['account_partyaddress']), + // 'account_partypan' => filter_var($_POST['account_partypan']), + // 'account_partycontact' => filter_var($_POST['account_partycontact']), + // 'account_partyemail' => filter_var($_POST['account_partyemail']), + // 'account_partycontactperson' => filter_var($_POST['account_partycontactperson']), + // 'account_partycontactpersoncontact' => filter_var($_POST['account_partycontactpersoncontact']), + 'created_on' => date('Y-m-d H:i:s'), + 'created_by' => 'admin', + 'remarks' => filter_var($_POST['remarks']), + 'status' => 1, + ); + $this->db->insert('tbl_accounts', $TableData); + $account_id = $this->db->insert_id(); + $voucherData = array( + "voucher_id" => 0, + "transaction_date" => date("Y-m-d"), + "account_id" => $account_id, + "Dr" => 0, + "Cr" => 0, + "fiscalyear_id" => $this->session->userdata['FiscalYearID'], + "created_on" => date('Y-m-d H:i:s'), + "branch_id" => $this->session->userdata("BranchID"), + "created_by" => $this->session->userdata("loggedUser"), + "remarks" => "Opening Balance Entry", + "status" => 1 + ); + if ($_POST['opening_balance_drcr'] == "DR") $voucherData['Dr'] = $_POST['opening_balance']; + if ($_POST['opening_balance_drcr'] == "CR") $voucherData['Cr'] = $_POST['opening_balance']; + $this->db->insert('tbl_voucherdetails', $voucherData); + redirect("accounts/accountheads/list"); + } else { + echo "Account Head Name Already Exists"; + die; + } + } + loadView("accounts/accountheads/add", $data); + break; + + default: if ($VoucherType = $this->myaccounts->getVoucherType($alias)) { $this->processVoucher($VoucherType); @@ -211,7 +262,7 @@ class Vouchers extends CI_Controller $entry_no++; - redirect("accounts/vouchers/" . $VoucherType->voucher_alias . "/list"); + echo json_encode(['status' => 'success']); break; } @@ -594,4 +645,8 @@ function footerfunctions() ?>"; file_put_contents($filename, $ListFileContent); } + function checkifAccountExists($account_name) + { + return ($this->db->query("select * from tbl_accounts where UPPER(account_name)='" . strtoupper($account_name) . "'")->num_rows() > 0) ? true : false; + } } diff --git a/account/application/controllers/inventory/Purchases.php b/account/application/controllers/inventory/Purchases.php index ce9c076..c4125fc 100644 --- a/account/application/controllers/inventory/Purchases.php +++ b/account/application/controllers/inventory/Purchases.php @@ -33,6 +33,7 @@ class Purchases extends CI_Controller 'transaction_type' => "Purchase Entry", 'accounts_id' => filter_var($_POST['accounts_id']), 'purchase_date' => filter_var($_POST['purchase_date']), + 'discount' => filter_var($_POST['discountpercentage']), 'created_on' => date('Y-m-d H:i:s'), 'created_by' => 'admin', 'remarks' => '', @@ -91,6 +92,13 @@ class Purchases extends CI_Controller $data['PurchaseRecords'] = $this->MPurchases->getPurchaseRecords(); loadView("inventory/purchases/register", $data); break; + + case 'getunitbyitem': + $id = $this->uri->segment(4); + $unit = $this->MStocks->getUnitByItemId($id); + echo json_encode($unit); + break; + default: $data['PurchaseRecords'] = $this->MPurchases->getPurchaseRecords(); loadView("inventory/purchases/list", $data); diff --git a/account/application/controllers/inventory/Reports.php b/account/application/controllers/inventory/Reports.php index c22b676..0e413bd 100644 --- a/account/application/controllers/inventory/Reports.php +++ b/account/application/controllers/inventory/Reports.php @@ -19,6 +19,7 @@ class Reports extends CI_Controller $data['StockRecords']=$this->MStocks->getStockRecords(); $data['PurchaseDetails'] = $this->MPurchases->getItemPurchases(); $data['SalesDetails'] = $this->MSales->getItemSales(); + $data['StockItems'] = $this->MStocks->getStockSummary(); loadview("inventory/reports/purchase_vs_sales", $data); break; default: diff --git a/account/application/controllers/inventory/Sales.php b/account/application/controllers/inventory/Sales.php index 5abece0..2dd5a72 100644 --- a/account/application/controllers/inventory/Sales.php +++ b/account/application/controllers/inventory/Sales.php @@ -29,6 +29,7 @@ class Sales extends CI_Controller 'transaction_type' => "Sales Entry", 'accounts_id' => filter_var($_POST['accounts_id']), 'sales_date' => filter_var($_POST['salesDate']), + 'discount' => filter_var($_POST['discountpercentage']), 'created_on' => date('Y-m-d H:i:s'), 'created_by' => 'admin', 'remarks' => '', @@ -79,6 +80,7 @@ class Sales extends CI_Controller 'transaction_type' => filter_var($_POST['transaction_type']), 'accounts_id' => filter_var($_POST['accounts_id']), 'sales_date' => filter_var($_POST['sales_date']), + 'discount' => filter_var($_POST['discountpercentage']), 'created_on' => date('Y-m-d H:i:s'), 'created_by' => 'admin', 'remarks' => filter_var($_POST['remarks']), @@ -98,11 +100,20 @@ class Sales extends CI_Controller $this->db->delete('tbl_salesdetails'); redirect("inventory/sales/list"); 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/controllers/master/Accategories.php b/account/application/controllers/master/Accategories.php index 81d847b..fd61bcd 100644 --- a/account/application/controllers/master/Accategories.php +++ b/account/application/controllers/master/Accategories.php @@ -91,7 +91,8 @@ class Accategories extends CI_Controller if (isset($_POST['submit'])) { $TableData = array( - 'acgroup_id' => filter_var($_POST['acgroup_id']), + 'acgroup_id' => filter_var(getFieldfromValue("tbl_accategories", "acgroup_id", "accategory_id", $_POST['parent_category_id'])), + // 'acgroup_id' => filter_var($_POST['acgroup_id']), 'accategory_code' => generateACCategoryCode($_POST['acgroup_id']), 'parent_category_id' => filter_var($_POST['parent_category_id']), 'accategory_name' => filter_var($_POST['accategory_name']), @@ -105,10 +106,13 @@ class Accategories extends CI_Controller redirect("master/accategories"); } $data['AccountCategory'] = $this->db->query("select * from tbl_accategories where accategory_id =\"$id\" ")->row(); - loadView("accounts/accategories/edit", $data); + $data['ACCategories'] = $this->myaccounts->getAccountCategories(); + $data['pageTitle'] = "Account Group"; + + loadView("accounts/accategories/list-childs-only", $data); break; case 'edit_parents': - $id = $this->uri->segment(4); + $id = $this->uri->segment(4); $data['pageTitle'] = "Edit Category"; if (isset($_POST['submit'])) { diff --git a/account/application/libraries/Myaccounts.php b/account/application/libraries/Myaccounts.php index 65f72b7..ee725fb 100644 --- a/account/application/libraries/Myaccounts.php +++ b/account/application/libraries/Myaccounts.php @@ -157,7 +157,7 @@ class myaccounts $ci = &get_instance(); return $ci->db->where("status", 1)->where("account_id", $account_id)->select_sum('cr')->get("tbl_voucherdetails")->row()->cr; } - function getAllAccountsTable($accategory_id = "") + function getAllAccountsTable($accategory_id = "", $full = "") { $CI = &get_instance(); if ($accategory_id != "") { @@ -208,7 +208,9 @@ class myaccounts $html .= "" . $Account->account_name . "" . $Account->Category->accategory_name . "" . (($balance >= 0) ? myCurrency($balance) : "") . "" . (($balance < 0) ? myCurrency(abs($balance)) : "") . ""; endforeach; $html .= ""; - $html .= "Total" . myCurrency($BalanceTotal) . "" . myCurrency($BalanceTotal) . ""; + if ($full==""){ + $html .= "Total" . myCurrency($BalanceTotal) . "" . myCurrency($BalanceTotal) . ""; + } $html .= "\n"; $html .= "
@@ -1013,7 +1015,9 @@ class myaccounts - + + + Total diff --git a/account/application/models/MStocks.php b/account/application/models/MStocks.php index 3d1e572..7cfb1a8 100644 --- a/account/application/models/MStocks.php +++ b/account/application/models/MStocks.php @@ -144,6 +144,7 @@ class MStocks extends CI_Model $Item->Item = $this->db->where("item_id", $item_id)->get("tbl_items")->row(); $Item->qty = $this->db->where("items_id", $item_id)->select("sum(qty) as qty")->get("tbl_stocks")->row()->qty; $Item->amount = $this->db->where("items_id", $item_id)->select("sum(price * qty) as amount")->get("tbl_stocks")->row()->amount; + $Item->Unit = $this->db->where("unit_id", $Item->Item->units_id)->get("tbl_units")->row(); $Item->Opening = $this->getOpeningStock($item_id); $Item->Purchase = $this->getItemPurchaseStock($item_id); $Item->Sales = $this->getItemSalesStock($item_id); @@ -208,13 +209,12 @@ class MStocks extends CI_Model $this->db->insert("tbl_stocks", $TableData); } } - // public function getUnitByItemId($id) - // { - // $this->db->where('status', 1); - // $Item = $this->db->where("item_id", $id)->get("tbl_items")->row(); - // $Unit = $this->db->where("unit_id", $Item->units_id)->get("tbl_units")->row(); - // $unitname = $Unit->title; - // return $unitname; + public function getUnitByItemId($id) + { + $this->db->where('status', 1); + $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; - // } + } } diff --git a/account/application/views/accounts/accategories/list-childs-only.php b/account/application/views/accounts/accategories/list-childs-only.php index 488d952..d92f6b4 100644 --- a/account/application/views/accounts/accategories/list-childs-only.php +++ b/account/application/views/accounts/accategories/list-childs-only.php @@ -5,19 +5,25 @@
-
Create +
+
-
" enctype="multipart/form-data" name="tbl_accategories"> + uri->segment(2) . "/edit/" . $AccountCategory->accategory_id) : site_url($this->uri->segment(1) . "/" . $this->uri->segment(2) . "/add_child"); ?>" enctype="multipart/form-data" name="tbl_accategories"> +
- + + " name="accategory_name" required>
@@ -26,7 +32,11 @@
- myaccounts->showFixedAccountsCategoriesCombo("parent_category_id", " Under", "parent_category_id", "status=1", $default = "", $CSSclass = ""); ?> + 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 = ""); + + ?> @@ -38,7 +48,7 @@
- +
@@ -59,7 +69,7 @@
- + @@ -74,7 +84,7 @@ + foreach ($AccountCategory as $TableRow) : $sn++; ?> diff --git a/account/application/views/accounts/balances/bycategory.php b/account/application/views/accounts/balances/bycategory.php index 2b95078..c0a00a1 100644 --- a/account/application/views/accounts/balances/bycategory.php +++ b/account/application/views/accounts/balances/bycategory.php @@ -90,112 +90,5 @@ function displayCategoryTree($tree) { -
-
- -
- - -
- - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
ParticularsOpeningThis YearClosing
Dr. AmountCr. AmountDr. AmountCr. AmountDr. AmountCr. Amount
10
Current Assets
Bank Assets
Nabil Bank
RBB Bank
Another Grandchild
Child 1
Child 2
- -
- -
- -
- + \ No newline at end of file diff --git a/account/application/views/accounts/ledgerall.php b/account/application/views/accounts/ledgerall.php index 0d79c33..ae63143 100644 --- a/account/application/views/accounts/ledgerall.php +++ b/account/application/views/accounts/ledgerall.php @@ -11,7 +11,7 @@
- myaccounts->getAllAccountsTable(); ?> + myaccounts->getAllAccountsTable($accategory_id = "", $full=-1); ?>
diff --git a/account/application/views/accounts/vouchers/create.php b/account/application/views/accounts/vouchers/create.php index 38e71c1..85f52c6 100644 --- a/account/application/views/accounts/vouchers/create.php +++ b/account/application/views/accounts/vouchers/create.php @@ -243,7 +243,7 @@ button:hover {
- +