ria/app/Views/factoryMachineMasterDetails.php
2025-03-04 11:37:42 +05:30

268 lines
10 KiB
PHP

<style>
#datatable_filter {
float: inline-end;
}
#datatable_wrapper .row .col-sm-4 {
flex-basis: 50%;
float: inline-end;
}
#datatable_paginate .pagination {
flex-basis: 50%;
float: inline-end;
margin: 0 0 15px;
}
#datatable_wrapper .row:nth-child(3),
#datatable_wrapper .row:nth-child(1) {
padding: 0 15px;
}
#datatable_info {
margin-top: 5px;
}
.dataTables_wrapper {
padding-bottom: 0;
}
.Date-filter-form {
display: flex;
align-items: center;
gap: 10px;
/* Adjust the gap as needed */
}
.Date-filter-form input,
.Date-filter-form button {
padding: 5px;
font-size: 14px;
}
.Date-filter-form button {
background-color: #007bff;
color: white;
border: none;
cursor: pointer;
}
.Date-filter-form button:hover {
background-color: #0056b3;
}
.icon-button {
background: none;
border: none;
cursor: pointer;
color: #007bff;
font-size: 18px;
}
.icon-button:hover {
color: #0056b3;
}
</style>
<div class="content-page">
<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div class="mt-3">
<?php
helper('form');
$error = session()->getFlashdata('error');
if ($error) {
$type = "error";
echo show_alert($type, $error);
}
$success = session()->getFlashdata('success');
if ($success) {
$type = "success";
echo show_alert($type, $success);
}
?>
<div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="javascript: void(0);">Master Details</a></li>
<li class="breadcrumb-item active">
<h4 class="page-title"> <?= trim(explode(":", $pageTitle)[1]) ?> </h4>
</li>
</ol>
</div>
<a class="btn btn-success"
href="<?php echo base_url(); ?>loadView_createFactoryMachineMasterDetail">Add New
Factory Machine</a>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card">
<br>
<div style="margin-left:auto">
<div class="form-check" style="margin-right: 25px;">
<form id="archiveFormId" action="<?php echo base_url()?>/readFactoryMachineMasterDetails" method="post">
<input class="form-check-input" type="checkbox" id="showArchiveId"
name="showArchive" value="1" <?php echo $showArchive ? "checked" : " " ?>
style="width: 18px; height: 18px;">
<label class="form-check-label" for="showArchiveId"
style="font-size: 1rem; margin-left: 8px;">
Show Archive
</label>
</form>
</div>
</div>
<div class="card-body" style="overflow-x:scroll;">
<table id="datatable" class="table table-hover table-bordered"
style="background-color:#fff;">
<thead>
<tr>
<th>Machine Name</th>
<th>Machine Type</th>
<th>Energy Type</th>
<th>Status</th>
<th style="text-align:center !important;">Action</th>
</tr>
</thead>
<tbody>
<?php
if (!empty($masterData)) {
foreach ($masterData as $record) {
?>
<tr>
<td><?php echo $record['machine_name']; ?></td>
<td><?php echo $record['machine_type'] ?></td>
<td><?php echo $record['energy_type'] ?></td>
<td><?php if ( $record['is_active'] == 1) {echo"Active";}else{echo "InActive";}?></td>
<td align="center">
<?php if ($record['is_active'] == 0) { ?>
<a data-toggle="tooltip"
onclick="confirmReActivateMachineDetail(event)"
href="<?php echo base_url(); ?>reActivateFactoryMachineMasterDetails?id=<?php echo $record['id'] ?>">
<i class="fa fa-key" data-toggle="tooltip"
title="Click here to Re activate machine detail "></i>
&nbsp;&nbsp;&nbsp;
</a>
<?php } else { ?>
<a data-toggle="tooltip"
href="<?php echo base_url() ?>loadView_updateFactoryMachineMasterDetail?id=<?php echo $record['id'] ?>">
<i class="fa fa-edit" data-toggle="tooltip"
title="Click here to Edit machine detail "></i>
&nbsp;&nbsp;&nbsp;
</a>
<a data-toggle="tooltip" onclick="confirmDelete(event)"
href="<?php echo base_url(); ?>deleteFactoryMachineMasterDetails?id=<?php echo $record['id'] ?>">
<i class="fa fa-trash" data-toggle="tooltip"
title="Click here to Delete machine detail"></i>
&nbsp;&nbsp;&nbsp;
</a>
<?php } ?>
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
<p>( Note :The entries count includes archived data... )</p>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
</div>
</div>
</div> <!-- container -->
</div> <!-- content -->
</div>
<script type="text/javascript" src="<?php echo base_url(); ?>public/assets/js/common.js" charset="utf-8"></script>
<script>
$(document).ready(function () {
$.fn.dataTable.ext.type.order['date-eu-pre'] = function (date) {
var dateSplit = date.split('-');
return (dateSplit[2] + dateSplit[1] + dateSplit[0]) * 1;
};
// Initialize the DataTable
var table = $('#datatable').DataTable({
dom: 'Blfrtip',
buttons: [
'excel', 'pdf'
],
pageLength: 10,
lengthMenu: [[10, 20, 30, 50, -1], [10, 20, 30, 50, "All"]],
responsive: false,
order: false,
language: {
paginate: {
next: '<i class="fas fa-angle-right"></i>', // Next button icon
previous: '<i class="fas fa-angle-left"></i>' // Previous button icon
}
}
});
// Handle form submission
$("#DateRangeFilter").submit(function (e) {
e.preventDefault();
table.draw();
});
});
</script>
<script>
function confirmDelete(event) {
let result = confirm(` Do you Confirm to Delete the Factory Machine?`);
if (result) { return result; } else { event.preventDefault(); }
}
function confirmReActivateMachineDetail(event) {
let result = confirm(` Do you Confirm to Re Activate Factory Machine Detail?`);
if (result) { return result; } else { event.preventDefault(); }
}
</script>
<script>
$(document).on("change", "#showArchiveId", function () {
console.log("Checkbox changed, submitting form...");
$("#archiveFormId").submit();
});
</script>