diff --git a/account/application/controllers/inventory/Itemcategories.php b/account/application/controllers/inventory/Itemcategories.php index 08ebcbc..d56bc91 100644 --- a/account/application/controllers/inventory/Itemcategories.php +++ b/account/application/controllers/inventory/Itemcategories.php @@ -17,42 +17,60 @@ class Itemcategories extends CI_Controller switch ($alias) { case 'add': if (isset($_POST['submit'])) { - $TableData = array( - 'units_id' => filter_var($_POST['units_id']), - 'title' => filter_var($_POST['title']), - 'description' => filter_var($_POST['description']), - 'display_order' => filter_var($_POST['display_order']), - 'status' => 1, - 'remarks' => filter_var($_POST['remarks']), - 'created_on' => date('Y-m-d H:i:s'), - 'created_by' => 'admin', - ); - $this->db->insert('tbl_itemcategories', $TableData); - redirect("inventory/itemcategories/list"); + $title = filter_var($_POST['title']); + $this->db->where('title',$title); + $query = $this->db->get('tbl_itemcategories'); + if($query->num_rows() > 0){ + echo "Title or code already exists.";die; + }else{ + $TableData = array( + 'units_id' => filter_var($_POST['units_id']), + 'title' => filter_var($_POST['title']), + 'description' => filter_var($_POST['description']), + 'display_order' => filter_var($_POST['display_order']), + 'status' => 1, + 'remarks' => filter_var($_POST['remarks']), + 'created_on' => date('Y-m-d H:i:s'), + 'created_by' => 'admin', + ); + $this->db->insert('tbl_itemcategories', $TableData); + redirect("inventory/itemcategories/list"); + } } loadView("inventory/itemcategories/add", $data); break; case 'edit': if (isset($_POST['submit'])) { $id = $this->uri->segment(4); - $TableData = array( - 'units_id' => filter_var($_POST['units_id']), - 'title' => filter_var($_POST['title']), - 'description' => filter_var($_POST['description']), - 'display_order' => filter_var($_POST['display_order']), - 'status' => 1, - 'remarks' => filter_var($_POST['remarks']), - 'created_on' => date('Y-m-d H:i:s'), - 'created_by' => 'admin', - ); - $this->db->where('itemcategory_id', $id); - $this->db->update('tbl_itemcategories', $TableData); - redirect("inventory/itemcategories/list"); + + $title = filter_var($_POST['title']); + $this->db->where('status',1); + $this->db->where('itemcategory_id !=', $id); + $this->db->where('title',$title); + + $query = $this->db->get('tbl_itemcategories'); + if($query->num_rows() > 0){ + echo "Title or description already exists.";die; + }else{ + $TableData = array( + 'units_id' => filter_var($_POST['units_id']), + 'title' => filter_var($_POST['title']), + 'description' => filter_var($_POST['description']), + 'display_order' => filter_var($_POST['display_order']), + 'status' => 1, + 'remarks' => filter_var($_POST['remarks']), + 'created_on' => date('Y-m-d H:i:s'), + 'created_by' => 'admin', + ); + $this->db->where('itemcategory_id', $id); + $this->db->update('tbl_itemcategories', $TableData); + redirect("inventory/itemcategories/list"); + } } $id = $this->uri->segment(4); $this->db->where('itemcategory_id', $id); $data['itemcategory']=$this->db->get("tbl_itemcategories")->row(); - loadView("inventory/itemcategories/add", $data); + loadView("inventory/itemcategories/list", $data); break; case 'delete': $id = $this->uri->segment(4); diff --git a/account/application/controllers/inventory/Items.php b/account/application/controllers/inventory/Items.php index 340395d..d27fcf2 100644 --- a/account/application/controllers/inventory/Items.php +++ b/account/application/controllers/inventory/Items.php @@ -23,45 +23,67 @@ class Items extends CI_Controller switch ($alias) { case 'add': if (isset($_POST['submit'])) { - $TableData = array( - 'itemcategories_id' => filter_var($_POST['itemcategories_id']), - 'item_code' => filter_var($_POST['item_code']), - 'title' => filter_var($_POST['title']), - 'description' => filter_var($_POST['description']), - 'units_id' => filter_var($_POST['units_id']), - 'status' => 1, - 'created_on' => date('Y-m-d H:i:s'), - 'created_by' => 'admin', - ); - $this->db->insert('tbl_items', $TableData); - $item_id = $this->db->insert_id(); - $id = $item_id; - $qty = $_POST['opening_stock']; - $rate = $_POST['opening_stock_rate']; - $this->MStocks->addOpeningStock($id, $qty, $rate); - redirect("inventory/items/list"); + $title = filter_var($_POST['title']); + $item_code = filter_var($_POST['item_code']); + $this->db->where('title',$title); + $this->db->or_where('item_code',$item_code); + $query = $this->db->get('tbl_items'); + if($query->num_rows() > 0){ + echo "Title or code already exists.";die; + }else{ + $TableData = array( + 'itemcategories_id' => filter_var($_POST['itemcategories_id']), + 'item_code' => filter_var($_POST['item_code']), + 'title' => filter_var($_POST['title']), + 'description' => filter_var($_POST['description']), + 'units_id' => filter_var($_POST['units_id']), + 'status' => 1, + 'created_on' => date('Y-m-d H:i:s'), + 'created_by' => 'admin', + ); + $this->db->insert('tbl_items', $TableData); + $item_id = $this->db->insert_id(); + $id = $item_id; + $qty = $_POST['opening_stock']; + $rate = $_POST['opening_stock_rate']; + $this->MStocks->addOpeningStock($id, $qty, $rate); + redirect("inventory/items/list"); + } } loadView("inventory/items/add", $data); break; case 'edit': if (isset($_POST['submit'])) { $id = $this->uri->segment(4); - $TableData = array( - 'itemcategories_id' => filter_var($_POST['itemcategories_id']), - 'item_code' => filter_var($_POST['item_code']), - 'title' => filter_var($_POST['title']), - 'description' => filter_var($_POST['description']), - 'units_id' => filter_var($_POST['units_id']), - 'status' => 1, - 'created_on' => date('Y-m-d H:i:s'), - 'created_by' => 'admin', - ); - $this->db->where('item_id', $id); - $this->db->update('tbl_items', $TableData); - $qty = $_POST['opening_stock']; - $rate = $_POST['opening_stock_rate']; - $this->MStocks->updateOpeningStock($id, $qty, $rate); - redirect("inventory/items/list"); + + $title = filter_var($_POST['title']); + $item_code = filter_var($_POST['item_code']); + $this->db->where('status',1); + $this->db->where('item_id !=', $id); + $this->db->where('title',$title); + $this->db->or_where('item_code',$item_code); + + $query = $this->db->get('tbl_items'); + if($query->num_rows() > 0){ + echo "Title or description already exists.";die; + }else{ + $TableData = array( + 'itemcategories_id' => filter_var($_POST['itemcategories_id']), + 'item_code' => filter_var($_POST['item_code']), + 'title' => filter_var($_POST['title']), + 'description' => filter_var($_POST['description']), + 'units_id' => filter_var($_POST['units_id']), + 'status' => 1, + 'created_on' => date('Y-m-d H:i:s'), + 'created_by' => 'admin', + ); + $this->db->where('item_id', $id); + $this->db->update('tbl_items', $TableData); + $qty = $_POST['opening_stock']; + $rate = $_POST['opening_stock_rate']; + $this->MStocks->updateOpeningStock($id, $qty, $rate); + redirect("inventory/items/list"); + } } $id = $this->uri->segment(4); $this->db->where('item_id', $id); diff --git a/account/application/controllers/inventory/Purchases.php b/account/application/controllers/inventory/Purchases.php index d905c32..ce9c076 100644 --- a/account/application/controllers/inventory/Purchases.php +++ b/account/application/controllers/inventory/Purchases.php @@ -90,6 +90,7 @@ class Purchases extends CI_Controller case 'purchase_register': $data['PurchaseRecords'] = $this->MPurchases->getPurchaseRecords(); loadView("inventory/purchases/register", $data); + break; default: $data['PurchaseRecords'] = $this->MPurchases->getPurchaseRecords(); loadView("inventory/purchases/list", $data); diff --git a/account/application/controllers/inventory/Sales.php b/account/application/controllers/inventory/Sales.php index 9bf31f1..5abece0 100644 --- a/account/application/controllers/inventory/Sales.php +++ b/account/application/controllers/inventory/Sales.php @@ -9,6 +9,9 @@ class Sales extends CI_Controller $this->load->model('MSales'); checkLogin(); } + + + public function _remap($alias = "", $params = array()) { $data['dataValue'] = $this->session; @@ -100,4 +103,9 @@ class Sales extends CI_Controller loadView("inventory/sales/list", $data); } } + + // public function getUnitByItemId($id) { + // $unitName = $this->MStocks->getUnitByItemId($id); + // echo json_encode(['unitName' => $unitName]); + // } } diff --git a/account/application/controllers/inventory/Units.php b/account/application/controllers/inventory/Units.php index 9259bac..141f789 100644 --- a/account/application/controllers/inventory/Units.php +++ b/account/application/controllers/inventory/Units.php @@ -17,7 +17,15 @@ class Units extends CI_Controller switch ($alias) { case 'add': if (isset($_POST['submit'])) { - $TableData = array( + $title = filter_var($_POST['title']); + $description = filter_var($_POST['description']); + $this->db->where('title',$title); + $this->db->or_where('description',$description); + $query = $this->db->get('tbl_units'); + if($query->num_rows() > 0){ + echo "Title or code already exists.";die; + }else{ + $TableData = array( 'title' => filter_var($_POST['title']), 'alias' => filter_var($_POST['alias']), 'description' => filter_var($_POST['description']), @@ -26,33 +34,48 @@ class Units extends CI_Controller 'remarks' => filter_var($_POST['remarks']), 'created_on' => date('Y-m-d H:i:s'), 'created_by' => 'admin', - ); - $this->db->insert('tbl_units', $TableData); - redirect("inventory/units/list"); + ); + $this->db->insert('tbl_units', $TableData); + redirect("inventory/units/list"); + } + } loadView("inventory/units/add", $data); break; case 'edit': if (isset($_POST['submit'])) { $id = $this->uri->segment(4); - $TableData = array( - 'title' => filter_var($_POST['title']), - 'alias' => filter_var($_POST['alias']), - 'description' => filter_var($_POST['description']), - 'display_order' => filter_var($_POST['display_order']), - 'status' => 1, - 'remarks' => filter_var($_POST['remarks']), - 'created_on' => date('Y-m-d H:i:s'), - 'created_by' => 'admin', - ); - $this->db->where('unit_id', $id); - $this->db->update('tbl_units', $TableData); - redirect("inventory/units/list"); + + $title = filter_var($_POST['title']); + $description = filter_var($_POST['description']); + $this->db->where('status',1); + $this->db->where('unit_id !=', $id); + $this->db->where('title',$title); + $this->db->or_where('description',$description); + + $query = $this->db->get('tbl_units'); + if($query->num_rows() > 0){ + echo "Title or description already exists.";die; + }else{ + $TableData = array( + 'title' => filter_var($_POST['title']), + 'alias' => filter_var($_POST['alias']), + 'description' => filter_var($_POST['description']), + 'display_order' => filter_var($_POST['display_order']), + 'status' => 1, + 'remarks' => filter_var($_POST['remarks']), + 'created_on' => date('Y-m-d H:i:s'), + 'created_by' => 'admin', + ); + $this->db->where('unit_id', $id); + $this->db->update('tbl_units', $TableData); + redirect("inventory/units/list"); + } } $id = $this->uri->segment(4); $this->db->where('unit_id', $id); $data['unit'] = $this->db->get("tbl_units")->row(); - loadView("inventory/units/add", $data); + loadView("inventory/units/list", $data); break; case 'delete': $id = $this->uri->segment(4); diff --git a/account/application/controllers/master/Accategories.php b/account/application/controllers/master/Accategories.php index f4aad6e..81d847b 100644 --- a/account/application/controllers/master/Accategories.php +++ b/account/application/controllers/master/Accategories.php @@ -158,7 +158,7 @@ class Accategories extends CI_Controller loadView("accounts/accategories/list-parents-only", $data); break; case 'childs': - $data['pageTitle'] = "Account Groups"; + $data['pageTitle'] = "Account Group"; // $data['ACCategories'] = $this->db->query("select *, (select accategory_name from tbl_accategories as a where a.parent_category_id=b.accategory_id) as parent_category, (select acgroup_name from tbl_acgroups where tbl_acgroups.acgroup_id=b.acgroup_id) as acgroup_name from tbl_accategories as b where status=1")->result(); $data['ACCategories'] = $this->myaccounts->getAccountCategories(); diff --git a/account/application/libraries/Myaccounts.php b/account/application/libraries/Myaccounts.php index a196914..65f72b7 100644 --- a/account/application/libraries/Myaccounts.php +++ b/account/application/libraries/Myaccounts.php @@ -222,10 +222,10 @@ class myaccounts
Ledger Details Goes Here
-
+
"; diff --git a/account/application/models/MStocks.php b/account/application/models/MStocks.php index 4b62dc1..3d1e572 100644 --- a/account/application/models/MStocks.php +++ b/account/application/models/MStocks.php @@ -208,4 +208,13 @@ 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; + + // } } diff --git a/account/application/views/accounts/accategories/list-childs-only.php b/account/application/views/accounts/accategories/list-childs-only.php index e7bd554..488d952 100644 --- a/account/application/views/accounts/accategories/list-childs-only.php +++ b/account/application/views/accounts/accategories/list-childs-only.php @@ -52,7 +52,7 @@
-
+
diff --git a/account/application/views/accounts/daybook.php b/account/application/views/accounts/daybook.php index 4dae6bb..7f7778f 100644 --- a/account/application/views/accounts/daybook.php +++ b/account/application/views/accounts/daybook.php @@ -23,7 +23,7 @@
Ledger Details Goes Here
-
diff --git a/account/application/views/accounts/ledger/partywise.php b/account/application/views/accounts/ledger/partywise.php index 1b2bc98..f35d302 100644 --- a/account/application/views/accounts/ledger/partywise.php +++ b/account/application/views/accounts/ledger/partywise.php @@ -18,7 +18,7 @@
-
myaccounts->showAccountsCombo("account_id", "", "account_id", "status=1", isset($_GET['account_id']) ? $_GET['account_id'] : '', $CSSclass = ""); ?>
+
myaccounts->showAccountsCombo("account_id", "", "account_id", "status=1", isset($_GET['account_id']) ? $_GET['account_id'] : 1, $CSSclass = ""); ?>
@@ -31,7 +31,11 @@
- + Ledger Details Goes Here -
+
"; diff --git a/account/application/views/accounts/ledger_cashbook.php b/account/application/views/accounts/ledger_cashbook.php index fa9c988..9941cce 100644 --- a/account/application/views/accounts/ledger_cashbook.php +++ b/account/application/views/accounts/ledger_cashbook.php @@ -61,10 +61,10 @@
Ledger Details Goes Here
-
+
"; diff --git a/account/application/views/inventory/itemcategories/list.php b/account/application/views/inventory/itemcategories/list.php index c5a16bf..21c2759 100644 --- a/account/application/views/inventory/itemcategories/list.php +++ b/account/application/views/inventory/itemcategories/list.php @@ -43,7 +43,7 @@
- +
@@ -84,13 +84,13 @@
db->query("select * from tbl_itemcategories where status=1")->result(); ?> - +
- + diff --git a/account/application/views/inventory/items/list.php b/account/application/views/inventory/items/list.php index 81c4471..ee43982 100644 --- a/account/application/views/inventory/items/list.php +++ b/account/application/views/inventory/items/list.php @@ -114,7 +114,7 @@
-
+
diff --git a/account/application/views/inventory/sales/create.php b/account/application/views/inventory/sales/create.php index 844c1ac..8814709 100644 --- a/account/application/views/inventory/sales/create.php +++ b/account/application/views/inventory/sales/create.php @@ -174,6 +174,33 @@ // newRow.find('.select2').select2(); // calculateTotals(); }); + + // $(document).on('change', '.select_item', function(){ + + // var selectedOption = $(this).find(':selected'); + // var selectedValue = selectedOption.val(); + // alert(selectedValue); + // var unitInput = $(this).closest('.sales-detail-duplicator').find('.item_unit'); + // if (selectedValue) { + // $.ajax({ + // url: 'application/controllers/inventory/Sales/getUnitByItemId/' + selectedValue, + // method: 'POST', + // success: function(response) { + // console.log(response); + // unitInput.val(unitName); + // alert("Selected Item Value: " + selectedValue + "\nUnit: " + unitName); + // }, + // error: function() { + // alert("Error retrieving unit data."); + // } + // }); + // } else { + // unitInput.val(''); + // alert("No item selected."); + // } + // }); + + // $(document).on("click", ".remove-sales-detail", function() { // $(this).closest(".sales-detail").remove(); // calculateTotals(); diff --git a/account/application/views/inventory/units/list.php b/account/application/views/inventory/units/list.php index c17c21f..c80f643 100644 --- a/account/application/views/inventory/units/list.php +++ b/account/application/views/inventory/units/list.php @@ -34,7 +34,7 @@
- description : ''; ?> +
@@ -65,7 +65,7 @@
db->query("select * from tbl_units where status=1")->result(); ?> -
+
diff --git a/account/application/views/translations/list.php b/account/application/views/translations/list.php index 0d42cad..bf0f72b 100644 --- a/account/application/views/translations/list.php +++ b/account/application/views/translations/list.php @@ -15,7 +15,7 @@
db->query("select * from tbl_translations where status=1")->result(); ?> -
+
diff --git a/account/pdf/ledgers/ledger_28.wpdf b/account/pdf/ledgers/ledger_28.wpdf new file mode 100644 index 0000000..458d9e6 Binary files /dev/null and b/account/pdf/ledgers/ledger_28.wpdf differ diff --git a/account/pdf/ledgers/ledger_5.wpdf b/account/pdf/ledgers/ledger_5.wpdf new file mode 100644 index 0000000..9998d05 Binary files /dev/null and b/account/pdf/ledgers/ledger_5.wpdf differ diff --git a/account/pdf/vouchers/Voucher_2.pdf b/account/pdf/vouchers/Voucher_2.pdf index a041a82..8c4e7cb 100644 Binary files a/account/pdf/vouchers/Voucher_2.pdf and b/account/pdf/vouchers/Voucher_2.pdf differ