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 .= "