1155 lines
32 KiB
PHP
Executable File
1155 lines
32 KiB
PHP
Executable File
|
|
<?php
|
|
$ReqNo = '';
|
|
$ReqType = '';
|
|
$Requestedby = '';
|
|
$FirstName ='';
|
|
$Designation ='';
|
|
$DepartmentName = '';
|
|
$Status = '';
|
|
$CostCenterCode = '';
|
|
$RowCount = '';
|
|
$serviceSchedule='';
|
|
$servicePeriod='';
|
|
$noOfService='';
|
|
$strReqPOType = '';
|
|
if(!empty($ReqDetails))
|
|
{
|
|
|
|
foreach ($ReqDetails as $Req)
|
|
{
|
|
$ReqNo = $Req->ReqNo;
|
|
$ReqType = $Req->ReqType;
|
|
$Requestedby = $Req->Requestedby;
|
|
$FirstName =$Req->FirstName;
|
|
$Designation =$Req->Designation;
|
|
$DepartmentName = $Req->DepartmentName;
|
|
$Status = $Req->Status;
|
|
$CostCenterCode = $Req->CostCenterCode;
|
|
$serviceSchedule=$Req->Schedule_Type;
|
|
|
|
$servicePeriod=$Req->Service_Period;
|
|
$noOfService=$Req->NumberOfService;
|
|
|
|
}
|
|
}
|
|
|
|
//echo $ReqType;
|
|
|
|
|
|
$description='';
|
|
|
|
|
|
|
|
if(!empty($ReqPOType))
|
|
{
|
|
|
|
$strReqPOType = $ReqPOType;
|
|
}
|
|
|
|
?>
|
|
|
|
<script type="text/javascript">
|
|
window.onload = function()
|
|
{
|
|
var serviceScheduleType = '<?php echo $serviceSchedule; ?>';
|
|
if(serviceScheduleType != '')
|
|
{
|
|
if(serviceScheduleType!='Recurring'){
|
|
document.getElementById('DisplayScheduleDiv').style.display = 'block';
|
|
document.getElementById('ServicePeriodOption').style.display = 'none';
|
|
document.getElementById('NoServices').style.display = 'none';
|
|
|
|
}
|
|
else{
|
|
document.getElementById('DisplayScheduleDiv').style.display = 'block';
|
|
document.getElementById('ServicePeriodOption').style.display = 'none';
|
|
document.getElementById('NoServices').style.display = 'none';
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
document.getElementById('DisplayScheduleDiv').style.display = 'none';
|
|
document.getElementById('ServicePeriodOption').style.display = 'none';
|
|
document.getElementById('NoServices').style.display = 'none';
|
|
|
|
}
|
|
}
|
|
</script>
|
|
<div class="content-wrapper">
|
|
|
|
|
|
<section class="content">
|
|
|
|
<div>
|
|
<center><b><h2>Siddharth Industries - Edit Requisition Form</h2></b></center>
|
|
<div class="container-fluid">
|
|
<div id="content"></div>
|
|
|
|
<?php
|
|
$attributes = array('class' => 'form-label-left requistion ','name' => 'requistion','id' => 'requistion');
|
|
|
|
echo form_open($this->config->base_url().'requisitionform/EditRequistion',$attributes); ?>
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<div class="row" align="right">
|
|
<a class="btn btn-primary" href="<?php echo base_url(); ?>Requisition" ID="cancel"> <span class="bold">Back</span></a>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<label>Request Type</label>
|
|
<div class="form-group">
|
|
|
|
<?php
|
|
$data = array('name' => 'RequestType','value' => set_value('RequestType',$ReqType),'id'=>'RequestType', 'class' => 'form-control' ,'readonly' => 'true');
|
|
echo form_input($data);
|
|
|
|
?>
|
|
|
|
<input type="hidden" name="txtReqNo" id="txtReqNo" value="<?php echo $ReqNo?>"/>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<label>Requested By</label>
|
|
<div class="form-group">
|
|
|
|
<?php
|
|
$data = array('name' => 'EmpID','value' => set_value('EmpID',$FirstName),'id'=>'EmpID', 'class' => 'form-control' ,'readonly' => 'true');
|
|
echo form_input($data);
|
|
|
|
?>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<label>Department Name</label>
|
|
<div class="form-group">
|
|
<?php
|
|
$data = array('name' => 'DeptName','value' => set_value('DeptName',$DepartmentName),'id'=>'DeptName', 'class' => 'form-control' ,'readonly' => 'true');
|
|
echo form_input($data);
|
|
?>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3">
|
|
<label>Designation</label>
|
|
<div class="form-group">
|
|
<?php
|
|
$data = array('name' => 'Designation','value' => set_value('Designation',$Designation),'id'=>'Designation', 'class' => 'form-control' ,'readonly' => 'true');
|
|
echo form_input($data);
|
|
?>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-12">
|
|
|
|
<div class="col-md-3">
|
|
<label>Cost Center Name</label>
|
|
|
|
<div class="form-group">
|
|
<?php
|
|
$Costs = array($CostCenterCode=>$CostCenterCode);
|
|
//print_r( $options);
|
|
|
|
if(!empty($CostCenter))
|
|
{
|
|
foreach ($CostCenter 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"');
|
|
|
|
?>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="col-md-3">
|
|
<label>Available Budget Amount</label> <img id="AlertImg" src="<?php echo base_url(); ?>assets/dist/img/red.png" alt="your image" width="25px" style="display:none"/>
|
|
<div class="form-group">
|
|
<?php
|
|
$data = array('name' => 'AvlBudgetAmount','value' => set_value('AvlBudgetAmount'),'id'=>'AvlBudgetAmount', 'class' => 'form-control' ,'readonly' => 'true');
|
|
echo form_input($data);
|
|
?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
<div class="col-md-3" id="DisplayScheduleDiv" style="display:none;">
|
|
<label>Select Service Schedule Type</label>
|
|
<div class="form-group">
|
|
<?php
|
|
$Schdule =array("One Time", "Recurring");
|
|
|
|
|
|
if(!empty($Schdule))
|
|
|
|
{
|
|
|
|
foreach ($Schdule as $seletedSch):
|
|
if($serviceSchedule==$seletedSch){
|
|
$SchType[$seletedSch] = $seletedSch ;
|
|
}
|
|
endforeach;
|
|
foreach ($Schdule as $Sch):
|
|
if($serviceSchedule!=$Sch){
|
|
$SchType[$Sch] = $Sch ;
|
|
}
|
|
endforeach;
|
|
|
|
}
|
|
echo form_dropdown('ScheduleType', $SchType,set_value('ScheduleType'),'id="ScheduleType"' ,'class = "form-control"');
|
|
|
|
?>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3" id="ServicePeriodOption" style="display:none;">
|
|
<label>Select Service Period Option</label>
|
|
<div class="form-group">
|
|
<?php
|
|
|
|
|
|
|
|
if(!empty($ServiceOption))
|
|
|
|
{
|
|
foreach ($ServiceOption as $SerOptionsel):
|
|
|
|
if($servicePeriod==$SerOptionsel->ConfigValue){
|
|
|
|
$ServiceOptions[$SerOptionsel->ConfigValue] = $SerOptionsel->ConfigValue;
|
|
}
|
|
endforeach;
|
|
|
|
foreach ($ServiceOption as $SerOption):
|
|
if($servicePeriod!=$SerOption->ConfigValue){
|
|
$ServiceOptions[$SerOption->ConfigValue] = $SerOption->ConfigValue;
|
|
}
|
|
endforeach;
|
|
|
|
}
|
|
echo form_dropdown('ServiceOptions', $ServiceOptions,set_value('ServiceOptions'),'id="ServiceOptions"' ,'class = "form-control"');
|
|
|
|
?>
|
|
</div>
|
|
</div>
|
|
<div class="col-md-3" id="NoServices" style="display:none;">
|
|
<label>Number of Services</label>
|
|
<div class="form-group">
|
|
<?php
|
|
|
|
$data = array('name' => 'ServiceNo','value' => set_value('ServiceNo',$noOfService),'id'=>'ServiceNo', 'class' => 'form-control' ,'onkeypress'=>'return isNumberKey(event);');
|
|
echo form_input($data);
|
|
?>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
<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(count($MaterialCode) != 0)
|
|
{
|
|
?>
|
|
<a data-toggle="modal" data-target="#myModal1" class="btn btn-primary">Add Line Item</a>
|
|
<?php } ?>
|
|
<div class="modal fade" id="myModal1" role="dialog">
|
|
<div class="modal-dialog">
|
|
|
|
<!-- Modal content-->
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<button type="button" class="close" data-dismiss="modal">×</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($MaterialCode))
|
|
{
|
|
foreach ($MaterialCode as $MID):
|
|
|
|
|
|
$options[$MID->MaterialCode] = $MID->MaterialCode.' '.' - '.' '.$MID->MaterialName;
|
|
|
|
endforeach;
|
|
}
|
|
|
|
echo form_dropdown('drpMaterial', $options,set_value('drpMaterial'),'id="drpMaterial"' ,'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" id="otherDescription" >
|
|
<label>Other Description</label>
|
|
<div class="form-group">
|
|
<?php
|
|
$data = array('name' => 'otherD','value' => set_value('otherD'),'id'=>'otherD', 'class' => 'form-control' ,'rows' => '5', 'cols' => '70','maxlength' => '500');
|
|
echo Form_textarea($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>
|
|
|
|
<div class="modal-footer">
|
|
<a class="btn btn-info font addClick" ID="addClick" ><i class="fa fa-plus"></i> <span class="bold">Add</span></a>
|
|
<a class="btn btn-info" data-dismiss="modal" value="Cancel">cancel</a>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div><br/> <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">×</button>
|
|
<center><h4>Edit Line Item </h4></center>
|
|
</div>
|
|
<div align="left">
|
|
|
|
<div class="col-md-6">
|
|
<label>Material Code</label>
|
|
<div >
|
|
<?php
|
|
$data = array('name' => 'EditMaterialCode', 'value' => set_value('EditMaterialCode'),'id'=>'EditMaterialCode', 'class' => 'form-control','readonly'=>'true');
|
|
echo form_input($data);
|
|
?>
|
|
</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" id="EditotherDescription">
|
|
<label>Other Description</label>
|
|
<div class="form-group">
|
|
<?php
|
|
// $data = array('name' => 'EditotherD','value' => set_value('EditotherD'),'id'=>'EditotherD', 'class' => 'form-control','readonly'=>'true' );
|
|
// echo form_input($data);
|
|
|
|
$data = array('name' => 'EditotherD','value' => set_value('EditotherD'),'id'=>'EditotherD', 'class' => 'form-control' ,'rows' => '5', 'cols' => '70','maxlength' => '500');
|
|
echo Form_textarea($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>
|
|
|
|
<div class="modal-footer">
|
|
<a class="btn btn-info font EditClick" ID="EditClick" ><i class="fa fa-plus"></i> <span class="bold">Edit</span></a>
|
|
<a class="btn btn-info" data-dismiss="modal" value="Cancel">Cancel</a>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div></br>
|
|
|
|
<table id="Items" class="table table-bordered table-hover" style="background-color:#fff;font-size:12px;">
|
|
<thead style="background-color:#ddf">
|
|
<tr>
|
|
<th>SNo</th>
|
|
<th>Material Code</th>
|
|
<th>Material Name</th>
|
|
<th>Uom</th>
|
|
|
|
<th>RequestedQuantity</th>
|
|
<th>PoQuantity</th>
|
|
<th>Status</th>
|
|
<th>Action</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="tempAppend">
|
|
<?php
|
|
if(!empty($LineItem))
|
|
{
|
|
$index = 0;
|
|
foreach($LineItem as $record)
|
|
{
|
|
$index = $index + 1;
|
|
$materialdesc=$record->MaterialDescription;
|
|
//echo $materialdesc;
|
|
?>
|
|
<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->Quantity ; ?>" />
|
|
|
|
<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->Quantity ; ?></td>
|
|
<td align="left"><?php echo $record->POQTY ; ?></td>
|
|
<td align="left"><?php echo $record->StatusName ;?></td>
|
|
<input type="hidden" name="<?php echo 'materialdesc'.$index ?>" id="<?php echo 'materialdesc'.$index ?>" value="<?php echo $record->MaterialDescription ; ?>" />
|
|
<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> </a> <a onclick = "DeleteRow(<?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>
|
|
|
|
|
|
</tr>
|
|
<?php $RowCount = $index; }
|
|
?>
|
|
|
|
<?php
|
|
}?>
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
<div align="right" style="padding-right:10px">
|
|
<input type="hidden" name="txtStatus" id="txtStatus" />
|
|
<input type="hidden" name="txtDeletedRow" id="txtDeletedRow" />
|
|
<input type="hidden" name="txtRowCount" id="txtRowCount" value="<?php echo $RowCount ; ?>"/>
|
|
<?php if($Status == REQ_DRAFT)
|
|
{ ?>
|
|
<a class="btn btn-primary Save" ID="Save" onclick="Save(0)" > <span class="bold">Save</span></a>
|
|
<a class="btn btn-primary submit" ID="submit" onclick="Save(1)" > <span class="bold">Submit</span></a>
|
|
|
|
<input type="reset" class="btn btn-primary">
|
|
<?php }
|
|
else if($Status == REQ_PENDING_APPROVAL)
|
|
{?>
|
|
<!--<a class="btn btn-primary" ID="update" onclick="update()" > <span class="bold">Update</span></a>
|
|
<a class="btn btn-primary" href="<?php echo base_url(); ?>Requisition" ID="cancel"> <span class="bold">Cancel</span></a> -->
|
|
<a class="btn btn-primary Save" ID="submit" onclick="Save(1)" > <span class="bold">Update</span></a>
|
|
<input type="reset" class="btn btn-primary">
|
|
<?php } ?>
|
|
|
|
|
|
|
|
</div>
|
|
<br>
|
|
</div>
|
|
</div>
|
|
|
|
</section>
|
|
</div>
|
|
|
|
<script>
|
|
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() {
|
|
|
|
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.Quantity
|
|
}).appendTo('form');
|
|
|
|
});
|
|
|
|
|
|
$('#otherDescription').hide();
|
|
$('#EditotherDescription').hide();
|
|
|
|
$( ".datePicker" ).datepicker({ dateFormat: 'dd/mm/yy' });
|
|
|
|
//Initialize Select2 Elements
|
|
$(".select2").select2();
|
|
|
|
var id = '<?php echo $CostCenterCode?>';
|
|
var ReqType = '<?php echo $strReqPOType?>';
|
|
|
|
var urlval = '';
|
|
|
|
urlval ="<?php echo base_url() ?>servicepurchaseorder/AvilBudgetAmount?ReqType="+ReqType;
|
|
|
|
|
|
$.ajax({
|
|
data:{id:id},
|
|
type:"POST",
|
|
url:urlval,
|
|
success:function(data) {
|
|
if(data)
|
|
{
|
|
$('#content').loader('hide');
|
|
|
|
$("#AvlBudgetAmount").val(parseFloat(data).toFixed(2));
|
|
|
|
if(parseFloat($("#AvlBudgetAmount").val()) <= 0)
|
|
{
|
|
$('#AlertImg').removeAttr("style");
|
|
}
|
|
else
|
|
{
|
|
$('#AlertImg').attr("style","display:none;");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$('#content').loader('hide');
|
|
alert("Error");
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
|
|
$('#CostCenter').change(function() {
|
|
|
|
var id = $('#CostCenter').val();
|
|
$("#AvlBudgetAmount").val('');
|
|
var ReqType = '<?php echo $strReqPOType?>';
|
|
var urlval = '';
|
|
if(ReqType == '<?php echo IMPORT?>')
|
|
{
|
|
urlval="<?php echo base_url() ?>servicepurchaseorder/GetAvailableImportBudgetAmount?ReqType="+ReqType;
|
|
}
|
|
else
|
|
{
|
|
urlval ="<?php echo base_url() ?>servicepurchaseorder/AvilBudgetAmount?ReqType="+ReqType;
|
|
}
|
|
|
|
if(id != '-1')
|
|
{
|
|
$('#content').loader('show');
|
|
$.ajax({
|
|
data:{id:id},
|
|
type:"POST",
|
|
url:urlval,
|
|
success:function(data) {
|
|
if(data)
|
|
{
|
|
$('#content').loader('hide');
|
|
$("#AvlBudgetAmount").val(parseFloat(data).toFixed(2));
|
|
|
|
if(parseFloat($("#AvlBudgetAmount").val()) <= 0)
|
|
{
|
|
$('#AlertImg').removeAttr("style");
|
|
}
|
|
else
|
|
{
|
|
$('#AlertImg').attr("style","display:none;");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
$('#content').loader('hide');
|
|
alert("Error");
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
else
|
|
{
|
|
alert('Please select the Employee details');
|
|
return false;
|
|
}
|
|
|
|
});
|
|
|
|
|
|
$('#drpMaterial').change(function() {
|
|
|
|
var id = $('#drpMaterial').val();
|
|
|
|
// var skillsSelect = document.getElementById("drpMaterial");
|
|
// var selectedText = skillsSelect.options[skillsSelect.selectedIndex].text;
|
|
|
|
var value = $("#drpMaterial option:selected").text();
|
|
answer = value.replace(/[^a-z]/gi, '');
|
|
var converttext = answer.toUpperCase();
|
|
//alert(converttext)
|
|
|
|
$("#Description").val('');
|
|
$("#UOM").val('');
|
|
if(id != '-1')
|
|
{
|
|
|
|
if((converttext != 'SERVICE'))
|
|
{
|
|
$('#content').loader('show');
|
|
|
|
$.ajax({
|
|
data:{id:id},
|
|
dataType: 'json',
|
|
type:"POST",
|
|
url:"<?php echo base_url();?>requisitionform/getMaterialDetails",
|
|
success:function(json) {
|
|
$('#content').loader('hide');
|
|
//alert(json.MatDetail);
|
|
$("#Description").val(json.MatDetail[0]['MaterialName']);
|
|
$("#UOM").val(json.MatDetail[0]['UOM']);
|
|
}
|
|
|
|
});
|
|
}
|
|
|
|
else
|
|
{
|
|
$('#otherDescription').show();
|
|
}
|
|
//$('#content').loader('hide');
|
|
}
|
|
else
|
|
{
|
|
alert('Please select the RequestType');
|
|
return false;
|
|
}
|
|
|
|
|
|
});
|
|
});
|
|
</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">0.00</td>
|
|
<td align="left">NEW</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> </a> <a href='#' onclick = "DeleteRow(<%=index%>)" class="link" data-id="<%=index%>" data-userid="<%=index%>" id="Del" ><span class="glyphicon glyphicon-trash"></span></a>
|
|
|
|
|
|
</td>
|
|
</tr>
|
|
</script>
|
|
<script>
|
|
var index = $('#txtRowCount').val();
|
|
var userid = '';
|
|
function removeHiddenRows(rowcount)
|
|
{
|
|
var step;
|
|
//alert(rowcount);
|
|
for (step = 1; step < rowcount-1; step++) {
|
|
var td = document.getElementById(step);
|
|
td.parentNode.removeChild(td);
|
|
$("#MaterialCode"+step).remove();
|
|
$("#Description"+step).remove();
|
|
$("#UOM"+step).remove();
|
|
$("#Quantity"+step).remove();
|
|
index = '1';
|
|
userid = '';
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function Save(status)
|
|
{
|
|
if(status == '0')
|
|
{
|
|
stat = '<?php echo REQ_DRAFT; ?>';
|
|
}
|
|
else
|
|
{
|
|
stat = '<?php echo REQ_PENDING_APPROVAL; ?>';
|
|
}
|
|
//alert($('#MaterialCode4').val());
|
|
|
|
if(validate())
|
|
{
|
|
if(document.getElementById('Items').rows.length < 2)
|
|
{
|
|
alert('Please Select Line item to update the Requisition');
|
|
$('#Deliverydt').focus();
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
//alert(document.getElementById('Items').rows.length);
|
|
$('#content').loader('show');
|
|
$('#txtStatus').val(stat);
|
|
|
|
var serviceSchedule='';
|
|
var servicePeriod='';
|
|
var noOfService='';
|
|
if($('#RequestType').val()=='SERVICE'){
|
|
if($('#ScheduleType').val()=='Recurring'){
|
|
serviceSchedule=$('#ScheduleType').val();
|
|
servicePeriod=$('#ServiceOptions').val();
|
|
noOfService=$('#ServiceNo').val();
|
|
}
|
|
else{
|
|
serviceSchedule=$('#ScheduleType').val();
|
|
servicePeriod='';
|
|
noOfService=0;
|
|
}
|
|
|
|
}
|
|
else{
|
|
var serviceSchedule='';
|
|
var servicePeriod='';
|
|
var noOfService='';
|
|
}
|
|
$.ajax({
|
|
data:$('.requistion').serialize()+"&serviceSchedule="+serviceSchedule+"&servicePeriod="+servicePeriod+"&noOfService="+noOfService,
|
|
type:"POST",
|
|
url:"<?php echo base_url() ?>requisitionform/EditRequistion",
|
|
success:function(data) {
|
|
if(data)
|
|
{
|
|
$('#content').loader('hide');
|
|
alert(data);
|
|
$('#txtRowCount').val('');
|
|
$('#txtDeletedRow').val('');
|
|
|
|
window.location = "Requisition";
|
|
|
|
}
|
|
else
|
|
{
|
|
alert("Error");
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
}
|
|
}
|
|
}
|
|
function validate()
|
|
{
|
|
|
|
if($("option:selected", $("#RequestType")).val() == '-1')
|
|
{
|
|
alert('Please Select ReqType Names');
|
|
return false;
|
|
}
|
|
else if($("option:selected", $("#EmpID")).val() == '-1')
|
|
{
|
|
alert('Please Select Reqby');
|
|
return false;
|
|
}
|
|
else if(index < 1)
|
|
{
|
|
alert('Please Add Line Item');
|
|
return false;
|
|
}
|
|
else
|
|
{
|
|
return true;
|
|
}
|
|
|
|
}
|
|
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() ?>requisitionform/DeleteRequistionForm",
|
|
success:function(data) {
|
|
if(data)
|
|
{
|
|
$('#content').loader('hide');
|
|
alert(data);
|
|
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
alert("Error");
|
|
}
|
|
|
|
}});
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
$('.addClick').click(function(){
|
|
|
|
if ($("#drpMaterial option:selected").val() =='-1' )
|
|
{
|
|
alert('Please Select the MaterialCode ');
|
|
}
|
|
|
|
if(document.getElementById('Quantity').value == '' )
|
|
{
|
|
alert('Please Enter the Quantity');
|
|
|
|
}
|
|
|
|
if ($("#drpMaterial option:selected").val() !='-1' && $('#Quantity').val() != '' )
|
|
{
|
|
var temp = parseInt(index) + 1;
|
|
var materialCode = $("#drpMaterial option:selected").val();
|
|
var materialName = $("#Description").val();
|
|
var uom = $("#UOM").val();
|
|
var quantity = $("#Quantity").val();
|
|
var materialdescription= $('#otherD').val();
|
|
|
|
$('#drpMaterial option[value='+materialCode+']').remove();
|
|
$('#Description').val('');
|
|
$('#UOM').val('');
|
|
$('#Quantity').val('');
|
|
$('#otherD').val('')
|
|
|
|
index = parseInt(index)+1;
|
|
|
|
|
|
var template = jQuery("#tempList").html();
|
|
|
|
if(materialdescription == '')
|
|
{
|
|
$('#tempAppend').append(_.template(template,{index:temp,MaterialCode:materialCode,MaterialName:materialName,UOM:uom,Quantity:quantity}));
|
|
}
|
|
|
|
else
|
|
{
|
|
$('#tempAppend').append(_.template(template,{index:temp,MaterialCode:materialCode,MaterialName:materialdescription,UOM:uom,Quantity:quantity}));
|
|
}
|
|
|
|
|
|
|
|
var theForm = $(".requistion");
|
|
|
|
//addHidden(theForm,"MaterialCode"+temp,materialCode);
|
|
//addHidden(theForm,"Description"+temp,materialName);
|
|
//addHidden(theForm,"UOM"+temp,uom);
|
|
//addHidden(theForm,"Quantity"+temp,quantity);
|
|
|
|
$('<input>').attr({
|
|
type: 'hidden',
|
|
id: 'MaterialCode' + temp,
|
|
name: 'MaterialCode'+ temp,
|
|
value:materialCode
|
|
}).appendTo('form');
|
|
|
|
$('<input>').attr({
|
|
type: 'hidden',
|
|
id: 'Description' + temp,
|
|
name: 'Description'+ temp,
|
|
value:materialName
|
|
}).appendTo('form');
|
|
|
|
$('<input>').attr({
|
|
type: 'hidden',
|
|
id: 'UOM' + temp,
|
|
name: 'UOM'+ temp,
|
|
value:uom
|
|
}).appendTo('form');
|
|
|
|
$('<input>').attr({
|
|
type: 'hidden',
|
|
id: 'Quantity' + temp,
|
|
name: 'Quantity'+ temp,
|
|
value:quantity
|
|
}).appendTo('form');
|
|
|
|
$('<input>').attr({
|
|
type: 'hidden',
|
|
id: 'otherD' + temp,
|
|
name: 'otherD'+ temp,
|
|
value:materialdescription
|
|
}).appendTo('form');
|
|
|
|
$('#txtRowCount').val(temp);
|
|
|
|
}
|
|
|
|
});
|
|
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);
|
|
}
|
|
$("#myModal1").on("shown.bs.modal", function(e) {
|
|
if($("option:selected", $("#RequestType")).val() == '-1')
|
|
{
|
|
alert('Please select the Request Type ');
|
|
e.close();
|
|
}
|
|
});
|
|
|
|
$("#EditItem").on("shown.bs.modal", function(e) {
|
|
userid = $(e.relatedTarget).data('userid');
|
|
//alert(userid);
|
|
var tr= document.getElementById(userid);
|
|
var cellval = tr.cells;
|
|
|
|
//var desc=cellval[2].innerHTML;
|
|
var check=cellval[2].innerHTML;
|
|
var upcheck= check.toUpperCase();
|
|
|
|
// var decs= <?php echo json_encode($materialdesc, JSON_PRETTY_PRINT) ?>;
|
|
//alert(decs)
|
|
//var desc= cellval[8].innerHTML
|
|
|
|
//alert(desc)
|
|
var decs= $('#materialdesc'+userid).val();
|
|
// alert(upcheck)
|
|
|
|
if(upcheck=='SERVICE')
|
|
{
|
|
$('#EditotherDescription').show();
|
|
$('#EditotherD').val(decs)
|
|
|
|
}
|
|
|
|
else
|
|
{
|
|
$('#EditotherDescription').hide();
|
|
$('#EditotherD').val('')
|
|
|
|
|
|
}
|
|
|
|
//alert(x[1].innerHTML);
|
|
$('#EditMaterialCode').val(cellval[1].innerHTML);
|
|
$('#EditDescription').val(cellval[2].innerHTML);
|
|
$('#EditUOM').val(cellval[3].innerHTML);
|
|
$('#EditQuantity').val(cellval[4].innerHTML);
|
|
|
|
|
|
|
|
});
|
|
|
|
$('.EditClick').click(function(){
|
|
|
|
if(document.getElementById('EditQuantity').value == '' )
|
|
{
|
|
alert('Please Enter the Quantity' );
|
|
}
|
|
|
|
if ( $('#EditQuantity').val() != '' )
|
|
{
|
|
|
|
var editMaterialCode = $("#EditMaterialCode").val();
|
|
var editDescription = $("#EditDescription").val();
|
|
var editUOM = $('#EditUOM').val();
|
|
var editQuantity = $('#EditQuantity').val();
|
|
|
|
var tr= document.getElementById(userid);
|
|
var cellval = tr.cells;
|
|
cellval[1].innerHTML = editMaterialCode;
|
|
cellval[2].innerHTML = editDescription;
|
|
cellval[3].innerHTML =editUOM;
|
|
cellval[4].innerHTML = editQuantity;
|
|
|
|
$('#MaterialCode'+userid).val(editMaterialCode);
|
|
$('#Description'+userid).val(editDescription);
|
|
$('#UOM'+userid).val(editUOM);
|
|
$('#Quantity'+userid).val(editQuantity);
|
|
|
|
|
|
}
|
|
|
|
});
|
|
$(function () {
|
|
$('#Items').DataTable({
|
|
"paging": true,
|
|
"lengthChange": true,
|
|
"searching": true,
|
|
"ordering": true,
|
|
"info": true,
|
|
"autoWidth": true
|
|
|
|
});
|
|
});
|
|
$("#ScheduleType").change(function(){
|
|
if($('#ScheduleType').val().trim()!='Recurring'){
|
|
document.getElementById('ServicePeriodOption').style.display = 'none';
|
|
document.getElementById('NoServices').style.display = 'none';
|
|
|
|
|
|
}
|
|
else{
|
|
document.getElementById('ServicePeriodOption').style.display = 'none';
|
|
document.getElementById('NoServices').style.display = 'none';
|
|
|
|
}
|
|
|
|
});
|
|
</script>
|
|
|