463 lines
19 KiB
PHP
Executable File
463 lines
19 KiB
PHP
Executable File
<?php
|
|
|
|
$MaterialCode = '';
|
|
$MaterialName = '';
|
|
$MaterialType = '';
|
|
$MaterialCategory = '';
|
|
$UOM = '';
|
|
$Assetcode ='';
|
|
$costcenter='';
|
|
$remarks='';
|
|
$conversionfactorUOM='';
|
|
$conversionactor ='';
|
|
$RMCode = '';
|
|
$HSNcode = '';
|
|
$IsActive = '';
|
|
$openstock='';
|
|
$date='';
|
|
$reorder='';
|
|
|
|
if(!empty($materialDetails))
|
|
{
|
|
foreach ($materialDetails as $MD)
|
|
{
|
|
$MaterialCode = $MD->MaterialCode;
|
|
$MaterialName = $MD->MaterialName;
|
|
|
|
$MaterialType = $MD->MaterialType;
|
|
$MaterialCategory = $MD->Category;
|
|
$UOM = $MD->UOM;
|
|
$Assetcode = $MD->assetcode;
|
|
$costcenter = $MD->CostCenterCode;
|
|
$remarks = $MD->Remarks;
|
|
$conversionfactor = $MD->ConversionFactorUnit;
|
|
$conversionfactorUOM = $MD->ConversionFactorUOM;
|
|
$RMCode = $MD->RMCode;
|
|
$HSNcode = $MD->HSNCODE;
|
|
$openstock=$MD->stock;
|
|
$date=$MD->stockdate;
|
|
|
|
$reorder=$MD->reorder;
|
|
$chk = $MD->IsActive;
|
|
|
|
if($chk == 1)
|
|
{
|
|
$IsActive = 'checked';
|
|
}
|
|
else
|
|
{
|
|
$IsActive = '';
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
?>
|
|
<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();?>assets/Autocomplete/jquery.autocomplete.js"></script>
|
|
<div class="content-wrapper" style="min-height: 537px;">
|
|
<!-- Content Header (Page header) -->
|
|
<section class="content-header">
|
|
<h1>
|
|
<center>Siddharth Industries - Edit Material -<?php echo $MaterialCode; ?> </center>
|
|
|
|
</h1>
|
|
</section>
|
|
|
|
<section class="content">
|
|
<div style="text-align:right;margin-right:17px">
|
|
<a href="<?php echo base_url() ?>rawmaterialdetails/rawmaterialListing" class="btn btn-primary" value="Back"/>Back</a>
|
|
</div>
|
|
<br/>
|
|
<!-- <div class="row"> -->
|
|
<!-- left column -->
|
|
<div class="col-md-12">
|
|
<!-- general form elements -->
|
|
<div class="box box-primary">
|
|
|
|
<!-- form start -->
|
|
|
|
<form role="form" action="<?php echo base_url() ?>rawmaterialdetails/editRawmaterial" method="post" id="editRawmaterial" role="form">
|
|
<div class="box-body">
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
|
|
<div class="col-md-2">
|
|
<div class="form-group">
|
|
<label for="RMcode">MaterialCode</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</label><font color="Red">*</font>
|
|
<input type="text" class="form-control required " id="MaterialName" name="MaterialName" maxlength="255" value="<?php echo htmlentities($MaterialName);?>">
|
|
<input type="hidden" class="form-control required " id="MaterialCode" value="<?php echo $MaterialCode;?>"name="MaterialCode" maxlength="255">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-2">
|
|
|
|
<div class="form-group">
|
|
<label for="MaterialType">Material Type</label>
|
|
<input type="text" class="form-control" readonly id="MaterialType" name="MaterialType" value="<?php echo $MaterialType;?>">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-3">
|
|
|
|
<div class="form-group autoSearch" id="mc">
|
|
<label for="Matcate">Material Caterogy</label><font color="Red">*</font>
|
|
<input type="text" class="form-control required " required id="MaterialCategory" name="MaterialCategory" value="<?php echo $MaterialCategory;?>" maxlength="255">
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
<div class="col-md-2">
|
|
<div class="form-group">
|
|
<label for="UOM">Unit of Measurement</label><font color="Red">*</font>
|
|
<!-- <select class="form-control select2 required " required id="UOM" name="UOM">
|
|
<option value=" ">Select UOM</option>
|
|
</select> -->
|
|
<select class="form-control required select2" id="UOM" name="UOM" onchange="changeTextBox();" >
|
|
<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 ?>
|
|
<?php
|
|
}
|
|
}
|
|
?>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
|
|
<div class="col-md-12">
|
|
|
|
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="assetcode">Asset Code</label>
|
|
<select class="form-control select2" id="Assetcode" name="Assetcode" disabled="disabled" >
|
|
<option value=" ">Select Asset Code</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="costcenter">Cost Center Code</label>
|
|
<select class="form-control select2" id="Costcenter" name="Costcenter" disabled="disabled" >
|
|
<option value=" ">Select Cost Center Code</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="conversionfactor">Conversion Factor</label>
|
|
<input type="text" class="form-control" id="conversionfactor" name="conversionfactor" maxlength="255" value="<?php echo $conversionfactor;?>">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="conversionfactorUOM">Conversion Factor UOM</label>
|
|
<select class="form-control select2" id="conversionfactorUOM" name="conversionfactorUOM" >
|
|
<option value=" ">Select Conversion Factor UOM</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-12">
|
|
<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 autoSearch" id="mc">
|
|
<label for="Matcate">Open Stock</label>
|
|
<input type="text" class="form-control required " id="openstock" readonly name="openstock" value="<?php echo $openstock;?>" maxlength="255">
|
|
</div>
|
|
|
|
</div>
|
|
<?php
|
|
|
|
} else
|
|
{
|
|
?>
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="conversionfactor">Open 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">
|
|
<label>Open Stock Date</label>
|
|
<?php
|
|
$data = array('name' => 'Date','value' => set_value('Date',$date), 'class' => 'form-control','readonly'=>'true', 'onkeypress'=>'return false;');
|
|
echo form_input($data);
|
|
?>
|
|
</div>
|
|
<?php
|
|
|
|
} else
|
|
{
|
|
?>
|
|
<div class="col-md-3">
|
|
<label>Open Stock Date</label>
|
|
<?php
|
|
$data = array('name' => 'Date','id'=>'Date', 'class' => 'form-control' , 'onkeypress'=>'return false;');
|
|
echo form_input($data);
|
|
?>
|
|
</div>
|
|
<?php
|
|
}
|
|
?>
|
|
<div class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="conversionfactor">Reorder Level</label>
|
|
<input type="text" class="form-control" id="reorder" value="<?php echo $reorder;?>" name="reorder" maxlength="255">
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
<div class="col-md-12">
|
|
|
|
<div class="col-md-6">
|
|
<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 class="col-md-3">
|
|
<div class="form-group">
|
|
<label for="Active">IsActive</label> <br/>
|
|
<input type="checkbox" id="isactive" name="isactive" <?php echo $IsActive; ?> >
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div><!-- /.box-body -->
|
|
|
|
<div class="box-footer" style="text-align:right">
|
|
<input type="submit" class="btn btn-primary" value="Submit" />
|
|
<a href="<?php echo base_url() ?>rawmaterialdetails/rawmaterialListing" class="btn btn-primary" value="Cancel"/>Cancel</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</section>
|
|
</div>
|
|
|
|
<script src="<?php echo base_url(); ?>assets/js/editUser.js" type="text/javascript"></script>
|
|
<script>
|
|
$(document).ready(function(){
|
|
|
|
|
|
$("#UOM").select2();
|
|
$("#Assetcode").select2();
|
|
$("#Costcenter").select2();
|
|
$("#conversionfactorUOM").select2();
|
|
/** ---- auto search code -------- */
|
|
$('#MaterialCategory').autocomplete({
|
|
|
|
onSearchStart: function (query) {
|
|
|
|
$('#MaterialCategory').autocomplete("option", "minLength", 0);
|
|
},
|
|
|
|
serviceUrl: "<?php echo base_url();?>rawmaterialdetails/autocomplete",
|
|
onSelect: function (suggestion) {
|
|
|
|
var data = suggestion.ConfigValue;
|
|
var selectedvalue = $('input[name=MaterialCategory]').val();
|
|
if(selectedvalue=='Spares')
|
|
{
|
|
|
|
$('#Assetcode').prop('disabled', false);
|
|
$('#Costcenter').prop('disabled', false);
|
|
}
|
|
else{
|
|
|
|
$('#Assetcode').prop('disabled', 'disabled');
|
|
$('#Costcenter').prop('disabled', 'disabled');
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
/** ---- Value are append to dropdown -------- */
|
|
//var uom = [];
|
|
var ass = [];
|
|
var cos = [];
|
|
var con = [];
|
|
|
|
//uom = <?php echo json_encode($UOMList) ?>;
|
|
ass = <?php echo json_encode($assetcode)?>;
|
|
cos = <?php echo json_encode($costcentercode)?>;
|
|
con = <?php echo json_encode($cfUOM)?>;
|
|
|
|
// $.each(uom,function(u,um){
|
|
// $("#UOM").append( $('<option></option>').val(um.ConfigValue).html(um.ConfigValue));
|
|
// });
|
|
|
|
// $('#UOM option[value="<?php echo $UOM?>"]').prop('selected', true);
|
|
|
|
$.each(ass,function(a,as){
|
|
$("#Assetcode").append( $('<option></option>').val(as.AssetCode).html(as.AssetCode+'-'+as.AssetName));
|
|
});
|
|
|
|
$('#Assetcode option[value="<?php echo $Assetcode?>"]').prop('selected', true);
|
|
|
|
$.each(cos,function(c,cc){
|
|
$("#Costcenter").append( $('<option></option>').val(cc.CostCenterCode).html(cc.CostCenterCode+'-'+cc.CostCenterName));
|
|
});
|
|
|
|
$('#Costcenter option[value="<?php echo $costcenter?>"]').prop('selected', true);
|
|
|
|
$.each(con,function(cn,con){
|
|
$("#conversionfactorUOM").append( $('<option></option>').val(con.ConfigValue).html(con.ConfigValue));
|
|
});
|
|
|
|
$('#conversionfactorUOM option[value="<?php echo $conversionfactorUOM?>"]').prop('selected', true);
|
|
|
|
/** ---- if spares part matereial means -------- */
|
|
var x = $("#MaterialCategory").val() == 'Spares';
|
|
if(x)
|
|
{
|
|
$('#Assetcode').prop('disabled', false);
|
|
$('#Costcenter').prop('disabled', false);
|
|
}
|
|
|
|
});
|
|
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);
|
|
$('#content').loader('show');
|
|
$.ajax({
|
|
data:{id:material},
|
|
type:"POST",
|
|
url:"<?php echo base_url();?>rawmaterialdetails/checkmaterial",
|
|
success:function(data) {
|
|
var count = data.length;
|
|
//alert(count);
|
|
|
|
if(count >2 ){
|
|
$('#content').loader('hide');
|
|
alert('Material name already existed ! ');
|
|
dat = JSON.parse(data);
|
|
var related_name = "";
|
|
$.each(dat,function(i,obj){
|
|
|
|
related_name += obj.MaterialCode +" - "+ obj.MaterialName+" - "+obj.MaterialType+" - "+obj.Category+"\n";
|
|
|
|
});
|
|
|
|
alert("'" + materialname + "' - related materials are , " + " \n \n" + related_name);
|
|
$("#MaterialName").focus();
|
|
}
|
|
else{
|
|
$('#content').loader('hide');
|
|
// alert("empty data");
|
|
}
|
|
|
|
}
|
|
});
|
|
});
|
|
</script>
|