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 @@ + +
( Note :The entries count includes archived data... )