development in ria factory module -vadivel J

This commit is contained in:
vadivel J 2024-10-03 18:01:09 +05:30
parent 628992d416
commit 5315a6cb11
7 changed files with 547 additions and 1 deletions

View File

@ -392,4 +392,15 @@ $routes->get('sales_invoice', 'Sales::sales_invoice');
// transporter Routes
$routes->get('transporterListing', 'Supplier::transporterListing');
$routes->post('fetchTransporterDetails', 'Supplier::fetchTransporterDetails');// for Ajax both add and edit....
$routes->get('deleteTransporter', 'Supplier::deleteTransporter');
$routes->get('deleteTransporter', 'Supplier::deleteTransporter');
//Factory Machine Master Routes
$routes->post('createFactoryMachineMasterDetails' , 'FactoryMachineController::createFactoryMachineMasterDetails');
$routes->get ('readFactoryMachineMasterDetails' , 'FactoryMachineController::readFactoryMachineMasterDetails');
$routes->get ('readFactoryMachineMasterDetailsById', 'FactoryMachineController::readFactoryMachineMasterDetailsById');
$routes->post ('updateFactoryMachineMasterDetails' , 'FactoryMachineController::updateFactoryMachineMasterDetails');
$routes->post('deleteFactoryMachineMasterDetails' , 'FactoryMachineController::deleteFactoryMachineMasterDetails');
$routes->get('loadView_createFactoryMachineMasterDetail','FactoryMachineController::loadView_createFactoryMachineMasterDetail');
$routes->get('loadView_updateFactoryMachineMasterDetail','FactoryMachineController::loadView_updateFactoryMachineMasterDetail');

View File

@ -0,0 +1,142 @@
<?php
namespace App\Controllers;
use App\Controllers\BaseController;
use App\Models\FactoryMachineModel;
use CodeIgniter\HTTP\ResponseInterface;
class FactoryMachineController extends BaseController
{
protected $factoryMachineMaster_model;
protected $session;
/**
* This is default constructor of the class
*/
public function __construct()
{
parent::__construct();
$this->factoryMachineMaster_model = new FactoryMachineModel;
$this->session = session();
helper('form'); //$this->load->library('form_validation');
$this->isLoggedIn();
}
public function index()
{
//
}
public function createFactoryMachineMasterDetails(){
$this->global['pageTitle'] = 'Create Factory Machine ';
$postData=[
'machine_name'=> $this->request->getPost('machineName'),
'machine_type'=> $this->request->getPost('machineType'),
'energy_type' => $this->request->getPost('energyType'),
];
$data = $this->factoryMachineMaster_model->insert($postData);
$this->readFactoryMachineMasterDetails();
//check above data is successfully created.
}
public function loadView_createFactoryMachineMasterDetail(){
$this->global['pageTitle'] = 'Create Factory Machine Master Detail ';
$data['masterData']='';
return $this->loadViews("factoryMachineMasterDetailsCreate", $this->global, $data, NULL);
}
public function loadView_updateFactoryMachineMasterDetail(){
$this->global['pageTitle'] = 'Edit Factory Machine Master Detail ';
$id = $this->request->getGet('id');
$data['masterData'] = $this->factoryMachineMaster_model->where('id', $id)->where('is_active', 1)->first();
//here we are using create Factory Machine Master Detail view for
// updating Factory Machine Master Detail
return $this->loadViews("factoryMachineMasterDetailsCreate", $this->global, $data, NULL);
}
public function readFactoryMachineMasterDetails(){
$this->global['pageTitle'] = 'Factory Machine Master Details ';
$data['masterData'] = $this->factoryMachineMaster_model->where('is_active', 1)->findAll();
return $this->loadViews("factoryMachineMasterDetails", $this->global, $data, NULL);
}
public function readFactoryMachineMasterDetailsById(){
$this->global['pageTitle'] = 'Factory Machine Master Detail ';
$id = $this->request->getPost('id');
$data = $this->factoryMachineMaster_model->where('id', $id)->where('is_active', 1)->first();
return $this->loadViews("factoryMachineMasterDetails", $this->global, $data, NULL);
}
public function updateFactoryMachineMasterDetails(){
$this->global['pageTitle'] = 'Edit Factory Machine Master Detail ';
$id = $this->request->getPost('id');
$postData=[
'machine_name'=> $this->request->getPost('machineName'),
'machine_type'=> $this->request->getPost('machineType'),
'energy_type' => $this->request->getPost('energyType'),
];
$data = $this->factoryMachineMaster_model->update($id,$postData);
$this->readFactoryMachineMasterDetails();
}
public function deleteFactoryMachineMasterDetails(){
$this->global['pageTitle'] = 'Delete Factory Machine Master Detail ';
$id = $this->request->getPost('id');
$data['is_active']=0;
$data = $this->factoryMachineMaster_model->update($id,$data);
}
}

View File

@ -0,0 +1,34 @@
<?php
namespace App\Database\Migrations;
use CodeIgniter\Database\Migration;
class CreateFactoryMachineMasterTable extends Migration
{
public function up()
{
$this->forge->addField([
'id' => ['type' => 'INT', 'auto_increment' => true],
'machine_name' => ['type' => 'VARCHAR', 'constraint' => '255'],
'machine_type' => ['type' => 'VARCHAR', 'constraint' => '255'],
'fuel_type' => ['type' => 'VARCHAR', 'constraint' => '255'],
'is_active' => ['type' => 'TINYINT', 'constraint' => 1, 'default' => 1],
'created_at' => ['type' => 'DATETIME', 'null' => true],
'updated_at' => ['type' => 'DATETIME', 'null' => true]
]);
$this->forge->addKey('id', true);
$this->forge->createTable('t_factoryMachineMaster');
}
public function down()
{
$this->forge->dropTable('t_factoryMachineMaster');
}
}

View File

@ -0,0 +1,42 @@
<?php
namespace App\Models;
use CodeIgniter\Model;
class FactoryMachineModel extends Model
{
// The table associated with this model
protected $table = 't_factoryMachineMaster';
// Primary key of the table
protected $primaryKey = 'id';
// Return type (you can use 'array' or 'object')
protected $returnType = 'array';
// Fields that are allowed to be inserted or updated
protected $allowedFields = ['machine_name', 'machine_type', 'energy_type', 'is_active', 'created_at', 'updated_at'];
// Enable automatic timestamps
protected $useTimestamps = true;
// Define custom timestamps columns, if necessary (optional)
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
// Validation rules (optional)
protected $validationRules = [
'machine_name' => 'required|max_length[255]',
'machine_type' => 'required|max_length[255]',
'energy_type' => 'required|max_length[255]',
];
// Validation messages (optional)
protected $validationMessages = [];
// Skip validation (set to true to skip validation rules)
protected $skipValidation = false;
}

View File

@ -0,0 +1,203 @@
<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>
<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">
<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;">Machine Name</th>
<th style="text-align:center !important;">Machine Type</th>
<th style="text-align:center !important;">Energy Type</th>
<th style="text-align:center !important;">Action</th>
</tr>
</thead>
<tbody>
<?php
if (!empty($masterData)) {
foreach ($masterData as $record) {
?>
<td align="center"><?php echo $record['machine_name']; ?></td>
<td align="center"><?php echo $record['machine_type'] ?></td>
<td align="center"><?php echo $record['energy_type'] ?></td>
<td align="center">
<a data-toggle="tooltip"
href="<?php echo base_url(); ?>loadView_updateFactoryMachineMasterDetail?id=<?php echo $record['id'] ?>"
target="new"><i class="fa fa-pencil-alt" data-toggle="tooltip"
title="- Click here to Edit "></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>
<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>

View File

@ -0,0 +1,108 @@
<?php
$machineName=$masterData['machine_name']??'';
$machineType=$masterData['machine_type']??'';
$energyType=$masterData['energy_type']??'';
?>
<style>
.btn-soft-primary {
color: white;
background-color: rgb(42, 206, 150);
border-color: rgb(42, 206, 150);
}
.btn-soft-primary:hover {
background-color: rgb(32, 176, 130); /* Slightly darker shade for hover */
border-color: rgb(32, 176, 130);
}
.th{
font-size: 14px;
text-align:center !important ;
}
.btn-custom {
width: 100px; /* or any desired width */
padding: 10px; /* adjust padding */
}
</style>
<div class="content-page">
<div class="content">
<!-- Start Content-->
<div class="container-fluid">
<!-- start page title -->
<div class="row">
<div class="col-12">
<div class="page-title-box page-title-box-alt">
<h4><?= trim(explode(":", $pageTitle)[1]) ?></h4>
<button type="button" onclick="window.history.back();" class="btn btn-secondary">Back</button>
</div>
</div>
</div>
<!-- end page title -->
<!-- Form row -->
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-body">
<form action="<?= base_url() ?>
<?php if(empty($masterData))
{echo "createFactoryMachineMasterDetails";}
else{echo "updateFactoryMachineMasterDetails";} ?>" 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 >
</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>
</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 >
<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="gas" <?= $energyType == 'gas' ? 'selected' : '' ?> > Gas</option>
<option value="electric" <?= $energyType == 'electric' ? 'selected' : '' ?> >Electric</option>
</select>
</div>
</div>
<div class="form-row" >
<div class="form-group" >
<button class="btn btn-success">Submit</button>
&nbsp;
<button class="btn btn-danger ">
Cancel</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
<!-- end row -->
</div> <!-- container -->
</div> <!-- content -->
</div>

View File

@ -602,6 +602,7 @@
</div> -->
</li>
<!-- Sales module -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle arrow-none" href="#" id="topnav-hr" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@ -613,6 +614,7 @@
</div>
</li>
<!-- purchase module -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle arrow-none" href="#" id="topnav-purchase" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@ -659,6 +661,8 @@
</div>
</li>
<!-- HR module -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle arrow-none" href="#" id="topnav-hr" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@ -696,6 +700,7 @@
</div>
</li>
<!-- Others -->
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle arrow-none" href="#" id="topnav-others" role="button"
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
@ -717,6 +722,7 @@
<a href="<?php echo base_url(); ?>departmentListing" class="dropdown-item">Department Details</a>
<!-- <a href="<?php echo base_url(); ?>rawmaterialListing" class="dropdown-item">Material Details</a> -->
<a href="<?php echo base_url(); ?>userListing" class="dropdown-item">Users</a>
<a href="<?php echo base_url(); ?>readFactoryMachineMasterDetails" class="dropdown-item">Factory Machines Details</a>
</div>
</div>
</div>