From 36a8ac8ccc8b2bc7ba5af92049e3e3c599356d87 Mon Sep 17 00:00:00 2001 From: vadivelJ96 Date: Thu, 21 Nov 2024 13:30:48 +0530 Subject: [PATCH] changes in master details-1 vadivel J 21-11-2024 --- app/Config/Routes.php | 4 +- app/Controllers/Assetdetails.php | 27 ++++++++ app/Controllers/CostCenter.php | 7 +- app/Controllers/Supplier.php | 6 +- app/Models/Assetdetails_model.php | 21 ++++++ app/Models/Costcenter_model.php | 2 +- app/Models/Rawmaterialdetails_model.php | 2 +- app/Models/Supplier_model.php | 3 +- app/Views/addRawMaterial.php | 7 +- app/Views/addSupplier.php | 10 ++- app/Views/assetListing.php | 87 ++++++++++++++++++++++++- app/Views/costListing.php | 14 ++-- app/Views/editRawmaterial.php | 5 +- app/Views/editSupplier.php | 6 +- app/Views/rawmaterialListing.php | 4 +- app/Views/transporterListing.php | 28 ++++++-- 16 files changed, 198 insertions(+), 35 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 2f22d3ee..7a724f16 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -81,8 +81,10 @@ $routes->get('assetListing', 'Assetdetails::assetListing'); $routes->get('addasset', 'Assetdetails::addasset'); $routes->post('assetdetails/getpodetails','Assetdetails::getpodetails'); $routes->post('assetdetails/getline','Assetdetails::getline'); - $routes->get('assetdetails/editOldasset', 'Assetdetails::editOldasset'); +$routes->get('assetdetails/deleteAsset', 'Assetdetails::deleteAsset'); +$routes->get('assetdetails/reActivateAsset', 'Assetdetails::reActivateAsset'); + //uncommenting addNewAsset $routes->post('addNewasset', 'Assetdetails::addNewasset'); $routes->match(['GET', 'POST', 'PUT', 'DELETE'],'editOldasset', 'Assetdetails::editasset'); diff --git a/app/Controllers/Assetdetails.php b/app/Controllers/Assetdetails.php index 97aa6bdc..49b1a850 100755 --- a/app/Controllers/Assetdetails.php +++ b/app/Controllers/Assetdetails.php @@ -8,6 +8,7 @@ use App\Models\Assetdetails_model; use CodeIgniter\Validation\Exceptions\ValidationException; use PhpOffice\PhpSpreadsheet\Spreadsheet; use PhpOffice\PhpSpreadsheet\Writer\Xlsx; +use DateTime; /** * Module : Asset * Assetdetails Class to control all asset related operations. @@ -316,6 +317,32 @@ class Assetdetails extends BaseController $this->loadViews("editOldasset", $this->global, $data, NULL); } + function deleteAsset(){ + + $assetCode = $this->request->getGet('AssetID'); + $updatedBy = $this->session->get('userId'); + $updatedDate = new DateTime(); + $updatedDate = $updatedDate->format('Y-m-d H:i:s'); + $assetInfo = array('IsActive' => 0 , 'UpdatedDate' => $updatedDate , 'UpdatedBy' => $updatedBy ); + $result = $this->assetdetails_model->deleteAsset($assetCode , $assetInfo); + + return redirect()->route('assetListing'); + + } + + function reActivateAsset(){ + + $assetCode = $this->request->getGet('AssetID'); + $updatedBy = $this->session->get('userId'); + $updatedDate = new DateTime(); + $updatedDate = $updatedDate->format('Y-m-d H:i:s'); + $assetInfo = array('IsActive' => 1 , 'UpdatedDate' => $updatedDate , 'UpdatedBy' => $updatedBy ); + $result = $this->assetdetails_model->deleteAsset($assetCode , $assetInfo); + + return redirect()->route('assetListing'); + + } + /** * This function is used to edit the user information diff --git a/app/Controllers/CostCenter.php b/app/Controllers/CostCenter.php index 04066286..62393226 100755 --- a/app/Controllers/CostCenter.php +++ b/app/Controllers/CostCenter.php @@ -137,11 +137,8 @@ class CostCenter extends BaseController function checkCostCenter(){ $data = $this->request->getPost(); $result = $this->costcenter_model->checkCostCenter( $data['CostCenterName']); - if(empty($result)){ - echo false; - }else{ - echo true; - } + + return $this->response->setJSON($result); } /** diff --git a/app/Controllers/Supplier.php b/app/Controllers/Supplier.php index f44b7bdf..2e52a8ef 100755 --- a/app/Controllers/Supplier.php +++ b/app/Controllers/Supplier.php @@ -473,11 +473,7 @@ class Supplier extends BaseController $data = $this->request->getPost(); $message = $this->supplier_model->checkTransporter($data['transportername']); - if(!empty($message)){ - echo true; - }else{ - echo false; - } + return $this->response->setJSON($message); } diff --git a/app/Models/Assetdetails_model.php b/app/Models/Assetdetails_model.php index e24aaf28..2ed1c632 100755 --- a/app/Models/Assetdetails_model.php +++ b/app/Models/Assetdetails_model.php @@ -245,6 +245,27 @@ class Assetdetails_model extends Model return $count; } + function deleteAsset ($assetCode , $assetInfo){ + + $this->db->table('t_asset_details') + ->where('AssetCode', $assetCode) + ->update($assetInfo); + $count = $this->db->affectedRows(); + return $count; + + } + + + function reActivateAsset ($assetCode , $assetInfo){ + + $this->db->table('t_asset_details') + ->where('AssetCode', $assetCode) + ->update($assetInfo); + $count = $this->db->affectedRows(); + return $count; + + } + function viewasset($asset, $Asset_Code) { diff --git a/app/Models/Costcenter_model.php b/app/Models/Costcenter_model.php index 20d09083..f3ec9348 100755 --- a/app/Models/Costcenter_model.php +++ b/app/Models/Costcenter_model.php @@ -431,7 +431,7 @@ where Dept.DEPCode not in function checkCostCenter($CostCenterName){ $builder = $this->db->table('t_costcenter_master') - ->where('IsActive',1) + ->select('CostCenterName,IsActive') ->where('CostCenterName', $CostCenterName); $query = $builder->get(); diff --git a/app/Models/Rawmaterialdetails_model.php b/app/Models/Rawmaterialdetails_model.php index 2b6c4b75..321d1a24 100755 --- a/app/Models/Rawmaterialdetails_model.php +++ b/app/Models/Rawmaterialdetails_model.php @@ -292,7 +292,7 @@ class Rawmaterialdetails_model extends Model $builder = $this->db->table('t_materialmaster') - ->select('MaterialCode,MaterialName,MaterialType,Category') + ->select('MaterialCode,MaterialName,MaterialType,Category,IsActive') ->like('REPLACE(MaterialName, " ", "")', $material); $query = $builder->get(); diff --git a/app/Models/Supplier_model.php b/app/Models/Supplier_model.php index 036f0891..03dd3f8c 100755 --- a/app/Models/Supplier_model.php +++ b/app/Models/Supplier_model.php @@ -55,8 +55,7 @@ class Supplier_model extends Model function checkTransporter($transporterName){ $builder = $this->db->table('t_transporter') - ->where('name', $transporterName) - ->where('isactive',1); + ->where('name', $transporterName); $query = $builder->get(); return $query->getResult(); diff --git a/app/Views/addRawMaterial.php b/app/Views/addRawMaterial.php index a2bc2a80..edae186c 100755 --- a/app/Views/addRawMaterial.php +++ b/app/Views/addRawMaterial.php @@ -308,10 +308,15 @@ success: function(data) { var count = data.length; //alert(count); - + console.log(data[0].IsActive); if (count >= 1) { $('#loader').hide(); + if(data[0].IsActive == 1){ alert('Material name already existed ! '); + }else{ + alert('Material name already existing in the deleted section.!!'); + } + var related_name = ""; $.each(data, function(i, obj) { diff --git a/app/Views/addSupplier.php b/app/Views/addSupplier.php index 20090396..b6cc9f3b 100755 --- a/app/Views/addSupplier.php +++ b/app/Views/addSupplier.php @@ -268,11 +268,15 @@ id: supplier }, success: function(data) { - var count = data.length; - console.log(data); + var count = data?data.length:0; if (count >= 1) { $('#loader').hide(); - alert('supplier already existed ! '); + if(data[0].IsActive == 1){ + alert('supplier already existed ! '); + }else{ + alert('supplier already existing in the deleted section..!! '); + } + var related_supplier = ""; $.each(data, function(i, obj) { related_supplier += obj.SupplierID + " - " + obj.SupplierName + " - " + obj.Address + "\n"; diff --git a/app/Views/assetListing.php b/app/Views/assetListing.php index 0733986d..786b0ace 100755 --- a/app/Views/assetListing.php +++ b/app/Views/assetListing.php @@ -71,6 +71,19 @@ + +
+
+ + +
+ +
+ +
@@ -89,6 +102,7 @@ Received Date Asset Value Asset Status + Action @@ -98,14 +112,23 @@ if (!empty($userRecords)) { foreach ($userRecords as $record) { ?> - + " + style="IsActive == 0){echo"display:none";}?>" + > + CreatedDt)) == "30-11--0001") { $cdate = '00-00-0000'; } else { $cdate = date('d-m-Y', strtotime($record->CreatedDt)); } ?> - AssetCode, 5) ?> + + + AssetCode, 5) ?> + + AssetName ?> Description ?> DepartmentName ?> @@ -118,6 +141,34 @@ echo $DOPurchase ?> AssetValue, 2); ?> AssetStatus ?> + + IsActive == 0) { ?> + + + + + + + + + + +    + + + + + + + + + +

( Note :The entries count includes archived data... )

+
+ @@ -223,4 +278,32 @@ } }); }); + + + \ No newline at end of file diff --git a/app/Views/costListing.php b/app/Views/costListing.php index de80a8ef..84dfff8c 100755 --- a/app/Views/costListing.php +++ b/app/Views/costListing.php @@ -225,13 +225,19 @@ data: { CostCenterName: $('#CostCenterName').val() }, - success: function (response) { + success: function (data) { $('#loader').hide(); + let isactive =data[0].IsActive; + + if (data && data.length > 0) { - if (response) { - alert("Cost Center Name Already Exists..!!"); + if(isactive == 1){ + alert("Cost Center Name Exists..!!"); + }else{ + alert("Cost Center Name Existing in the deleted section ..!!"); + } $('#ccwizard').modal('hide'); - location.reload(); + } else { $.ajax({ type: 'POST', diff --git a/app/Views/editRawmaterial.php b/app/Views/editRawmaterial.php index 95de1c8c..64600829 100755 --- a/app/Views/editRawmaterial.php +++ b/app/Views/editRawmaterial.php @@ -458,8 +458,11 @@ if ($total <= $reorder) { if (count >= 1) { $('#loader').hide(); + if(data[0].IsActive == 1){ alert('Material name already existed ! '); - + }else{ + alert('Material name already existing in the deleted section.!!'); + } var related_name = ""; $.each(data, function(i, obj) { diff --git a/app/Views/editSupplier.php b/app/Views/editSupplier.php index fa1bf241..290458b2 100755 --- a/app/Views/editSupplier.php +++ b/app/Views/editSupplier.php @@ -582,7 +582,11 @@ if (!empty($supplier)) { var count = data.length; if (count >= 1) { $('#loader').hide(); - alert('supplier already existed ! '); + if(data[0].IsActive == 1){ + alert('supplier already existed ! '); + }else{ + alert('supplier already existing in the deleted section..!! '); + } var related_supplier = ""; $.each(data, function (i, obj) { related_supplier += obj.SupplierID + " - " + obj.SupplierName + " - " + obj.Address + "\n"; diff --git a/app/Views/rawmaterialListing.php b/app/Views/rawmaterialListing.php index 92441c4b..57686b6e 100755 --- a/app/Views/rawmaterialListing.php +++ b/app/Views/rawmaterialListing.php @@ -141,7 +141,7 @@ -     @@ -151,7 +151,7 @@ data-toggle="tooltip" title="MaterialCode ?> - Click here to delete material details" onclick="deleteMaterial('MaterialCode; ?>')">    - + diff --git a/app/Views/transporterListing.php b/app/Views/transporterListing.php index 894e8434..c1706ffd 100755 --- a/app/Views/transporterListing.php +++ b/app/Views/transporterListing.php @@ -247,6 +247,9 @@ }); $('#tempClick').click(function () { + //loader is initiated + $('#loader').show(); + if ($('#transportername').val() === '') { alert('Please Enter the Transporter Name'); return; @@ -266,12 +269,15 @@ data: { transportername }, - success: function (response) { - console.log("response", response); - if (response) { - alert("Already Transporter with this Name Exists..!!"); - window.location.href = "transporterListing"; - return true; + success: function (data) { + + if (data && data.length > 0) { + let isactive = data[0].isactive; + if (isactive == 1 ) { alert(" Transporter with this Name Exists..!!"); } + else { alert(" Transporter with this Name Existing in deleted section ..!!"); } + + $('#transporterwizard').modal('hide'); + return; } else { $.ajax({ type: 'POST', @@ -289,12 +295,22 @@ }, error: function (xhr, status, error) { alert('An error occurred: ' + error); + }, + complete: function () { + //loader is stopped + $('#loader').hide(); + console.log('second ajax call completed'); } }); } }, error: function (xhr, status, error) { alert('An error occurred inside Check transporterExsits: ' + error); + }, + complete: function () { + //loader is stopped + $('#loader').hide(); + console.log('first ajax call completed') } });