550 lines
24 KiB
PHP
Executable File
550 lines
24 KiB
PHP
Executable File
<?php
|
|
|
|
$MaterialCode = '';
|
|
$MaterialName = '';
|
|
$MaterialType = '';
|
|
$MaterialCategory = '';
|
|
$UOM = '';
|
|
$remarks = '';
|
|
$HSNcode = '';
|
|
$IsActive = '';
|
|
$openstock = '';
|
|
$date = '';
|
|
$reorder = '';
|
|
$total = 0;
|
|
|
|
$date_today = date("Y-m-d");
|
|
|
|
//print_r($materialDetails);
|
|
|
|
if (!empty($materialDetails)) {
|
|
foreach ($materialDetails as $MD) {
|
|
$MaterialCode = $MD->MaterialCode;
|
|
$MaterialName = $MD->MaterialName;
|
|
$MaterialType = $MD->MaterialType;
|
|
$MaterialCategory = $MD->Category;
|
|
$UOM = $MD->UOM;
|
|
$remarks = $MD->Remarks;
|
|
$HSNcode = $MD->HSNCODE;
|
|
$openstock = $MD->stock;
|
|
$date = $MD->stockdate;
|
|
$reorder = $MD->reorder;
|
|
$chk = $MD->IsActive;
|
|
$IsActive = ($chk == 1) ? 'checked' : '';
|
|
}
|
|
}
|
|
|
|
|
|
$Average_Price = $avg_price[0]['avg_rate'];
|
|
$Average_Value = number_format($Average_Price, 2, '.', '');
|
|
|
|
if (!empty($currentstock)) {
|
|
|
|
$currentstock = $currentstock[0]['remainingqty'];
|
|
|
|
$x = $openstock;
|
|
$y = $currentstock;
|
|
|
|
$todaydateyear = format_date($date_today, 0, "Y");
|
|
$todaydatemonth = format_date($date_today, 0, 'm');
|
|
$todaydatedate = format_date($date_today, 0, 'd');
|
|
$openstockdateyear = format_date($date, 0, 'Y');
|
|
|
|
$parts = explode('-', $date);
|
|
$openstockdatemonth = $parts[1] ?? 0;
|
|
$openstockdatedate = $parts[2] ?? '';
|
|
|
|
|
|
if ($openstockdateyear == $todaydateyear) {
|
|
if ($openstockdatemonth <= 03) {
|
|
$total = $y == '' ? '0' : $y;
|
|
} else {
|
|
$total = (int)$x + (int)$y;
|
|
}
|
|
} else if ($openstockdateyear < $todaydateyear) {
|
|
//$total= $y;
|
|
$total = $y == '' ? '0' : $y;
|
|
} else if ($openstockdateyear > $todaydateyear) {
|
|
$total = $x + $y;
|
|
}
|
|
}
|
|
|
|
|
|
?>
|
|
|
|
<?php
|
|
|
|
if ($total <= $reorder) {
|
|
|
|
echo '<script type="text/javascript">alert("Current Stock Low ");</script>';
|
|
}
|
|
?>
|
|
<script>
|
|
$(function() {
|
|
$("#Date").datepicker({
|
|
//minDate :'now',
|
|
//maxDate : 'now',
|
|
dateFormat: 'dd-mm-yy',
|
|
changeMonth: true,
|
|
changeYear: true,
|
|
yearRange: '-100:+1'
|
|
});
|
|
});
|
|
</script>
|
|
<style>
|
|
.autocomplete-suggestion {
|
|
cursor: pointer;
|
|
background-color: skyblue;
|
|
/* background-color: darkgrey; */
|
|
outline: 1px solid slategrey;
|
|
}
|
|
</style>
|
|
<script type="text/javascript" src="<?php echo base_url(); ?>public/assets/Autocomplete/jquery.autocomplete.js"></script>
|
|
|
|
|
|
<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 class="page-title">Edit Material - <?php echo $MaterialCode; ?> Details</h4>
|
|
<button type="button" class="btn btn-secondary" onclick="history.back()">
|
|
<span class="bold">Cancel</span>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- End page title -->
|
|
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<form role="form" action="<?php echo base_url() ?>rawmaterialdetails/editRawmaterial" method="post" id="editRawmaterial">
|
|
<div class="box-body">
|
|
<!-- Material Information -->
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<div class="form-row mb-3">
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="RMcode">Material Code</label>
|
|
<input type="text" class="form-control" readonly id="RMcode" name="RMcode" maxlength="255" value="<?php echo $MaterialCode; ?>">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="MaterialName">Material Name <span class="text-danger">*</span></label>
|
|
<input type="text" class="form-control" id="MaterialName" name="MaterialName" maxlength="255" value="<?php echo htmlentities($MaterialName); ?>" required>
|
|
<input type="hidden" class="form-control" id="MaterialCode" name="MaterialCode" maxlength="255" value="<?php echo $MaterialCode; ?>">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="MaterialType">Material Type <span class="text-danger">*</span></label>
|
|
<select class="form-control select2" id="MaterialType" name="MaterialType" required>
|
|
<?php
|
|
if (!empty($material)) {
|
|
foreach ($material as $SID) {
|
|
?>
|
|
<option value="<?= $SID->ConfigValue ?>" <?php if ($MaterialType === $SID->ConfigValue) echo "selected"; ?>>
|
|
<?php echo $SID->ConfigValue ?>
|
|
</option>
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="MaterialCategory">Material Category
|
|
<span class="badge">*</span></label>
|
|
<i type="button" class="fe-plus-circle" id="addMaterialCaterogyModalButton"
|
|
style="font-size: 16px; color:rgb(15, 155, 218);" data-toggle="modal" data-target="#addMaterialCaterogyModal"
|
|
title="Add Material Caterogy">
|
|
</i>
|
|
<select class="form-control select2" id="MaterialCategory" name="MaterialCategory" required>
|
|
<?php
|
|
if (!empty($materialCategoryList)) {
|
|
foreach ($materialCategoryList as $record) {
|
|
?>
|
|
<option value="<?= $record['category_name'] ?>" <?php if ($record['category_name'] === $MaterialCategory) echo "selected"; ?>>
|
|
<?php echo $record['category_name'] ?>
|
|
</option>
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="form-row mb-3">
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="UOM">Unit of Measurement <span class="text-danger">*</span></label>
|
|
<select class="form-control select2" id="UOM" name="UOM" required>
|
|
<option value="<?php echo $UOM; ?>"><?php echo $UOM; ?></option>
|
|
<?php
|
|
if (!empty($UOMList)) {
|
|
foreach ($UOMList as $UM) {
|
|
?>
|
|
<option value="<?php echo $UM->ConfigValue; ?>"><?php echo $UM->ConfigValue ?></option>
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="HSNcode">HSN Code</label>
|
|
<input type="text" class="form-control" id="HSNcode" name="HSNcode" maxlength="8" value="<?php echo $HSNcode; ?>" onkeypress="return isNumberKey(event)">
|
|
</div>
|
|
</div>
|
|
<?php if ($openstock != "") { ?>
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="openstock">Opening Stock</label>
|
|
<input type="text" class="form-control" id="openstock" name="openstock" value="<?php echo $openstock; ?>" maxlength="255">
|
|
</div>
|
|
</div>
|
|
<?php } else { ?>
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="openstock">Opening Stock</label>
|
|
<input type="text" class="form-control" id="openstock" name="openstock" maxlength="255">
|
|
</div>
|
|
</div>
|
|
<?php } ?>
|
|
|
|
<?php if ($date != "") { ?>
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label>Open Stock Date</label>
|
|
<input type="text" name="Date" id="Date" class="form-control" value="<?php echo $date; ?>" readonly>
|
|
</div>
|
|
</div>
|
|
<?php } else { ?>
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label>Open Stock Date</label>
|
|
<input type="text" name="Date" id="Date" class="form-control" readonly>
|
|
</div>
|
|
</div>
|
|
<?php } ?>
|
|
</div>
|
|
<div class="form-row mb-3">
|
|
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="reorder">Reorder Level</label>
|
|
<input type="text" class="form-control" id="reorder" name="reorder" value="<?php echo $reorder; ?>" maxlength="255">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="currentstock">Current Stock</label>
|
|
<input type="text" class="form-control" id="currentstock" name="currentstock" readonly value="<?php echo $total; ?>" maxlength="255">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="avg_price">Average Price</label>
|
|
<input type="text" class="form-control" id="avg_price" name="avg_price" readonly value="<?php echo $Average_Value ?>" maxlength="255">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="remarks">Remarks</label>
|
|
<input type="text" class="form-control" id="remarks" name="remarks" maxlength="255" value="<?php echo $remarks; ?>">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="form-row mb-3">
|
|
|
|
<div class="col-md-2">
|
|
<div class="form-group">
|
|
<label for="isactive">Is Active</label><br />
|
|
<input type="checkbox" id="isactive" name="isactive" <?php echo $IsActive; ?>>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="box-footer text-right">
|
|
<button type="button" class="btn btn-secondary" onclick="history.back()">
|
|
<span class="bold">Cancel</span>
|
|
</button>
|
|
<input type="submit" class="btn btn-success" value="Submit" />
|
|
</div>
|
|
</form>
|
|
</div><!-- /.card-body -->
|
|
</div><!-- /.card -->
|
|
</div><!-- /.col -->
|
|
</div><!-- /.row -->
|
|
</div><!-- /.container-fluid -->
|
|
</div><!-- /.content -->
|
|
</div><!-- /.content-page -->
|
|
|
|
|
|
|
|
|
|
<!-- modal -->
|
|
|
|
<div class="modal fade" id="addMaterialCaterogyModal" tabindex="-1" aria-labelledby="addMaterialCaterogyModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="addMaterialCaterogyModalLabel">Add Material Category</h5>
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<form id="addMaterialCategoryForm">
|
|
<div class="form-group">
|
|
<label for="materialCategoryInput">Material Category</label>
|
|
<input type="text" class="form-control" id="materialCategoryInput" placeholder="Enter material category">
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
|
|
<button type="button" class="btn btn-primary" onclick="addMaterialCategory()">Save Category</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script src="<?php echo base_url(); ?>public/assets/js/editUser.js" type="text/javascript"></script>
|
|
<script>
|
|
$(document).ready(function() {
|
|
|
|
|
|
$("#UOM").select2();
|
|
$("#MaterialType").select2();
|
|
$("#MaterialCategory").select2();
|
|
/** ---- auto search code -------- */
|
|
$('#MaterialCategory').autocomplete({
|
|
|
|
onSearchStart: function(query) {
|
|
|
|
$('#MaterialCategory').autocomplete("option", "minLength", 0);
|
|
},
|
|
|
|
serviceUrl: "<?php echo base_url(); ?>rawmaterialdetailsautocomplete",
|
|
onSelect: function(suggestion) {
|
|
|
|
var data = suggestion.ConfigValue;
|
|
var selectedvalue = $('input[name=MaterialCategory]').val();
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
function onlyAlphabets(evt) {
|
|
var charCode;
|
|
if (window.event)
|
|
charCode = window.event.keyCode; //for IE
|
|
else
|
|
charCode = evt.which; //for firefox
|
|
if (charCode == 32) //for <space> symbol
|
|
return true;
|
|
if (charCode > 31 && charCode < 65) //for characters before 'A' in ASCII Table
|
|
return false;
|
|
if (charCode > 90 && charCode < 97) //for characters between 'Z' and 'a' in ASCII Table
|
|
return false;
|
|
if (charCode > 122) //for characters beyond 'z' in ASCII Table
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
function isNumberKey(evt) {
|
|
var charCode = (evt.which) ? evt.which : evt.keyCode;
|
|
if (charCode != 46 && charCode > 31 &&
|
|
(charCode < 48 || charCode > 57))
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
function onlyAlphabets(evt) {
|
|
var charCode;
|
|
if (window.event)
|
|
charCode = window.event.keyCode; //for IE
|
|
else
|
|
charCode = evt.which; //for firefox
|
|
if (charCode == 32) //for <space> symbol
|
|
return true;
|
|
if (charCode > 31 && charCode < 65) //for characters before 'A' in ASCII Table
|
|
return false;
|
|
if (charCode > 90 && charCode < 97) //for characters between 'Z' and 'a' in ASCII Table
|
|
return false;
|
|
if (charCode > 122) //for characters beyond 'z' in ASCII Table
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
$('#MaterialName').change(function() {
|
|
|
|
var materialname = $('#MaterialName').val();
|
|
//var s = "I am Given String ";
|
|
//material = material.replace(/\s*$/,"");
|
|
var material = materialname.replace(/ /g, '');
|
|
//alert(m.length+" "+m+" "+s+" "+s.length);
|
|
$('#loader').show();
|
|
$.ajax({
|
|
data: {
|
|
id: material
|
|
},
|
|
type: "POST",
|
|
url: "<?php echo base_url(); ?>materialExist",
|
|
success: function(data) {
|
|
var count = data.length;
|
|
//alert(count);
|
|
|
|
if (count >= 1) {
|
|
$('#loader').hide();
|
|
if(data[0].IsActive == 1){
|
|
alert('Material name already existed ! ');
|
|
}else{
|
|
alert('Material name already existing in the deleted section.!!');
|
|
}
|
|
var related_name = "";
|
|
$.each(data, function(i, obj) {
|
|
|
|
related_name += obj.MaterialCode + " - " + obj.MaterialName + " - " + obj.MaterialType + " - " + obj.Category + "\n";
|
|
|
|
});
|
|
|
|
alert("'" + materialname + "' - related materials are , " + " \n \n" + related_name);
|
|
$("#MaterialName").val('');
|
|
$("#MaterialName").focus();
|
|
} else {
|
|
$('#loader').hide();
|
|
// alert("empty data");
|
|
}
|
|
|
|
},
|
|
error: function() {
|
|
$('#loader').hide();
|
|
alert("Error Occur");
|
|
}
|
|
|
|
});
|
|
});
|
|
</script>
|
|
|
|
|
|
<script>
|
|
function addMaterialCategory (){
|
|
|
|
$('#materialCategoryInput').val()
|
|
|
|
let materialCategory = $('#materialCategoryInput').val().trim();
|
|
|
|
if (materialCategory.length <= 2) {
|
|
alert('Material Category should have more than 2 letters.');
|
|
return false;
|
|
}
|
|
|
|
if (materialCategory.length > 20) {
|
|
alert('Material Category should have fewer than 20 letters.');
|
|
return false;
|
|
}
|
|
|
|
$.ajax({
|
|
url: "<?php echo base_url('/rawmaterialdetails/addMaterialCategories'); ?>",
|
|
type: 'POST',
|
|
data: {
|
|
category_name: materialCategory
|
|
},
|
|
success: function(response) {
|
|
|
|
if(response.status=="201"){
|
|
|
|
$("#addMaterialCaterogyModal").modal('hide');
|
|
$("#MaterialCategory").append(`<option value="${materialCategory}" selected > ${materialCategory} </option>`)
|
|
}
|
|
else if(response.status=="409"){
|
|
|
|
$("#addMaterialCaterogyModal").modal('hide');
|
|
|
|
$('#MaterialCategory').val(materialCategory);
|
|
|
|
$('#MaterialCategory').trigger('change');
|
|
|
|
setTimeout(()=>{ alert(`${response.message}`) },1000)
|
|
}
|
|
else{
|
|
$("#addMaterialCaterogyModal").modal('hide');
|
|
|
|
setTimeout(()=>{ alert('Error Adding Category..!!'); },1000)
|
|
|
|
}
|
|
|
|
|
|
},
|
|
error: function(xhr, status, error) {
|
|
// Handle errors
|
|
alert('Error adding category');
|
|
console.log(error);
|
|
}
|
|
});
|
|
|
|
|
|
}
|
|
</script>
|