Skip to content

Commit

Permalink
production
Browse files Browse the repository at this point in the history
  • Loading branch information
infotracktechnology committed Nov 7, 2023
1 parent f0b26af commit 1cc10df
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 34 deletions.
2 changes: 2 additions & 0 deletions application/config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
$route['production']['GET'] = "ProductionController/index";
$route['production_entry/(:num)']['GET'] = "ProductionController/production_entry/$1";
$route['api/loom/(:num)']['GET'] = "ProductionController/Loom/$1";
$route['production_loom']['POST'] = 'ProductionController/production_loom';
$route['production_status']['POST'] = 'ProductionController/production_status';

$route['loom']['GET'] = 'LoomController/index';
$route['loom/create']['GET'] = 'LoomController/create';
Expand Down
38 changes: 34 additions & 4 deletions application/controllers/ProductionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,51 @@ function __construct() {
}

public function index(){
$this->load->view('production');
$production = $this->db->get('production')->result();
$this->load->view('production',compact('production'));
}
public function production_entry($id){
if($id == 0){

$production_no = $this->db->query("SELECT max(production_no)+1 as production_no FROM `production`")->row();
$production_no = ($production_no->production_no) ? $production_no->production_no : 1;
$production = array('production_no' => $production_no,'date' => date('Y-m-d'),'status'=>'Start');
$this->db->insert('production',$production);
$id = $this->db->insert_id();
}

$production = $this->db->get_where('production',array('id'=>$id))->row();
$entry = $this->db->get_where('production_entry',array('pid'=>$id))->result();
$status = $this->db->get_where('production_status',array('pid'=>$id))->result();
$looms = $this->db->get('loom_master')->result();
$loom_weavers = $this->db->get('technicion_master')->result();
$this->load->view('production_entry',compact('looms','loom_weavers'));
$this->load->view('production_entry',compact('looms','loom_weavers','production','entry','status'));
}

public function loom($id){
$loom = $this->db->query("SELECT a.loom_id,c.id,c.size,c.pick,c.product_name,round((1848*d.count*36)/(39.36*c.pick*52+2),2)grm,c.coolie FROM `loom_master` a left join loom_product b on a.loom_id=b.loom_id left join product_master c on b.product_id=c.id left join material_master d on c.weft_yarn=d.material_id WHERE a.loom_id=$id")->row();
$loom = $this->db->query("SELECT a.loom_id,a.Loom_No,c.id,c.size,c.pick,c.product_name,round((1848*d.count*36)/(39.36*c.pick*52+2),2)grm,c.coolie FROM `loom_master` a left join loom_product b on a.loom_id=b.loom_id left join product_master c on b.product_id=c.id left join material_master d on c.weft_yarn=d.material_id WHERE a.loom_id=$id")->row();
$this->output->set_content_type('application/json')->set_output(json_encode($loom));
}

public function production_loom(){
$data = $this->input->post();
$entry = ['pid'=>$data['pid'],'operator'=>$data['operator'],'loom'=>$data['loom'],'start_time'=>$data['start_time'],'end_time'=>$data['end_time'],'product'=>$data['product_id'],'weft_yarn'=>$data['weft_yarn'],'warp_yarn'=>$data['warp_yarn'],'total'=>$data['total'],'dhothi'=>$data['dhothi'],'wastage'=>$data['wastage']];

$production_entry = $this->db->insert('production_entry',$entry);
if($production_entry){
$production = $this->db->where('id',$data['pid'])->update('production',array('operator'=>$data['operator'],'status'=>'Running','date'=>$data['date']));
}
$this->output->set_content_type('application/json')->set_output(json_encode($data,true));
}

public function production_status() {
$data = $this->input->post();
$status = ['pid'=>$data['pid'],'start_time'=>$data['start_time'],'end_time'=>$data['end_time'],'status'=>$data['status'],'comments'=>$data['comments']];
$production_status = $this->db->insert('production_status',$status);
if($production_status){
$production = $this->db->where('id',$data['pid'])->update('production',array('status'=>$data['status'],'date'=>$data['date'],'operator'=>$data['operator']));
}
$this->output->set_content_type('application/json')->set_output(json_encode($data,true));

}
}
?>
39 changes: 38 additions & 1 deletion application/views/production.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,39 @@

</div>
<div class="card-body">
<div class="col-12">
<div class="table-responsive">
<table id="myTable" class="table table-striped table-bordered table-sm">

<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Production No</th>
<th scope="col">Production Date</th>
<th scope="col">Status</th>
<th scope="col">Action</th>
</tr>
</thead>

<tbody>
<?php
foreach($production as $key => $row) {
?>
<tr>
<td><?php echo $key+1; ?></td>
<td><?php echo $row['production_no']; ?></td>
<td><?php echo $row['date']; ?></td>
<td><?php echo $row['status']; ?></td>
<td><a href="<?php echo base_url("production_entry/$row[id]");?>" class="btn btn-sm btn-primary"><i class="fa fa-eye"></i></a></td>
</tr>
<?php } ?>

</tbody>
</table>


</div>
</div>

</div>
</div>
Expand All @@ -61,7 +93,12 @@
<script src="<?php echo base_url();?>assets/bundles/datatables/datatables.min.js"></script>
<script src="<?php echo base_url();?>assets/bundles/datatables/DataTables-1.10.16/js/dataTables.bootstrap4.min.js"></script>


<script type="text/javascript">
const mytable = $('#myTable').DataTable({
"autoWidth": true,
"responsive": true,
});
</script>
</body>
</html>

Expand Down
112 changes: 83 additions & 29 deletions application/views/production_entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
<?php include_once 'sidebar.php';?>
<div class="main-content">
<section class="section">
<form method="post" name="myForm" action="" enctype="multipart/form-data">

<div class="section-body">
<div class="card card-primary">
<div class="card-header">
<h4>Production Entry</h4>
<div class="card-header-action">
<a class="btn btn-primary" href="#">Go Back</a>
<a class="btn btn-primary" href="<?php echo base_url("production");?>">Go Back</a>
</div>

</div>
Expand All @@ -39,18 +39,18 @@

<div class="col-md-2 form-group">
<label>Production No</label>
<input type="text" class="form-control form-control-sm" value="<?php echo 1; ?>" ng-model="production_no" readonly>
<input type="text" class="form-control form-control-sm" ng-model="production.production_no" readonly>
</div>

<div class="col-md-4 form-group">
<label>Production Date</label>
<input type="date" class="form-control form-control-sm" ng-model="production_date" value="<?php echo date('Y-m-d');?>" max="<?php echo date('Y-m-d'); ?>" required>
<input type="date" class="form-control form-control-sm" ng-model="production.date" max="<?php echo date('Y-m-d'); ?>" required>
</div>


<div class="col-md-4 form-group">
<label>Loom Weaver</label>
<select name="loom_weaver" ng-model="loom_weaver" class="form-control form-control-sm" required>
<select name="loom_weaver" ng-model="production.operator" class="form-control form-control-sm" required>
<option value="" selected disabled>Select Loom Weaver</option>
<option ng-repeat="loom_weaver in loom_weavers" value="{{loom_weaver.id}}">{{loom_weaver.Name}}</option>
</select>
Expand All @@ -72,15 +72,17 @@ class="fas fa-plus"></i></a>
</div>
<div class="collapse" id="loom_details">
<div class="card-body">
<form method="post" ng-submit="AddLoom($event);" enctype="multipart/form-data">
<div class="row">
<div class="col-md-2 form-group">

<div class="col-md-2 form-group">
<label>Loom</label>
<select name="loom" id="loom" ng-on-change="getLoom($event);" class="form-control form-control-sm" required>
<option value="" selected disabled>Select Loom</option>
<option ng-repeat="loom in looms" value="{{loom.loom_id}}">{{loom.Loom_No}}</option>
</select>
</div>

<div class="col-md-2 form-group">
<label> Start Time</label>
<input type="time" name="start_time" class="form-control form-control-sm" required>
Expand All @@ -93,22 +95,22 @@ class="fas fa-plus"></i></a>

<div class="col-md-2 form-group">
<label> Product</label>
<input type="text" name="product" class="form-control form-control-sm" required>
<input type="text" name="product" ng-value="data.product_name" class="form-control form-control-sm" readonly>
</div>

<div class="col-md-2 form-group">
<label> Warp Yarn</label>
<input type="text" name="warp_yarn" class="form-control form-control-sm" required>
<input type="text" name="warp_yarn" ng-value="data.warp_yarn" class="form-control form-control-sm" readonly>
</div>

<div class="col-md-2 form-group">
<label> Weft Yarn</label>
<input type="text" name="weft_yarn" class="form-control form-control-sm" required>
<input type="text" name="weft_yarn" ng-value="data.weft_yarn" class="form-control form-control-sm" readonly>
</div>

<div class="col-md-2 form-group">
<label> Dhothi</label>
<input type="text" name="dhothi" class="form-control form-control-sm" required>
<input type="text" name="dhothi" ng-on-input="getDhothi($event);" class="form-control form-control-sm" required>
</div>

<div class="col-md-2 form-group">
Expand All @@ -118,43 +120,53 @@ class="fas fa-plus"></i></a>

<div class="col-md-2 form-group">
<label> Size</label>
<input type="text" name="size" class="form-control form-control-sm" required>
<input type="text" name="size" ng-value="data.size" class="form-control form-control-sm" required>
</div>

<div class="col-md-2 form-group">
<label> Pick</label>
<input type="text" name="pick" class="form-control form-control-sm" required>
<input type="text" name="pick" ng-value="data.pick" class="form-control form-control-sm" required>
</div>

<div class="col-md-2 form-group">
<label> Coolie</label>
<input type="text" name="coolie" class="form-control form-control-sm" required>
<input type="text" ng-value="data.coolie" name="coolie" class="form-control form-control-sm" readonly>
</div>

<div class="col-md-2 form-group">
<label> Total</label>
<input type="text" name="total" class="form-control form-control-sm" required>
<input type="text" name="total" ng-value="data.total" class="form-control form-control-sm" readonly>
</div>

<div class="col-md-6 form-group">
<button class="btn btn-primary">Update</button>
<button type="submit" class="btn btn-primary">Update</button>
</div>

<div class="col-12">
<h6>History</h6>
<div class="table-responsive">
<table id="myTable" class="table table-bordered table-sm table-primary" style="width:100%;overflow-x:auto;">
<table class="table table-sm table-secondary table-bordered">

<thead>
<tr>
<th scope="col">Date</th>
<th scope="col">S.No</th>
<th scope="col">Loom</th>
<th scope="col">Warp Yarn</th>
<th scope="col">Weft Yarn</th>
<th scope="col">Dhothi</th>
<th scope="col">Total</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="row in entry">
<td>{{$index+1}}</td>
<td>{{row.loom}}</td>
<td>{{row.warp_yarn}}</td>
<td>{{row.weft_yarn}}</td>
<td>{{row.dhothi}}</td>
<td>{{row.total}}</td>
</tr>
</tbody>


</table>
Expand All @@ -163,6 +175,7 @@ class="fas fa-plus"></i></a>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
Expand All @@ -177,6 +190,7 @@ class="fas fa-plus"></i></a>
</div>
<div class="collapse" id="job_status">
<div class="card-body">
<form method="post" ng-submit="AddStatus($event);" enctype="multipart/form-data">
<div class="row">
<div class="col-md-6 form-group">
<label>Job Status</label>
Expand Down Expand Up @@ -213,19 +227,27 @@ class="fas fa-plus"></i></a>
<div class="col-12">
<h6>History</h6>
<div class="table-responsive">
<table id="myTable" class="table table-bordered table-sm table-primary" style="width:100%;overflow-x:auto;">
<table class="table table-sm table-secondary table-bordered">

<thead>
<tr>
<th scope="col">Date</th>
<th scope="col">Sratus</th>
<th scope="col">S.No</th>
<th scope="col">Status</th>
<th scope="col">Start Time</th>
<th scope="col">End Time</th>
<th scope="col">Comments</th>

</tr>
</thead>

<tbody>
<tr ng-repeat="row in status">
<td>{{$index+1}}</td>
<td>{{row.status}}</td>
<td>{{row.start_time}}</td>
<td>{{row.end_time}}</td>
<td>{{row.comments}}</td>
</tr>
</tbody>

</table>

Expand All @@ -234,12 +256,13 @@ class="fas fa-plus"></i></a>
</div>

</div>
</form>
</div>
</div>
</div>

</div>
</form>

</section>
</div>
</div>
Expand All @@ -264,13 +287,15 @@ class="fas fa-plus"></i></a>

const app = angular.module('myApp', []);
const baseUrl = '<?php echo base_url();?>';
app.controller('myCtrl', function($scope, $http) {
app.controller('myCtrl', function($scope, $http, $filter) {
$scope.looms = <?php echo json_encode($looms);?>;
$scope.loom_weavers = <?php echo json_encode($loom_weavers);?>;
$scope.production = <?php echo json_encode($production);?>;
$scope.entry = <?php echo json_encode($entry);?>;
$scope.status = <?php echo json_encode($status);?>;
$scope.production.date = new Date($scope.production.date);
$scope.data={};

$scope.looms = angular.fromJson(<?php echo json_encode($looms);?>);
$scope.loom_weavers = angular.fromJson(<?php echo json_encode($loom_weavers);?>);
$scope.data = {};
const form_data = new FormData($('#myForm')[0]);

$scope.getLoom = function(e){
var loom_id = e.target.value;
$http.get(baseUrl+'api/loom/'+loom_id).then(function(response){
Expand All @@ -285,6 +310,35 @@ class="fas fa-plus"></i></a>
$scope.data.total = (dhothi*$scope.data.coolie).toFixed(2);
}

$scope.AddLoom = function(e){
if(!$scope.production.operator) {
alert('Please Select Loom Weaver');
return false;
}
const data = new FormData(e.target);
data.append('pid',$scope.production.id);
data.append('operator',$scope.production.operator);
data.append('Loom_No',$scope.data.Loom_No);
data.append('product_id',$scope.data.id);
data.append('date',$filter('date')($scope.production.date,'yyyy-MM-dd'));
$http.post(baseUrl+'production_loom',data,{headers: {'Content-Type': undefined}}).then(function(response){
$(e.target).trigger('reset');
$scope.data = {};
$scope.entry.push(response.data);
})
}

$scope.AddStatus = function(e){
const data = new FormData(e.target);
data.append('pid',$scope.production.id);
data.append('Loom_No',$scope.data.Loom_No);
data.append('date',$filter('date')($scope.production.date,'yyyy-MM-dd'));
$http.post(baseUrl+'production_status',data,{headers: {'Content-Type': undefined}}).then(function(response){
$(e.target).trigger('reset');
$scope.status.push(response.data);
})
}

})


Expand Down

0 comments on commit 1cc10df

Please sign in to comment.