master detail module changes-1 vadivel J 09-12-2024

This commit is contained in:
vadivelJ96 2024-12-09 16:34:03 +05:30
parent 25515a7104
commit bcea9f851a
8 changed files with 516 additions and 135 deletions

View File

@ -120,8 +120,12 @@ $routes->post('companycontroller/bankdtl', 'Companycontroller::bankdtl');
$routes->get('configlisting', 'Configurationctrl::index');
$routes->get('addconfig', 'Configurationctrl::addconfig');
$routes->post('configurationctrl/saveconfig', 'Configurationctrl::saveconfig');
$routes->post('configurationctrl/configValueCheck', 'Configurationctrl::configValueCheck');
$routes->get('configurationctrl/deleteConfigValue', 'Configurationctrl::deleteConfigValue');
$routes->get('configurationctrl/reActivateConfigValue', 'Configurationctrl::reActivateConfigValue');
$routes->get('configurationctrl/editconfig', 'Configurationctrl::editconfig');
$routes->post('configurationctrl/updateconfig', 'Configurationctrl::updateconfig');
$routes->post('configurationctrl/configNameCheck', 'Configurationctrl::configNameCheck');
$routes->get('configurationctrl/deleteConfig', 'configurationctrl::deleteConfig');
$routes->get('configurationctrl/reActivateConfig', 'configurationctrl::reActivateConfig');

View File

@ -105,6 +105,7 @@ class Configurationctrl extends BaseController
$config = array('Config_ID' => $ConfigId, 'ConfigName' => $ConfigName, 'Comments' => $Comments);
$result = $this->configmodel->updateconfig($config, $ConfigId);
$child_result = false ;
for ($i = 1; $i <= $Rowcount; $i++) {
$child_primary_key = $this->request->getPost('DbKey' . $i);
@ -158,5 +159,51 @@ class Configurationctrl extends BaseController
}
public function configNameCheck(){
$data = $this->request->getPost();
$configName = ($data['configName']);
$result = $this->configmodel->configNameCheck($configName);
return $this->response->setJSON($result);
}
public function configValueCheck(){
$data = $this->request->getPost();
$configId = $data['configId'];
$configValue = $data['ConfigValue'];
$result = $this->configmodel->configValueCheck($configId, $configValue);
return $this->response->setJSON($result);
}
public function deleteConfigValue(){
$configId = $this->request->getVar('ConfigID');
$configValue = $this->request->getVar('ConfigValue');
$result = $this->configmodel->deleteConfigValue($configId, $configValue);
return redirect()->back();
}
public function reActivateConfigValue(){
$configId = $this->request->getVar('ConfigID');
$configValue = $this->request->getVar('ConfigValue');
$result = $this->configmodel->reActivateConfigValue($configId, $configValue);
return redirect()->back();
}
}

View File

@ -31,6 +31,28 @@ class FactoryMachineController extends BaseController
}
public function createFactoryMachineMasterDetails(){
$this->global['pageTitle'] = 'Edit Factory Machine Master Detail ';
$data=[
'machine_name'=> $this->request->getPost('machineName'),
'machine_type'=> $this->request->getPost('machineType'),
'energy_type' => $this->request->getPost('energyType'),
];
$inserted = $this->factoryMachineMaster_model->insert($data);
if ($inserted) {
// Set flashdata for success message
return redirect()->to('/readFactoryMachineMasterDetails')->with('success', 'Machine details created successfully');
} else {
// Set flashdata for error message
return redirect()->back()->with('error', 'Failed to create machine details');
}
}
public function loadView_createFactoryMachineMasterDetail(){

View File

@ -177,4 +177,44 @@ class Config_model extends Model
return $query->getResult();
}
public function configNameCheck($configName){
$builder = $this->db->table('t_configmaster')
->where('ConfigName ', $configName);
$query = $builder->get();
// dd( $this->db->getLastQuery());
return $query->getResultArray();
}
public function configValueCheck($configId , $configValue){
$builder = $this->db->table('t_configdetails')
->where('Config_ID',$configId)
->where('configValue ', $configValue);
$query = $builder->get();
// dd( $this->db->getLastQuery());
return $query->getResultArray();
}
public function deleteConfigValue($configId, $configValue){
$builder = $this->db->table('t_configdetails')
->where('Config_ID',$configId)
->where('configValue ', $configValue)
->update(['isActive'=> 0]);
$res = $this->db->affectedRows();
return $res;
}
public function reActivateConfigValue($configId, $configValue){
$builder = $this->db->table('t_configdetails')
->where('Config_ID',$configId)
->where('configValue ', $configValue)
->update(['isActive'=> 1]);
$res = $this->db->affectedRows();
return $res;
}
}

View File

@ -46,7 +46,7 @@
<form role="form" id="addconfig" action="<?php echo base_url() ?>configurationctrl/saveconfig" method="post">
<div class="form-row" style="margin-top:10px">
<div class=" col-md-3">
<label class="col-form-label" for="ConfigurationName">Configuration Name</label>
<label class="col-form-label" for="ConfigurationName">Configuration Name</label><span class="text-danger">*</span>
<?php
$data = array('name' => 'configurationname', 'value' => set_value('configurationname'), 'id' => 'configurationname', 'class' => 'form-control', 'required' => 'true', 'maxlength' => '20');
echo form_input($data); ?>
@ -382,3 +382,74 @@
}
});
</script>
<script>
$('#configurationname').change(function () {
$('#loader').show();
$.ajax({
data: {configName: $('#configurationname').val()},
type: 'POST',
url: "<?php echo base_url(); ?>configurationctrl/configNameCheck",
success: function (data) {
if(data && data.length > 0){
if(data[0].isActive == 1){
alert("This Configuration Name is already present. kindly change it..!!");
$('#configurationname').val('');
return;
}else{
alert("This Configuration Name is already present in deleted section. kindly reactivate it If needed..!!");
$('#configurationname').val('');
return;
}
}
},
error:function(error){
console.log("error occured..!!" ,error);
},
complete:function(){
$('#loader').hide();
console.log('ajax call completed..!!');
}
});
});
</script>
<script>
$('#ConfigValue').change(function(){
$('#loader').show();
$.ajax({
data: {ConfigValue: $('#ConfigValue').val()},
type: 'POST',
url: "<?php echo base_url(); ?>configurationctrl/configValueCheck",
success: function (data) {
if(data && data.length > 0){
if(data[0].isActive == 1){
alert("This Configuration Value is already present. kindly change it..!!");
$('#ConfigValue').val('');
return;
}else{
alert("This Configuration Value is already present in deleted section. kindly reactivate it If needed..!!");
$('#ConfigValue').val('');
return;
}
}
},
error:function(error){
console.log("error occured..!!" ,error);
},
complete:function(){
$('#loader').hide();
console.log('ajax call completed..!!');
}
});
})
</script>

View File

@ -28,7 +28,8 @@ if (!empty($master)) {
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<h4 class="page-title">Edit Config <?= ' - ' . $ConfigName; ?> Details</h4>
<a class="btn btn-secondary" href="<?php echo base_url(); ?>configlisting"><span class="bold">Back</span></a>
<a class="btn btn-secondary" href="<?php echo base_url(); ?>configlisting"><span
class="bold">Back</span></a>
</div>
</div>
</div>
@ -93,13 +94,34 @@ if (!empty($master)) {
<div class="form-row" style="margin-top:10px">
<div class="col-md-12 text-right">
<a data-toggle="modal" href="#AddConfiguration" style="margin-right: 10px;" class="btn btn-success"><i class="fa fa-plus"></i>&nbsp;&nbsp;Add Configuration</a>
<a data-toggle="modal" href="#AddConfiguration" style="margin-right: 10px;"
class="btn btn-success"><i class="fa fa-plus"></i>&nbsp;&nbsp;Add
Configuration</a>
</div>
</div>
<br>
<div>
<div align="right">
<div class="form-check" style="margin-right: 25px;">
<input class="form-check-input" type="checkbox" id="showChildArchiveId"
name="showChildArchive" value="1" onchange="showChildArchiveList()"
style="width: 18px; height: 18px;">
<label class="form-check-label" for="showChildArchiveId"
style="font-size: 1rem; margin-left: 8px;">
Show Archive
</label>
</div>
</div>
</div>
<div class="form-row" style="margin-top:10px">
<div class="col-md-12">
<table id="configtable" class="table table-bordered table-hover responsive-utilities jambo_table" style="background-color:#fff;font-size:12px;">
<table id="configtable"
class="table table-bordered table-hover responsive-utilities jambo_table"
style="background-color:#fff;font-size:12px;">
<thead>
<tr>
<th>S.NO</th>
@ -113,16 +135,59 @@ if (!empty($master)) {
foreach ($child as $con) {
$index++;
?>
<input type="hidden" name="DbKey<?php echo $index ?>" id="DbKey<?php echo $index ?>" value="<?php echo $con->Key ?>">
<input type="hidden" name="configVal<?php echo $index ?>" id="configVal<?php echo $index ?>" value="<?php echo $con->ConfigValue ?>">
<tr>
<input type="hidden" name="DbKey<?php echo $index ?>"
id="DbKey<?php echo $index ?>" value="<?php echo $con->Key ?>">
<input type="hidden" name="configVal<?php echo $index ?>"
id="configVal<?php echo $index ?>"
value="<?php echo $con->ConfigValue ?>">
<tr class="<?php if ($con->isActive == 0) {
echo "deactivatedRow";
} ?>" style="<?php if ($con->isActive == 0) {
echo "display:none";
} ?>">
<td><?php echo $index; ?></td>
<td><?php echo $con->ConfigValue; ?></td>
<td><a data-target='#Edit' data-id="<?php echo $index; ?>" data-userid="<?php echo $index; ?>" data-toggle="modal" href="#Edit"><i class="fas fa-pencil-alt" data-toggle="tooltip" title="Click here to view/Edit the Budget details"></i>&nbsp;&nbsp;&nbsp;</a></td>
<td>
<?php if ($con->isActive == 0) { ?>
<a onclick="confirmReActivateConfig(event)"
href="<?php echo base_url() . 'configurationctrl/reActivateConfigValue
?ConfigValue=' . $con->ConfigValue . '
&ConfigID=' . $con->Config_ID; ?>"
data-toggle="tooltip"
title="<?php echo $con->Config_ID ?> - Click here to Re
activate Config Details"><i class="fas fa-key"></i>
</a>
<?php } else { ?>
<a data-target='#Edit' data-id="<?php echo $index; ?>"
data-userid="<?php echo $index; ?>" data-toggle="modal"
href="#Edit"><i class="fas fa-edit" data-toggle="tooltip"
title="Click here to Edit Config Value"></i>&nbsp;&nbsp;&nbsp;
</a>
&nbsp;&nbsp;
&nbsp;&nbsp;
<a onclick="confirmDeleteConfig(event)"
href="<?php echo base_url() . 'configurationctrl/deleteConfigValue
?ConfigValue=' . $con->ConfigValue . '
&ConfigID=' . $con->Config_ID; ?>">
<i class="fas fa-trash" data-toggle="tooltip"
title="Click here to Delete the Config Value"></i>&nbsp;&nbsp;&nbsp;
</a>
<?php } ?>
</td>
</tr>
<?php }
} ?>
<input type="hidden" name="txtRowCount" id="txtRowCount" value="<?php echo $index ?>" />
<input type="hidden" name="txtRowCount" id="txtRowCount"
value="<?php echo $index ?>" />
</tbody>
</table>
</div>
@ -140,14 +205,14 @@ if (!empty($master)) {
</div>
<!-- Modal For Add Configuration -->
<div class="modal fade" id="AddConfiguration" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal fade" id="AddConfiguration" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">Add Configuration</h4>
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">×</button>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<!-- Modal Body -->
@ -159,7 +224,8 @@ if (!empty($master)) {
Configuration Value :
</div>
<div class="col-md-5">
<input class="form-control" name="AddConfigValue" id="AddConfigValue" type="text">
<input class="form-control" name="AddConfigValue" id="AddConfigValue"
type="text">
</div>
</div>
</div>
@ -168,22 +234,24 @@ if (!empty($master)) {
<!-- Modal Footer -->
<div class="modal-footer">
<a class="btn btn-success" style="background-color: grey;border: none;margin-right:10px" data-dismiss="modal">Cancel</a>
<a class="btn btn-success font tempClickAdd" id="tempClickAdd"><i class="fa fa-plus"></i>&nbsp;&nbsp;Add</a>
<a class="btn btn-success" style="background-color: grey;border: none;margin-right:10px"
data-dismiss="modal">Cancel</a>
<a class="btn btn-success font tempClickAdd" id="tempClickAdd"><i
class="fa fa-plus"></i>&nbsp;&nbsp;Add</a>
</div>
</div>
</div>
</div>
<!-- Modal For Edit Configuration -->
<div class="modal fade" id="Edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal fade" id="Edit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title" id="myModalLabel">Edit Config</h4>
<button type="button" class="close" data-dismiss="modal"
aria-hidden="true">×</button>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<!-- Modal Body -->
@ -235,8 +303,10 @@ if (!empty($master)) {
<!-- Modal Footer -->
<div class="modal-footer">
<a class="btn btn-success" style="background-color: grey;border: none;margin-right:10px" data-dismiss="modal">Cancel</a>
<a class="btn btn-success font tempClickUpdate" id="tempClickUpdate"><i class="fa fa-pencil"></i>&nbsp;&nbsp;Update</a>
<a class="btn btn-success" style="background-color: grey;border: none;margin-right:10px"
data-dismiss="modal">Cancel</a>
<a class="btn btn-success font tempClickUpdate" id="tempClickUpdate"><i
class="fa fa-pencil"></i>&nbsp;&nbsp;Update</a>
</div>
</div>
</div>
@ -399,7 +469,7 @@ if (!empty($master)) {
$('#txtSelectedDepartment').val('');
$('#txtRowCount').val('');
//window.location = baseurl + 'CostCenter/CostListing';
window.location = baseurl + 'CostCenter/CostListing';
}
@ -422,3 +492,120 @@ if (!empty($master)) {
}
});
</script>
<script>
$('#ConfigName').change(function () {
$('#loader').show();
$.ajax({
data: { configName: $('#ConfigName').val() },
type: 'POST',
url: "<?php echo base_url(); ?>configurationctrl/configNameCheck",
success: function (data) {
if (data && data.length > 0) {
if (data[0].isActive == 1) {
alert("This Configuration Name is already present. kindly change it..!!");
$('#ConfigName').val('');
return;
} else {
alert("This Configuration Name is already present in deleted section. kindly reactivate it If needed..!!");
$('#ConfigName').val('');
return;
}
}
},
error: function (error) {
console.log("error occured..!!", error);
},
complete: function () {
$('#loader').hide();
console.log('ajax call completed..!!');
}
});
});
</script>
<script>
$('#AddConfigValue').change(function () {
$('#loader').show();
$.ajax({
data: {
configId: $('#ConfigId').val(),
ConfigValue: $('#AddConfigValue').val()
},
type: 'POST',
url: "<?php echo base_url(); ?>configurationctrl/configValueCheck",
success: function (data) {
if (data && data.length > 0) {
if (data[0].isActive == 1) {
alert("This Configuration Value is already present. kindly change it..!!");
$('#AddConfigValue').val('');
return;
} else {
alert("This Configuration Value is already present in deleted section. kindly reactivate it If needed..!!");
$('#AddConfigValue').val('');
return;
}
}else{
$('.tempClickAdd').click();
}
},
error: function (error) {
console.log("error occured..!!", error);
},
complete: function () {
$('#loader').hide();
console.log('ajax call completed..!!');
}
});
})
</script>
<script>
function showChildArchiveList() {
let isChecked = $("#showChildArchiveId").prop('checked');
// Show or hide the rows based on checkbox status
$(".deactivatedRow").each(function () {
if (isChecked) {
$(this).show();
} else {
$(this).hide();
}
});
}
$(document).ready(function () {
let table = $('#configtable');
showChildArchiveList();
table.on('draw', function () {
showChildArchiveList();
});
});
function confirmDeleteConfig(event) {
let result = confirm("Do You want to delete this configuration ?");
if (result) { return; } else { event.preventDefault(); }
}
function confirmReActivateConfig(event) {
let result = confirm("Do You want to Re activate deleted configuration ?");
if (result) { return; } else { event.preventDefault(); }
}
</script>

View File

@ -1,4 +1,3 @@
<?php
$machineName = $masterData['machine_name'] ?? '';
@ -14,7 +13,8 @@ $energyType=$masterData['energy_type']??'';
}
.btn-soft-primary:hover {
background-color: rgb(32, 176, 130); /* Slightly darker shade for hover */
background-color: rgb(32, 176, 130);
/* Slightly darker shade for hover */
border-color: rgb(32, 176, 130);
}
@ -24,10 +24,11 @@ $energyType=$masterData['energy_type']??'';
}
.btn-custom {
width: 100px; /* or any desired width */
padding: 10px; /* adjust padding */
width: 100px;
/* or any desired width */
padding: 10px;
/* adjust padding */
}
</style>
<div class="content-page">
@ -51,32 +52,39 @@ $energyType=$masterData['energy_type']??'';
<div class="card">
<div class="card-body">
<form action="<?= base_url() ?>
<?php if(empty($masterData))
{echo "createFactoryMachineMasterDetails";}
else{echo "updateFactoryMachineMasterDetails?id=".$masterData['id'];} ?>" method="post" class="form-label-left " >
<form action="<?= empty($masterData)
? base_url('createFactoryMachineMasterDetails')
: base_url('updateFactoryMachineMasterDetails?id=' . $masterData['id']); ?>" method="post"
class="form-label-left">
<div class="form-row">
<div class="form-group col">
<label for="machineName" class="col-form-label">Machine Name</label>
<span class="text-danger">*</span></label>
<input type="text" name="machineName" id="machineName" class="form-control" value="<?= set_value('machineName', $machineName) ?>" required >
<input type="text" name="machineName" id="machineName" class="form-control"
value="<?= set_value('machineName', $machineName) ?>" required>
</div>
<div class="form-group col">
<label for="machineType" class="col-form-label">Machine Type</label>
<span class="text-danger">*</span></label>
<input type="text" name="machineType" id="machineType" class="form-control" value="<?= set_value('machineType', $machineType) ?>" required>
<input type="text" name="machineType" id="machineType" class="form-control"
value="<?= set_value('machineType', $machineType) ?>" required>
</div>
<div class="form-group col">
<label for="energyType" class="col-form-label">Energy Type<span class="text-danger">*</span></label>
<select name="energyType" id="energyType" class="form-control searchabledropdown" data-toggle="select2" required >
<label for="energyType" class="col-form-label">Energy Type<span
class="text-danger">*</span></label>
<select name="energyType" id="energyType"
class="form-control searchabledropdown" data-toggle="select2" required>
<option value="-1">Select Energy Type</option>
<option value="diesel" <?= $energyType == 'diesel' ? 'selected' : '' ?> > Diesel</option>
<option value="petrol" <?= $energyType == 'petrol' ? 'selected' : '' ?> > Petrol</option>
<option value="diesel" <?= $energyType == 'diesel' ? 'selected' : '' ?>> Diesel
</option>
<option value="petrol" <?= $energyType == 'petrol' ? 'selected' : '' ?>> Petrol
</option>
<option value="gas" <?= $energyType == 'gas' ? 'selected' : '' ?>> Gas</option>
<option value="electric" <?= $energyType == 'electric' ? 'selected' : '' ?> >Electric</option>
<option value="electric" <?= $energyType == 'electric' ? 'selected' : '' ?>>
Electric</option>
</select>
</div>
@ -89,9 +97,11 @@ $energyType=$masterData['energy_type']??'';
<div class="form-group col">
<button type="submit" class="btn btn-info waves-effect waves-light">Submit</button>
<button type="submit"
class="btn btn-info waves-effect waves-light">Submit</button>
&nbsp;
<button type="button" class="btn btn-secondary" onclick="window.history.back();">
<button type="button" class="btn btn-secondary"
onclick="window.history.back();">
Cancel</button>
</div>