mater master issue fixes

This commit is contained in:
venbatechnologies@gmail.com 2018-03-06 18:35:38 +05:30
parent 9974c62570
commit dec9e33cda
2 changed files with 73 additions and 142 deletions

View File

@ -14,6 +14,7 @@ class rawmaterialdetails_model extends CI_Model
{
$this->db->select('*');
$this->db->from('T_MaterialMaster');
$this->db->where('IsActive',1 );
$query = $this->db->get();
$result = $query->result();
return $result;

View File

@ -105,22 +105,6 @@ if(!empty($materialDetails))
<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;?>">
<!-- <select class="form-control select2" id="MaterialType" name="MaterialType" readonly="true">
<option value="<?php echo $MaterialType;?> "><?php echo $MaterialType;?></option>
<?php
if(!empty($materialType))
{
foreach ($materialType as $MID)
{
?>
<option value="<?php echo $MID->ConfigValue ?>"><?php echo $MID->ConfigValue ?></option>
<?php
}
}
?>
</select>
-->
</div>
</div>
@ -129,30 +113,9 @@ if(!empty($materialDetails))
<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-6">
<div class="form-group">
<label for="MaterialCategory">Material Category</label>
<input type="text" class="form-control" readonly id="MaterialCategory" name="MaterialCategory" value="<?php echo $MaterialCategory;?>" onChange="changeTextBox();">
<!- <select class="form-control readonly select2" id="MaterialCategory" name="MaterialCategory" onChange="changeTextBox();">
<option value="<?php echo $MaterialCategory;?> "><?php echo $MaterialCategory;?></option>
<?php
if(!empty($materialCategory))
{
foreach ($materialCategory as $MC)
{
?>
<option value="<?php echo $MC->ConfigValue ?>"><?php echo $MC->ConfigValue ?></option>
<?php
}
}
?>
</select>
<!- <input type='hidden' id='mchiddenfield' name='mchiddenfield' value=''>
</div>
</div>-->
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label for="UOM">Unit of Measurement</label><font color="Red">*</font>
@ -181,41 +144,18 @@ if(!empty($materialDetails))
<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" placeholder="Select ">
<option value="<?php echo $Assetcode;?>"><?php echo $Assetcode;?></option>
<?php
if(!empty($assetcode))
{
foreach($assetcode as $AC)
{
?>
<option value="<?php echo $AC->AssetCode ?>"><?php echo $AC->AssetCode ?> - <?php echo $AC->AssetName ?></option>
<?php
}
}
?>
</select>
<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><?php echo $costcenter;?></option>
<?php
if(!empty($costcentercode))
{
foreach ($costcentercode as $CC)
{
?>
<option value="<?php echo $CC->CostCenterCode ?>"><?php echo $CC->CostCenterCode ?> - <?php echo $CC->CostCenterName?></option>
<?php
}
}
?>
</select>
<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">
@ -227,30 +167,22 @@ if(!empty($materialDetails))
<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="<?php echo $conversionfactorUOM;?>"><?php echo $conversionfactorUOM;?></option>
<?php
if(!empty($cfUOM))
{
foreach ($cfUOM as $cfuom)
{
?>
<option value="<?php echo $cfuom->ConfigValue; ?>"><?php echo $cfuom->ConfigValue ?>
<?php
}
}
?>
<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>
<div class="col-md-6">
<div class="form-group">
<label for="remarks">Remarks</label>
@ -286,57 +218,78 @@ if(!empty($materialDetails))
<script>
$(document).ready(function(){
//$("#MaterialType").select2();
//$("#MaterialCategory").select2();
$("#UOM").select2();
$("#Assetcode").select2();
$("#Costcenter").select2();
$("#conversionfactorUOM").select2();
/** ---- auto search code -------- */
$('#MaterialCategory').autocomplete({
onSearchStart: function (query) {
//alert(query);
$('#MaterialCategory').autocomplete("option", "minLength", 0);
},
onSearchStart: function (query) {
//alert(query);
$('#MaterialCategory').autocomplete("option", "minLength", 0);
},
serviceUrl: "<?php echo base_url();?>rawmaterialdetails/autocomplete",
onSelect: function (suggestion) {
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{
var data = suggestion.ConfigValue;
var selectedvalue = $('input[name=MaterialCategory]').val();
if(selectedvalue=='Spares')
{
//alert('good');
$('#Assetcode').prop('disabled', false);
$('#Costcenter').prop('disabled', false);
}
else{
// // alert('bad');
$('#Assetcode').prop('disabled', 'disabled');
$('#Costcenter').prop('disabled', 'disabled');
}
}
$('#Assetcode').prop('disabled', 'disabled');
$('#Costcenter').prop('disabled', 'disabled');
}
}
});
var x = $("#MaterialCategory").val() == 'Spares';
if(x)
{
document.getElementById("Assetcode").disabled=false;
document.getElementById("Costcenter").disabled=false;
}
else
{
//alert('i am a else part');
document.getElementById("Assetcode").disabled=true;
document.getElementById("Costcenter").disabled=true;
}
if(x)
{
$('#Assetcode').prop('disabled', false);
$('#Costcenter').prop('disabled', false);
}
/** ---- Value are append to dropdown -------- */
var ass = [];
var cos = [];
var con = [];
ass = <?php echo json_encode($assetcode)?>;
cos = <?php echo json_encode($costcentercode)?>;
con = <?php echo json_encode($cfUOM)?>;
$.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);
});
function onlyAlphabets(evt) {
var charCode;
if (window.event)
@ -362,13 +315,6 @@ function isNumberKey(evt)
return true;
}
// $(function() {
// $('#MaterialCategory').change(function() {
// var x = $(this).val();
// alert(x);
// $('#mchiddenfield').val(x);
// });
// });
function onlyAlphabets(evt) {
var charCode;
@ -387,22 +333,6 @@ function onlyAlphabets(evt) {
return true;
}
// function changeTextBox() {
// //alert('changeTextBox entered');
// var x = document.getElementById("MaterialCategory");
// if(x.value=='Spares')
// {
// //alert('i am an if part');
// document.getElementById("Assetcode").disabled=false;
// document.getElementById("Costcenter").disabled=false;}
// else
// {
// //alert('i am a else part');
// document.getElementById("Assetcode").disabled=true;
// document.getElementById("Costcenter").disabled=true;}
// }
$('#MaterialName').change(function() {
var materialname = $('#MaterialName').val();
@ -421,7 +351,7 @@ $('#MaterialName').change(function() {
$('#content').loader('hide');
swal({
title: "'" + materialname + " already existed ! ",
// type: "info",
showCancelButton: true,
confirmButtonClass: "btn-danger",
confirmButtonText: "Material Details!",