siddharth_application/application/views/issueStoreRequistion.php
venbatechnologies@gmail.com d131c105c3 store redirect
2017-08-03 14:33:50 +05:30

476 lines
12 KiB
PHP
Executable File

<?php
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
$CurrentDate = $dt->format('d-m-y');
// print_r($cost);die();
$CostCenterCode='';
$CostCenterName='';
$StoreReqNo='';
$ReqDate='';
$DepartmentName='';
$DEPCode = '';
$RowCount = 0;
$ReqBy = '';
if(!empty($ReqListDetails))
{
foreach ($ReqListDetails as $Req ) {
$CostCenterCode = $Req->CostCenterCode;
$CostCenterName=$Req->CostCenterName;
$StoreReqNo=$Req->StoreReqNo;
$dt = new DateTime($Req->ReqDate);
$ReqDate = $dt->format('d-m-y');
$DEPCode = $Req->DEPCode;
$DepartmentName=$Req->DepartmentName;
$ReqBy = $Req->FirstName;
}
}
?>
<script>
$(function() {
//Initialize Select2 Elements
$("#MaterialCode").select2();
$("#Date").datepicker({
// minDate : 'now',
maxDate : 'now',
dateFormat: 'mm/dd/yy',changeMonth: true, changeYear: true,yearRange: '-100:+0'
});
});
</script>
<style type="text/css">
.num{
text-align:right;
}
.select2
{
width: 100% ! important;
}
.dataTables_wrapper {
padding-bottom: 0px ! important;
}
span.highlight {
background-color: yellow;
}
</style>
<div class="content-wrapper" style="min-height: 500px ! important;">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
<center>Siddharth Industries - Store Requisition - <?php echo $StoreReqNo; ?></center>
</h1>
</section>
<section class="content">
<div class="row" style="padding:2% 5%">
<?php
$attributes = array('class' => 'form-label-left requistion ','name' => 'requistion','id' => 'requistion');
echo form_open($this->config->base_url().'storerequisitionlist/UpdateIssueRequistion',$attributes);
?>
<!-- <form method="post" role="form" > -->
<div class="row">
<div class="col-md-12">
<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',$ReqBy), 'id'=>'RequestedBy','class' => 'form-control' ,'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 . " - ".$DepartmentName), 'id'=>'DepartmentName','class' => 'form-control ' ,'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',$ReqDate), 'id' =>"Date", 'class' => 'form-control num' ,'readonly' => 'true');
echo form_input($data);
?>
</div>
<div class="col-md-3">
<label>Cost Center</label>
<?php
$data = array('name' => 'CostCenter','value' => set_value('CostCenter',$CostCenterCode . " - ".$CostCenterName),'id'=>"CostCenter", 'class' => 'form-control','readonly' => 'true' );
echo form_input($data);
?>
</div>
</div>
</div>
<br>
<div class="row ">
<div class=" box ">
<div class=" container-fluid">
<div class="box-header">
<CENTER><h3 class="box-title"> </h3></CENTER>
<span class="highlight">Available Stock Shown In Red Are Out Of Stock</span>
</div>
<table id="Items" 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>Requested Quantity</th>
<th>Available Stock</th>
<th>Requester Remarks</th>
<th>Issued Quantity</th>
<th>Comments</th>
</thead>
<tbody id='mytab'>
<?php
if(!empty($ReqItem))
{ //alert();
$index = 0;
foreach($ReqItem as $record)
{
//print_r($record);
$index = $index + 1;
?>
<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="right"><?php echo $record->QuantityRequired ?></td>
<?php if(($record->Quantity)-($record->QuantityRequired)<=0)
{?>
<td align="right" style="color: red" ><?php echo $record->Quantity?></td>
<?
}?>
<?php if(($record->Quantity)-($record->QuantityRequired)>0)
{?>
<td align="right"><?php echo $record->Quantity?></td>
<?
}?>
<td align="left"><?php echo $record->Remarks ?></td>
<td align="left">
<?php if(($record->Quantity)-($record->QuantityRequired)>0)
{?>
<input type="text" onchange="SaveIssueQuantity(<?php echo $index ?>,<?php echo $record->QuantityRequired ?>)" id="<?php echo 'issuedQuantity'.$index ?>" name="<?php echo 'issuedQuantity'.$index ?>" class="form required" onkeypress="return isNumberKey(event);"value="<?php echo $record->QuantityIssued; ?>"> <?}?>
</td>
<td align="left">
<?php if(($record->Quantity)-($record->QuantityRequired)>0)
{?>
<input type="text" onchange="SaveRemarks(<?php echo $index ?>)" id="<?php echo 'Comments'.$index ?>" name="<?php echo 'Comments'.$index ?>" class="form required" value="<?php echo $record->StoreComments; ?>" ><?}?>
</td>
</tr>
<?php $RowCount = $index; }
?>
<?php
}?>
</tbody>
</table>
</div>
</div>
</div>
<div class="col-md-3 col-md-offset-9" align = "right">
<input type="hidden" name="txtRowCount" id="txtRowCount" value="<?php echo $RowCount;?>" />
<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> -->
<!-- <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="Submit" class="btn btn-info" />-->
<input type="submit" class="btn btn-primary Submit" value="Update"/ >
<!-- <input type="reset" class="btn btn-primary" value="Cancel" href="<?php echo base_url(); ?>storerequisitionlisting" /> -->
<a class="btn btn-primary" href="<?php echo base_url(); ?>storerequisitionlisting">Cancel</a>
</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><%=Remarks%></td>
<td align="left"></td> <!-- Issued Quantity -->
<td></td> <!-- Comments -->
</tr>
</script>
<!--copy script-->
<script>
var j =0;
var isExceed = 0;
$(function() {
var ReqLineItem = <?php echo json_encode($ReqItem, 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: 'txtIssuedQuantity' + j,
name: 'txtIssuedQuantity'+ j,
}).appendTo('form');
$('<input>').attr({
type: 'hidden',
id: 'txtRemarks' + j,
name: 'txtRemarks'+ j,
}).appendTo('form');
});
});
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : evt.keyCode;
if (charCode != 46 && charCode > 31
&& (charCode < 48 || charCode > 57))
return false;
return true;
}
var index = '1';
var userid = '';
function SaveIssueQuantity(RowId,ReqQty)
{
//alert(ReqQty);
var qty = $("#issuedQuantity"+RowId).val();
//alert(qty);
if( qty != '')
{
if(qty <= ReqQty )
{
$("#txtIssuedQuantity"+RowId).val(qty);
}
else
{
alert('The Issued Quantity cannot be more than the Requested Quantity');
$("#issuedQuantity"+RowId).focus();
$("#issuedQuantity"+RowId).val('');
return false;
}
}
}
function SaveRemarks(RowId)
{
var remks = $("#Comments"+RowId).val();
if( remks != '')
{
$("#txtRemarks"+RowId).val(remks);
}
}
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/EditStoreRequisitions?ID="+id+"&RequestedBy="+RequestedBy+"&CostCenter="+CostCenter+"&DEPCode="+DEPCode+"&txtRowCount="+txtRowCount,
success:function(data) {
if(data)
{
$('#content').loader('hide');
alert(data);
$('#txtRowCount').val('');
$('#txtDeletedRow').val('');
//window.location = "storerequisitionlist";
}
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;
}
}
function Redirect()
{
window.location = "storerequisition";
}
</script>
<script>
$(function () {
$('#Items').DataTable({
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"info": true,
"autoWidth": true
});
});
</script>