working on stock module

This commit is contained in:
vadivel J 2024-10-08 17:30:53 +05:30
parent 49c9884a93
commit 04093c9342
6 changed files with 533 additions and 2 deletions

View File

@ -406,5 +406,15 @@ $routes->get('deleteFactoryMachineMasterDetails' , 'FactoryMachineController
$routes->get('loadView_createFactoryMachineMasterDetail','FactoryMachineController::loadView_createFactoryMachineMasterDetail');
$routes->get('loadView_updateFactoryMachineMasterDetail','FactoryMachineController::loadView_updateFactoryMachineMasterDetail');
//routes for getSilicaIgr
$routes->post('getSilicaIGR', 'Supplier::getSilicaIGR');
//Stock Module
$routes->get('coatingMachineDetails' , 'StockController::loadView_coatingMachineDetails');
$routes->post('addNewCoatingMachineDetails' , 'StockController::addNewCoatingMachineDetails');

View File

@ -81,7 +81,7 @@ class FactoryMachineController extends BaseController
$this->global['pageTitle'] = 'Factory Machine Master Details';
$data['masterData'] = $this->factoryMachineMaster_model->where('is_active', 1)
$data['masterData'] = $this->factoryMachineMaster_model
->where('is_active', 1)
->orderBy('created_at','DESC')
->findAll();

View File

@ -0,0 +1,119 @@
<?php
namespace App\Controllers;
use App\Controllers\BaseController;
use App\Models\CoatingMachineDetailsModel;
use CodeIgniter\HTTP\ResponseInterface;
use DateTime;
class StockController extends BaseController
{
protected $coatingMachineDetails_model;
protected $session;
/**
* This is default constructor of the class
*/
public function __construct()
{
parent::__construct();
$this->coatingMachineDetails_model = new CoatingMachineDetailsModel();
$this->session = session();
helper('form');
$this->isLoggedIn();
}
public function index()
{
//
}
public function loadView_coatingMachineDetails(){
$this->global['pageTitle'] = 'Coating Machine Details ';
$data['coatingMachineDetails']= $this->coatingMachineDetails_model
->where('is_active', 1)
->orderBy('created_at','DESC')
->findAll();
return $this->loadViews("CoatingMachineDetail", $this->global, $data, NULL);
}
public function addNewCoatingMachineDetails(){
$postData=$this->request->getPost();
$machineOnTime = $postData['machineOnTime'];
$machineOffTime = $postData['machineOffTime'];
$onTime = new DateTime($machineOnTime);
$offTime = new DateTime($machineOffTime);
$timeDifference = $onTime->diff($offTime);
$machineRunningInHrs = $timeDifference->h ;
$postData['machineRunningInHrs'] = $machineRunningInHrs;
$postData['perHourGasConsumption']= (float)$postData['totalGasConsumption']/$machineRunningInHrs;
$postData['perHourCoatingSandQTY']= (float)$postData['totalCoatingSandInKg']/$machineRunningInHrs;
//dd( $postData['perHourCoatingSandQTY']);
$inserted= $this->coatingMachineDetails_model->insert($postData);
if ($inserted) {
// Set flashdata for success message
return redirect()->to('/coatingMachineDetails')->with('success', 'Coating Machine details updated successfully');
} else {
// Set flashdata for error message
return redirect()->back()->with('error', 'Failed to update Coating machine details');
}
}
public function updateCoatingMachineDetails(){
$putData=$this->request->getPost();
$id = $this->request->getGet('id');
$updated= $this->coatingMachineDetails_model->update($id,$putData);
if ($updated) {
// Set flashdata for success message
return redirect()->to('/coatingMachineDetails')->with('success', 'Coating Machine details updated successfully');
} else {
// Set flashdata for error message
return redirect()->back()->with('error', 'Failed to update Coating machine details');
}
}
public function deleteCoatingMachineDetails(){
$id = $this->request->getGet('id');
$data['is_active']=0;
$updated = $this->coatingMachineDetails_model->update($id,$data);
if ($updated) {
// Set flashdata for success message
return redirect()->to('/coatingMachineDetails')->with('success', 'Coating Machine details deleted successfully');
} else {
// Set flashdata for error message
return redirect()->back()->with('error', 'Failed to delete Coating machine details');
}
}
}

View File

@ -0,0 +1,48 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class CoatingMachineDetailsModel extends Model
{
protected $table = 't_coatingMachineDetails';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = false;
protected $protectFields = true;
protected $allowedFields = ['shift','machineOnTime','machineOffTime','totalCoating','date',
'machineRunningInHrs' , 'perHourCoatingSandQTY' , 'perHourGasConsumption' ,
'totalCoatingSandInKg','totalGasConsumption','customerName', 'is_active','created_at','updated_at'];
protected bool $allowEmptyInserts = false;
protected bool $updateOnlyChanged = true;
protected array $casts = [];
protected array $castHandlers = [];
// Dates
protected $useTimestamps = false;
protected $dateFormat = 'datetime';
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
protected $deletedField = 'deleted_at';
// Validation
protected $validationRules = [];
protected $validationMessages = [];
protected $skipValidation = false;
protected $cleanValidationRules = true;
// Callbacks
protected $allowCallbacks = true;
protected $beforeInsert = [];
protected $afterInsert = [];
protected $beforeUpdate = [];
protected $afterUpdate = [];
protected $beforeFind = [];
protected $afterFind = [];
protected $beforeDelete = [];
protected $afterDelete = [];
}

View File

@ -0,0 +1,340 @@
<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>
<?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">
<h4 class="page-title"> <?= trim(explode(":", $pageTitle)[1]) ?> </h4>
<button type="button" class="btn btn-success" data-target="#coatingMachineDetailModal" data-toggle="modal" >
Add New Record
</button>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<table id="datatable" class="table table-hover table-bordered" style="background-color:#fff;">
<thead>
<tr>
<th style="text-align:center !important;">Customer Name</th>
<th style="text-align:center !important;">Date</th>
<th style="text-align:center !important;">Shift</th>
<th style="text-align:center !important;">Machine On Time</th>
<th style="text-align:center !important;">Machine Off Time</th>
<th style="text-align:center !important;">Machine Running (hrs)</th>
<th style="text-align:center !important;">Total Coating</th>
<th style="text-align:center !important;">Total Coating Sand (kgs)</th>
<th style="text-align:center !important;">Total Gas Consumption</th>
<th style="text-align:center !important;">Per Hour Gas Consumption</th>
<th style="text-align:center !important;">Per Hour Coating Sand QTY</th>
<th style="text-align:center !important;">Action</th>
</tr>
</thead>
<tbody>
<?php
if (!empty($coatingMachineDetails)) {
foreach ($coatingMachineDetails as $record) {
?>
<td align="center"><?php echo $record['customerName']; ?></td>
<td align="center"><?php echo $record['date'] ?></td>
<td align="center"><?php echo $record['shift'] ?></td>
<td align="center"><?php echo $record['machineOnTime'] ?></td>
<td align="center"><?php echo $record['machineOffTime'] ?></td>
<td align="center"><?php echo $record['machineRunningInHrs']??'' ?></td>
<td align="center"><?php echo $record['totalCoating'] ?></td>
<td align="center"><?php echo $record['totalCoatingSandInKg'] ?></td>
<td align="center"><?php echo $record['totalGasConsumption'] ?></td>
<td align="center"><?php echo $record['perHourGasConsumption']??'' ?></td>
<td align="center"><?php echo $record['perHourCoatingSandQTY']??'' ?></td>
<td align="center">
<a data-toggle="tooltip"
href="<?php echo base_url()?>loadView_updateFactoryMachineMasterDetail?id=<?php echo $record['id'] ?>"
>
<i class="fa fa-pencil-alt" data-toggle="tooltip"
title="Click here to Edit "></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 "></i>
&nbsp;&nbsp;&nbsp;
</a>
</td>
</tr>
<?php
}
}
?>
</tbody>
</table>
</div> <!-- end card body-->
</div> <!-- end card -->
</div><!-- end col-->
</div>
</div>
</div> <!-- container -->
</div> <!-- content -->
</div>
<!-- Modal -->
<div class="modal fade" id="coatingMachineDetailModal" tabindex="-1" role="dialog" aria-labelledby="coatingMachineDetailModalLabel" aria-hidden="true">
<div class="modal-dialog modal-xl" style="width:1060px !important ;" role="document">
<div class="modal-content" >
<div class="modal-header">
<h5 class="modal-title" id="coatingMachineDetailModalLabel">
Add New Coating Machine Detail</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<!-- form -->
<form method="post" action="<?php echo base_url(); ?>addNewCoatingMachineDetails">
<div class="modal-body">
<div class="form-row">
<div class="form-group col-md-3">
<label for="dateId">Date</label>
<span class="badge mandatory">*</span>
<input type="date" class="form-control" id="dateId"
name="date" value="">
</div>
<div class="form-group col-md-3">
<label for="shiftId">Shift</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" id="shiftId"
name="shift" value="">
</div>
<div class="form-group col-md-3">
<label for="machineOnTimeId">Machine On Time</label>
<span class="badge mandatory">*</span>
<input type="time" class="form-control" id="machineOnTimeId"
name="machineOnTime" value="">
</div>
<div class="form-group col-md-3">
<label for="machineOffTimeId">Machine Off Time</label>
<span class="badge mandatory">*</span>
<input type="time" class="form-control" id="machineOffTimeId"
name="machineOffTime" value="">
</div>
</div>
<div class="form-row">
<div class="form-group col-md-3">
<label for="customerNameId">Customer Name</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" id="customerNameId"
name="customerName" value="">
</div>
<div class="form-group col-md-3">
<label for="totalCoatingId">Total Coating</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" id="totalCoatingId"
name="totalCoating" value="">
</div>
<div class="form-group col-md-3">
<label for="totalCoatingSandId">Total Coating Sand (in Kg)</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" id="totalCoatingSandId"
name="totalCoatingSandInKg" value="">
</div>
<div class="form-group col-md-3">
<label for="totalGasConsumptionId">Total Gas Consumption</label>
<span class="badge mandatory">*</span>
<input type="text" class="form-control" id="totalGasConsumptionId"
name="totalGasConsumption" value="">
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
<button type="submit" class="btn btn-primary">Save </button>
</div>
</form>
</div>
</div>
</div>
<script type="text/javascript" src="<?php echo base_url(); ?>public/assets/js/common.js" charset="utf-8"></script>
<!-- <script type="text/javascript">
$(function () {
$('#datatable').DataTable({
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"info": true,
"autoWidth": true,
"pageLength": 10,
"lengthMenu": [10, 25, 50, 100]
});
});
</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, length menu, filter, table, information, pagination
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print' // Export buttons
],
pageLength: 10, // Default rows per page
lengthMenu: [ [10, 20, 30, 50, -1], [10, 20, 30, 50, "All"] ], // Rows per page options
// responsive: true, // Responsive table
order: [], // Default ordering (column index 0, descending)
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();}
}
</script>
<script>
$(document).ready(function() {
$('#exampleSelect2').select2();
});
</script>

View File

@ -661,6 +661,20 @@
</div>
</li>
<!-- Stock module -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle arrow-none" href="#" id="topnav-stock" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="ri-shopping-bag-line"></i> Stock <div class="arrow-down"></div>
</a>
<div class="dropdown-menu" aria-labelledby="topnav-stock">
<div class="dropdown">
<a href="<?php echo base_url(); ?>coatingMachineDetails" class="dropdown-item"><i class="ri-file-list-3-line align-middle mr-1"></i>Coating Machine Details</a>
</div>
</div>
</li>
<!-- HR module -->
<li class="nav-item dropdown">