siddharth_application/application/views/editstorerequisition.php
2021-04-23 12:07:34 +05:30

1129 lines
29 KiB
PHP

<?php
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
$CurrentDate = $dt->format('d-m-Y');
// print_r($cost);die();
$CostCenterCode='';
$StoreReqNo='';
$StatusCode ='';
foreach ($cost as $key ) {
$CostCenterCode = $key->CostCenterName;
$StoreReqNo=$key->StoreReqNo;
//print_r($CostCenterCode);# code...
}
foreach ($Status as $key ) {
$StatusCode = $key->Status;
}
//echo $StatusCode;
?>
<script>
$(function() {
//Initialize Select2 Elements
$("#CostCenter").select2();
$("#MaterialCode").select2();
$("#Date").datepicker({
// minDate : 'now',
maxDate : 'now',
dateFormat: 'dd-mm-yy',changeMonth: true, changeYear: true,yearRange: '-100:+0'
});
});
</script>
<style type="text/css">
.num{
text-align:left;
}
.select2
{
width: 100% ! important;
}
</style>
<div class="content-wrapper">
<div id="content"></div>
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<center>Siddharth Industries - Edit Store Requisition - <?php echo $StoreReqNo; ?></center>
</h1>
</section>
<section class="content">
<div class="row" style="border:2px dotted; padding:5%">
<?php
$attributes = array('class' => 'form-label-left requistion ','name' => 'requistion','id' => 'requistion');
echo form_open($this->config->base_url().'storerequisitionlist
/EditStoreRequistion',$attributes);
?>
<!-- <form method="post" role="form" > -->
<div class="row">
<input type="hidden" name="txtReqNo" id="txtReqNo" value="<?php echo $StoreReqNo?>"/>
<div class="col-md-3">
<label>Requested By</label>
<?php
$data = array('name' => 'RequestedBy','value' => set_value('RequestedBy',$name), 'id'=>'RequestedBy','class' => 'form-control num' ,'required' => 'true' ,'readonly' => 'true');
echo form_input($data);
?>
</div>
<div class="col-md-3">
<label>Department Name</label>
<?php
$data = array('name' => 'DepartmentName','value' => set_value('DepartmentName',$DEPCode . "-".$DepName), 'id'=>'DepartmentName','class' => 'form-control num' ,'required' => 'true' ,'readonly' => 'true');
echo form_input($data);
?>
</div>
<div class="col-md-3">
<label>Requested Date</label>
<?php
$data = array('name' => 'Date','value' => set_value('Date',$CurrentDate), 'id' =>"Date", 'class' => 'form-control num' ,'required' => 'true');
echo form_input($data);
?>
</div>
<div class="col-md-3">
<label>Cost Center</label>
<?php
$Costs = array();
//$CostCenterCode = $key->CostCenterName;
//print_r( $options);
if(!empty($cost))
//print_r($cost);
{
foreach ($cost as $SID):
// echo $SID->ConfigValue;
$Costs[$SID->CostCenterCode] = $SID->CostCenterCode .'-'. $SID->CostCenterName ;
endforeach;
}
echo form_dropdown('CostCenter', $Costs,set_value('CostCenter'),'id="CostCenter"' ,'class="form-control select2"' ,'readonly="true"','required="true"');
?>
</div>
<!-- <div class="col-md-2">
<label>Available Budget Amount</label>
<?php
$data = array('name' => 'BudgetAmount','value' => set_value('BudgetAmount'),'id'=>"BudgetAmount", 'class' => 'form-control','readonly' => 'true','required="true"' );
echo form_input($data);
?>
</div> -->
</div>
<br>
<br>
<div class="container-fluid">
<table class="table table-bordered" style="border:1px solid #333">
<div align="right" style="padding-right:10px">
<div align="right">
<?php if( ($StatusCode==STORE_PENDINGAPPROVAL)||($StatusCode==STORE_DRAFT)){?>
<a onclick="return validateBeforeAdd();" class="btn btn-primary">Add Line Item</a>
<?}?>
<!-- Add line Item -->
<div class="modal fade" id="mypo" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<center><h4>Add Line Item </h4></center>
</div>
<div align="left">
<div class="col-md-6">
<label>Material Code</label>
<div >
<?php
$options = array("0"=>'Material Code');
//print_r( $options);
if(!empty($MaterialList))
{
foreach ($MaterialList as $MID):
$options[$MID->MaterialCode] = $MID->MaterialCode.' '.' - '.' '.$MID->MaterialName;
endforeach;
}
echo form_dropdown('MaterialCode', $options,set_value('MaterialCode'),'id="MaterialCode"' ,'class="form-control"');
?>
</div>
</div>
<div class="col-md-6">
<label>Description</label>
<div class="form-group">
<?php
$data = array('name' => 'Description','value' => set_value('Description'),'id'=>'Description', 'class' => 'form-control','readonly' => 'true' );
echo form_input($data);
?>
</div>
</div>
<div class="col-md-6">
<label>UOM</label>
<div>
<?php
$data = array('name' => 'UOM','value' => set_value('UOM'),'id'=>'UOM', 'class' => 'form-control','readonly' => 'true' );
echo form_input($data);
?>
</div>
</div>
<div class="col-md-6">
<label>Quantity</label>
<div class="form-group">
<?php
$data = array('name' => 'Quantity','value' => set_value('Quantity'),'id'=>'Quantity', 'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event)','maxlength'=>'20');
echo form_input($data);
?>
</div>
</div>
<div class="col-md-12">
<label>Remarks</label>
<div class="form-group">
<?php
$data = array('name' => 'Remarks','value' => set_value('Remarks'),'id'=>'Remarks', 'class' => 'form-control');
echo form_input($data);
?>
</div>
</div>
</div>
<div class="modal-footer">
<a class="btn btn-info font addClick" ID="addClick" ><i class="fa fa-plus"></i>&nbsp;&nbsp;<span class="bold">Add</span></a>
<a class="btn btn-info" data-dismiss="modal" value="Cancel">cancel</a>
</div>
</div>
</div>
</div>
<!-- Edit Line Item -->
<div class="modal fade" id="EditItem" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<center><h4>Edit Line Item </h4></center>
</div>
<div align="left">
<div class="col-md-6">
<label>Material Code</label>
<div >
<div class="form-group">
<?php
$data = array('name' => 'EditMaterialCode','value' => set_value('EditMaterialCode'),'id'=>'EditMaterialCode', 'class' => 'form-control','readonly' => 'true' );
echo form_input($data);
?>
</div>
</div>
</div>
<div class="col-md-6">
<label>Description</label>
<div class="form-group">
<?php
$data = array('name' => 'EditDescription','value' => set_value('EditDescription'),'id'=>'EditDescription', 'class' => 'form-control','readonly' => 'true' );
echo form_input($data);
?>
</div>
</div>
<div class="col-md-6">
<label>UOM</label>
<div>
<?php
$data = array('name' => 'EditUOM','value' => set_value('EditUOM'),'id'=>'EditUOM', 'class' => 'form-control','readonly' => 'true' );
echo form_input($data);
?>
</div>
</div>
<div class="col-md-6">
<label>Quantity</label>
<div class="form-group">
<?php
$data = array('name' => 'EditQuantity','value' => set_value('EditQuantity'),'id'=>'EditQuantity', 'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event)','maxlength'=>'20');
echo form_input($data);
?>
</div>
</div>
<div class="col-md-12">
<label>Remarks</label>
<div class="form-group">
<?php
$data = array('name' => 'EditRemarks','value' => set_value('EditRemarks'),'id'=>'EditRemarks', 'class' => 'form-control');
echo form_input($data);
?>
</div>
</div>
</div>
<div class="modal-footer">
<a class="btn btn-info font EditItem" ID="EditItem" ><i class="fa fa-plus"></i>&nbsp;&nbsp;<span class="bold">Edit</span></a>
<a class="btn btn-info" data-dismiss="modal" value="Cancel">cancel</a>
</div>
</div>
</div>
</div>
<!-- View Line Item -->
<div class="modal fade" id="ViewItem" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<center><h4>View Line Item </h4></center>
</div>
<div align="left">
<div class="col-md-6">
<label>Material Code</label>
<div >
<div class="form-group">
<?php
$data = array('name' => 'ViewMaterialCode','value' => set_value('ViewMaterialCode'),'id'=>'ViewMaterialCode', 'class' => 'form-control','readonly' => 'true' );
echo form_input($data);
?>
</div>
</div>
</div>
<div class="col-md-6">
<label>Description</label>
<div class="form-group">
<?php
$data = array('name' => 'ViewDescription','value' => set_value('ViewDescription'),'id'=>'ViewDescription', 'class' => 'form-control','readonly' => 'true' );
echo form_input($data);
?>
</div>
</div>
<div class="col-md-6">
<label>UOM</label>
<div>
<?php
$data = array('name' => 'ViewUOM','value' => set_value('ViewUOM'),'id'=>'ViewUOM', 'class' => 'form-control','readonly' => 'true' );
echo form_input($data);
?>
</div>
</div>
<div class="col-md-6">
<label>Quantity</label>
<div class="form-group">
<?php
$data = array('name' => 'ViewQuantity','value' => set_value('EditQuantity'),'id'=>'ViewQuantity', 'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event)','maxlength'=>'20');
echo form_input($data);
?>
</div>
</div>
<div class="col-md-12">
<label>Remarks</label>
<div class="form-group">
<?php
$data = array('name' => 'ViewRemarks','value' => set_value('ViewRemarks'),'id'=>'ViewRemarks', 'class' => 'form-control');
echo form_input($data);
?>
</div>
</div>
</div>
<div class="modal-footer">
<!-- <a class="btn btn-info font EditItem" ID="EditItem" ><i class="fa fa-plus"></i>&nbsp;&nbsp;<span class="bold">Edit</span></a> -->
<a class="btn btn-info" data-dismiss="modal" value="Cancel">cancel</a>
</div>
</div>
</div>
</div>
</div>
</div>
</table>
</div>
<div class="row" style="padding: 0px 15px 0px 10px;">
<table id="mytable" class="table table-bordered table-hover editableTable" style="background-color:#fff;font-size:12px;">
<thead style="background-color: #CFCFCF;">
<th>SNO</th>
<th>Item Code</th>
<th>Description</th>
<th>UOM</th>
<th>Quantity</th>
<th>Issued Quantity</th>
<th>Remarks</th>
<th>Action</th>
</thead>
<tbody id='mytab'>
<?php
if(!empty($LineItem))
{ //alert();
$index = 0;
foreach($LineItem as $record)
{
//print_r($record);
$index = $index + 1;
//echo $StatusCode;
?>
<tr id="<?php echo $index ; ?>">
<td align="left"><?php echo $index ; ?></td>
<!-- <input type="hidden" name="<?php echo 'te'.$index ?>" id="<?php echo 'te'.$index ?>" value="<?php echo $record->MaterialCode ; ?>" />
<input type="hidden" name="<?php echo 'te'.$index ?>" id="<?php echo 'tes'.$index ?>" value="<?php echo $record->QuantityRequired ; ?>" /> -->
<td align="left"><?php echo $record->MaterialCode ?></td>
<td align="left"><?php echo $record->MaterialName ?></td>
<td align="left"><?php echo $record->UOM ?></td>
<td align="left"><?php echo $record->QuantityRequired ?></td>
<td align="left"><?php echo $record->QuantityIssued ?></td>
<!-- <td align="left"><?php echo $record->StatusName ?></td> -->
<td align="left"><?php echo $record->Remarks ?></td>
<?php
if(($StatusCode==STORE_PENDINGAPPROVAL)||($StatusCode==STORE_DRAFT))
{?>
<td>
<a data-id="<?php echo $index ; ?>" data-userid="<?php echo $index ; ?>" data-target='#EditItem' data-toggle="modal" href="#EditItem"><i class="fa fa-pencil" data-toggle="tooltip" title="Click here to view/Edit the <?php echo $record->MaterialCode ; ?> Material details"></i>&nbsp;&nbsp;&nbsp;</a> <a onclick = "RemoveList(<?php echo $index ; ?>)" class="link" data-id="<?php echo $record->MaterialCode ; ?>" data-userid="<?php echo $index ; ?>" id="Del"><span class="glyphicon glyphicon-trash"></span></a></td>
<?php
}else {?>
<td>
<a data-id="<?php echo $index ; ?>" data-userid="<?php echo $index ; ?>" data-target='#ViewItem' data-toggle="modal" href="#ViewItem"><i class="fa fa-eye" data-toggle="tooltip" title="Click here to view the <?php echo $record->MaterialCode ; ?> Material details"></i>&nbsp;&nbsp;&nbsp;</a>
</td>
<?php
}?>
</td>
</tr>
<?php $RowCount = $index; }
?>
<?php
}?>
</tbody>
</table>
</div>
<br>
<div class="col-md-3 col-md-offset-9" align = "right">
<input type="hidden" name="txtRowCount" id="txtRowCount" />
<input type="hidden" name="txtDeletedRow" id="txtDeletedRow" />
<input type="hidden" name="txtStatus" id="txtStatus" />
<!--<a class="btn btn-primary Save" ID="Save" onclick="Save()" >&nbsp;&nbsp;<span class="bold">Save</span></a> -->
<?php if($StatusCode == STORE_DRAFT)
{ ?>
<a class="btn btn-primary Save" ID="Save" onclick="Save(0)" >&nbsp;&nbsp;<span class="bold">Save</span></a>
<a class="btn btn-primary submit" ID="submit" onclick="Save(1)" >&nbsp;&nbsp;<span class="bold">Submit</span></a>
<input type="reset" class="btn btn-primary">
<?php }
else if($StatusCode == STORE_PENDINGAPPROVAL)
{?>
<!--<a class="btn btn-primary" ID="update" onclick="update()" >&nbsp;&nbsp;<span class="bold">Update</span></a>
<a class="btn btn-primary" href="<?php echo base_url(); ?>Requisition" ID="cancel">&nbsp;&nbsp;<span class="bold">Cancel</span></a> -->
<a class="btn btn-primary Save" ID="submit" onclick="Save(1)" >&nbsp;&nbsp;<span class="bold">Update</span></a>
<?php }
elseif (($StatusCode==STORE_APPROVAL)||($StatusCode==STORE_REJECT))
{?>
<a class="btn btn-primary Save" ID="submit" onclick="Redirect()" >&nbsp;&nbsp;<span class="bold">OK</span></a>
<?php }?>
</div>
</form>
</div>
</section>
</div>
</script>
<script type="text/html" id="tempList">
<tr id="<%=index%>">
<td align="left"><%=index%></td>
<td align="left"><%=MaterialCode%></td>
<td align="left"><%=MaterialName%></td>
<td align="left"><%=UOM%></td>
<td align="left"><%=Quantity%></td>
<td align="left"><%=IssuedQty%></td>
<td align="left"><%=Remarks%></td>
<td>
<a data-target='#EditItem' data-id="<%=index%>" data-userid="<%=index%>" data-toggle="modal" href="#EditItem"><i class="fa fa-pencil" data-toggle="tooltip" title="Click here to view/Edit the <%=MaterialCode%> Material details"></i>&nbsp;&nbsp;&nbsp;</a> <a href='#' onclick = "RemoveList(<%=index%>)" class="link" data-id="<%=index%>" data-userid="<%=index%>" id="Del" ><span class="glyphicon glyphicon-trash"></span></a>
</td>
</tr>
</script>
<!--copy script-->
<script>
var isExceed = 0;
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode != 46 && charCode > 31
&& (charCode < 48 || charCode > 57))
return false;
return true;
}
</script>
<script>
$(function() {
var j=0;
var ReqLineItem = <?php echo json_encode($LineItem, JSON_PRETTY_PRINT) ?>;
$.each(ReqLineItem, function(idx, obj) {
//$("#SupAddress").val(obj.Address);
j= j +1 ;
$('<input>').attr({
type: 'hidden',
id: 'MaterialCode' + j,
name: 'MaterialCode'+ j,
value:obj.MaterialCode
}).appendTo('form');
$('<input>').attr({
type: 'hidden',
id: 'Quantity' + j,
name: 'Quantity'+ j,
value:obj.QuantityRequired
}).appendTo('form');
$('<input>').attr({
type: 'hidden',
id: 'Remarks' + j,
name: 'Remarks'+ j,
value:obj.Remarks
}).appendTo('form');
});
$( ".datePicker" ).datepicker({ dateFormat: 'dd/mm/yy' });
//Initialize Select2 Elements
});
</script>
<script>
$('#CostCenter').change(function() {
var id = $('#CostCenter').val();
$("#BudgetAmount").val('');
var y = <?php echo json_encode($cost, JSON_PRETTY_PRINT) ?>;
$.each(y, function(idx, obj) {
// alert(obj.PONO);
if(id == obj.CostCenterCode)
{
//alert(obj.BudgetAmount);
$("#BudgetAmount").val(obj.BudgetAmount);
}
});
});
</script>
<script>
$('#MaterialCode').change(function() {
var id = $('#MaterialCode').val();
//alert(id);
$("#Description").val('');
$("#UOM").val('');
var z = <?php echo json_encode($MaterialList, JSON_PRETTY_PRINT) ?>;
$.each(z,function(idx,obj){
if(id== obj.MaterialCode){
//alert(obj.MaterialName);
$("#UOM").val(obj.UOM);
$("#Description").val(obj.MaterialName)
}
});
});
</script>
<script>
function addHidden(theForm, key, value) {
// Create a hidden input element, and append it to the form:
var input = document.createElement('input');
input.type = 'hidden';
input.name = key;'name-as-seen-at-the-server';
input.id = key;'name-as-seen-at-the-server';
input.value = value;
theForm.append(input);
}
$("#mypo").on("shown.bs.modal", function(e) {
if($("option:selected", $("#CostCenter")).val() == '-1')
{
alert('Please select the CostCenter ');
e.close();
}
});
var index=<?php echo $index; ?>;
$('.addClick').click(function()
{
if ($("#MaterialCode option:selected").val() =='-1' )
{
alert('Please Select the MaterialCode ');
return false;
}
if(document.getElementById('Quantity').value == '' )
{
alert('Please Enter the Quantity');
return false;
}
if ($("#MaterialCode option:selected").val() !='-1' && $('#Quantity').val() != '' )
{
var temp =index;
temp++;
var MaterialCode = $("#MaterialCode option:selected").val();
var Description =$('#Description').val();
var UOM =$('#UOM').val();
var Quantity =$('#Quantity').val();
var Remarks=$('#Remarks').val();
var IssuedQty=0;
$('#MaterialCode option[value='+MaterialCode+']').remove();
index = parseInt(index)+1;
var template = jQuery("#tempList").html();
$('#mytab').append(_.template(template,{index:temp,MaterialCode:MaterialCode,MaterialName:Description,UOM:UOM,Quantity:Quantity,Remarks:Remarks,IssuedQty:IssuedQty}));
var theForm = $(".requistion");
addHidden(theForm,"MaterialCode"+temp,MaterialCode);
addHidden(theForm,"Description"+temp,Description);
addHidden(theForm,"UOM"+temp,UOM);
addHidden(theForm,"Quantity"+temp,Quantity);
addHidden(theForm,"Remarks"+temp,Remarks);
//alert(JSON.stringify(Description));
$('#txtRowCount').val(temp);
clear();
}
});
function clear()
{
$('#MaterialCode').val('');
$('#Description').val('');
$('#UOM').val('');
$('#Quantity').val('');
$('#Remarks').val('');
}
var userid = '';
function removeHiddenRows(rowcount)
{
var step;
if(rowcount > 2)
{
for (step = 1; step < rowcount ; step++)
{
var td = document.getElementById(step);
td.parentNode.removeChild(td);
$("#MaterialCode"+step).remove();
$("#Description"+step).remove();
$("#UOM"+step).remove();
$("#Quantity"+step).remove();
$("#Remarks"+step).remove();
index = '1';
userid = '';
}
}
}
$("#EditItem").on("shown.bs.modal", function(e) {
userid = $(e.relatedTarget).data('userid');
// alert(userid);
var tr= document.getElementById(userid);
var cellval = tr.cells;
//alert(x[1].innerHTML);
$('#EditMaterialCode').val(cellval[1].innerHTML);
$('#EditDescription').val(cellval[2].innerHTML);
$('#EditUOM').val(cellval[3].innerHTML);
$('#EditQuantity').val(cellval[4].innerHTML);
$('#EditRemarks').val(cellval[6].innerHTML);
});
$("#ViewItem").on("shown.bs.modal", function(e) {
userid = $(e.relatedTarget).data('userid');
// alert(userid);
var tr= document.getElementById(userid);
var cellval = tr.cells;
//alert(x[1].innerHTML);
$('#ViewMaterialCode').val(cellval[1].innerHTML);
$('#ViewDescription').val(cellval[2].innerHTML);
$('#ViewUOM').val(cellval[3].innerHTML);
$('#ViewQuantity').val(cellval[4].innerHTML);
$('#ViewRemarks').val(cellval[5].innerHTML);
});
$('.EditItem').click(function(){
var editMaterialCode = $("#EditMaterialCode").val();
var editDescription = $("#EditDescription").val();
var editUOM = $('#EditUOM').val();
var editQuantity = $('#EditQuantity').val();
var editRemarks = $('#EditRemarks').val();
var tr= document.getElementById(userid);
//alert(tr);
var cellval = tr.cells;
cellval[1].innerHTML = editMaterialCode;
cellval[2].innerHTML = editDescription;
cellval[3].innerHTML = editUOM;
cellval[4].innerHTML = editQuantity;
cellval[6].innerHTML = editRemarks;
$('#MaterialCode'+userid).val(editMaterialCode);
$('#Description'+userid).val(editDescription);
$('#UOM'+userid).val(editUOM);
$('#Quantity'+userid).val(editQuantity);
$('#Remarks'+userid).val(editRemarks);
$('#txtRowCount').val(userid);
});
function Deleterow(rowid)
{
var id = [];
var tr= document.getElementById(rowid);
var cellval = tr.cells;
var MaterialCode = cellval[1].innerHTML;
// alert(cellval[1].innerHTML);
id[0] = $('#txtReqNo').val();
id[1] = MaterialCode;
var answer = confirm(" Do you want to delete the Item from the List?")
if (answer)
{
// To delete the item from list
var x = <?php echo json_encode($LineItem, JSON_PRETTY_PRINT) ?>;
var result = '0';
//alert(x);
//alert(MaterialCode);
if(MaterialCode != "0")
{
$.each(x, function(idx, obj) {
if(obj.MaterialCode === MaterialCode)
{
result = '1';
return false;
}
});
}
if(result == '0')
{
var DelRows = $('#txtDeletedRow').val();
tr.parentNode.removeChild(tr);
if(DelRows != '')
{
DelRows = DelRows + ":" + rowid;
}
else
{
DelRows= "0" + ":" + rowid;
}
$('#txtDeletedRow').val(DelRows);
}
// To delete the value from Tables
else if(result == '1')
{
var DelRows = $('#txtDeletedRow').val();
tr.parentNode.removeChild(tr);
if(DelRows != '')
{
DelRows = DelRows + ":" + rowid;
}
else
{
DelRows= "0" + ":" + rowid;
}
$('#txtDeletedRow').val(DelRows);
$.ajax({
data:{id:id},
type:"POST",
url:"<?php echo base_url() ?>storerequisitionlist/DeleteRequistionForm",
success:function(data) {
if(data)
{
$('#content').loader('hide');
alert(data);
}
else
{
alert("Error");
}
}});
}
}
}
// this function used to remove the item from listing table
function RemoveList(rowid)
{
var id = [];
var tr= document.getElementById(rowid);
var cellval = tr.cells;
var MaterialCode = cellval[1].innerHTML;
// alert(cellval[1].innerHTML);
id[0] = $('#txtReqNo').val();
id[1] = MaterialCode;
var answer = confirm(" Do you want to delete the Item from the List?")
if (answer)
{
// To delete the item from list
var x = <?php echo json_encode($LineItem, JSON_PRETTY_PRINT) ?>;
var result = '0';
//alert(x);
//alert(MaterialCode);
if(MaterialCode != "0")
{
$.each(x, function(idx, obj) {
if(obj.MaterialCode === MaterialCode)
{
result = '1';
return false;
}
});
}
if(result == '0')
{
var DelRows = $('#txtDeletedRow').val();
tr.parentNode.removeChild(tr);
if(DelRows != '')
{
DelRows = DelRows + ":" + rowid;
}
else
{
DelRows= "0" + ":" + rowid;
}
$('#txtDeletedRow').val(DelRows);
}
// To delete the value from Tables
else if(result == '1')
{
$('#content').loader('show');
var DelRows = $('#txtDeletedRow').val();
tr.parentNode.removeChild(tr);
if(DelRows != '')
{
DelRows = DelRows + ":" + rowid;
}
else
{
DelRows= "0" + ":" + rowid;
}
$('#txtDeletedRow').val(DelRows);
$.ajax({
data:{id:id},
type:"POST",
url:"<?php echo base_url() ?>storerequisitionlist/DeleteRequistionForm",
success:function(data) {
if(data)
{
$('#content').loader('hide');
alert(data);
}
else
{
alert("Error");
}
}});
}
}
}
function validateBeforeAdd()
{
if ($("#CostCenter option:selected").val() =='-1' )
{
alert('Please Select the CostCenterCode ');
$("#CostCenter").focus();
return false;
}
else if( isExceed == '1')
{
alert('You dont have available Budget Amount. You cant raise new StoreRequisition');
return false;
}
else
{
$('#mypo').modal('show');
}
}
function Redirect()
{
window.location = "storerequisition";
}
function Save(status)
{
//alert($(json.stringify(MaterialCode).val());
var txtRowCount= $('#txtRowCount').val();
//var mat = $('#MaterialCode'+txtRowCount).val();
if(status == '0')
{
stat = '<?php echo STORE_DRAFT; ?>';
}
else
{
stat = '<?php echo STORE_PENDINGAPPROVAL; ?>';
}
$('#txtStatus').val(stat);
var id=$('#txtStatus').val();
var RequestedBy=$('#RequestedBy').val();
var CostCenter=$('#CostCenter').val();
var splitDepCode= $('#DepartmentName').val();
DEPCode = splitDepCode.split('-')[0];
if (validate())
{
if(document.getElementById('mytable').rows.length < 0)
{
alert('Please Select Line item to Store Requisition');
$('#Deliverydt').focus();
return false;
}
else
{
console.log($('.requistion').serialize());
$('#content').loader('show');
$.ajax({
data:$('.requistion').serialize(),
type:"POST",
url:"<?php echo base_url() ?>storerequisitionlist/UpdateStoreRequistion",
success:function(data) {
if(data)
{
$('#content').loader('hide');
alert(data);
$('#txtRowCount').val('');
$('#txtDeletedRow').val('');
window.location = "storerequisition";
}
else
{
alert("Error");
}
}
});
}
}
}
function validate()
{
if($("option:selected", $("#CostCenter")).val() == '-1')
{
alert('Please Select CostCenter');
return false;
}
else if($("option:selected", $("#MaterialCode")).val() == '-1')
{
alert('Please Select MaterialCode');
return false;
}
else if(document.getElementById('mytable').rows.length < 1)
{
alert('Please Add Line Item');
return false;
}
else if(isExceed == 1)
{
alert('You dont have Budget and You cant Raise New StoreRequisition');
return false;
}
else
{
return true;
}
}
</script>
<script>
$(function () {
$('#Items').DataTable({
"paging": false,
"lengthChange": true,
"searching": false,
"ordering": false,
"info": false,
"autoWidth": true
});
});
</script>