siddharth_application/application/views/approvalstorerequisitionslip.php
2018-05-22 14:58:28 +05:30

406 lines
11 KiB
PHP
Executable File

<?php
//print_r($AppList);
?>
<div class="content-wrapper">
<section class="content">
<div class="box">
<div class="box-header">
<center><h3 class="box-title">Siddharth Industries - Store Requisition Approval List</h3></center>
</div>
<?php
$attributes = array('class' => 'form-label-left Approve ','name' => 'Approve','id' => 'Approve');
echo form_open($this->config->base_url().'storerequisitionlist/SearchRequistLists',$attributes); ?>
<div class="container-fluid">
<!-- popup for view store requisition detail -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal -->
<form>
<div class="modal-content">
<div class="modal-header" style="background-color: #3c8dbc;color:#fff;">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<center><h4> Store Requisition Details - <span id="StReqno"></span></h4></center>
</div>
<div align="left">
<div class="col-md-12">
<!--<div class="col-md-4">
<label>Requistion Type</label>
<div class="form-group">
<?php
$data = array('name' => 'ReqType','value' => set_value('ReqType'),'id'=>'ReqType', 'class' => 'form-control' ,'readonly' => 'true');
echo form_input($data);
?>
</div>
</div> -->
<div class="col-md-6">
<label>Requested By</label>
<div class="form-group">
<?php
$data = array('name' => 'Requestedby','value' => set_value('Requestedby'),'id'=>'Requestedby', 'class' => 'form-control' ,'readonly' => 'true');
echo form_input($data);
?>
</div>
</div>
<div class="col-md-6">
<label>Department Name</label>
<div class="form-group">
<?php
$data = array('name' => 'Desigination','value' => set_value('Desigination'),'id'=>'Desigination', 'class' => 'form-control' ,'readonly' => 'true');
echo form_input($data);
?>
</div>
</div>
</div>
<div class="col-md-12">
<div class="col-md-6">
<label>Requested Date</label>
<div class="form-group">
<?php
$data = array('name' => 'ReqDate','value' => set_value('ReqDate'),'id'=>'ReqDate', 'class' => 'form-control' ,'readonly' => 'true');
echo form_input($data);
?>
</div>
</div>
<div class="col-md-6">
<label>Cost Center Name</label>
<div class="form-group">
<?php
$data = array('name' => 'CostCenter','value' => set_value('CostCenter'),'id'=>'CostCenter', 'class' => 'form-control' ,'readonly' => 'true');
echo form_input($data);
?>
</div>
</div>
<!-- <div class="col-md-4">
<label>Avl Budget Amt</label>&nbsp;<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>
<table id="Items" class="table table-bordered table-hover" style="background-color:#fff;font-size:12px;">
<div align="right" style="padding-right:10px">
<div class="modal fade" role="dialog">
<thead style="background-color:#ddf">
<tr>
<th>SNo</th>
<th>Item Code</th>
<th>Item Description</th>
<th>UOM</th>
<th>Requested Quantity</th>
<th>Issued Quantity</th>
<th>Status</th>
<th>Remarks</th>
</tr>
</thead>
<tbody id="tbleAppend">
</tbody>
</div>
</div>
</table>
<div class="modal-footer"> <div class="col-md-12">
<a class="btn btn-info" data-dismiss="modal" value="Cancel">Ok</a>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
<table id="Requisition" class="table table-bordered table-hover editabletable" style="background-color:#fff;font-size:12px;">
<div align="right" style="padding-right:10px">
<div id="content" > </div>
<div class="modal fade" role="dialog">
<thead style="background-color:#ddf">
<tr>
<th>Store Requisition Number</th>
<th>Requested By</th>
<th>Requested Date</th>
<th>Status</th>
<th>Action</th>
<th>comments</th>
</tr>
</thead>
<tbody id="ApprovalList">
<?php
if(!empty($AppList))
{
//print_r($AppList);
$index = 0;
foreach($AppList as $record)
{
$index = $index +1;
?>
<tr id="<?php echo $index ?>" >
<td><a data-toggle="modal" data-target="#myModal" data-id="<%=index%>" data-userid="<?php echo $record->StoreReqNo ?>" ><u><?php echo $record->StoreReqNo ?></u></a></td>
<td><?php echo $record->FirstName?></td>
<td ><?php $Cdt = new DateTime($record->ReqDate);
$ReqDate= $Cdt->format('d-m-Y');
echo $ReqDate;
?></td>
<td><?php echo $record->StatusName ?></td>
<?php if (($record->Status) == STORE_PENDINGAPPROVAL)
{
?>
<!-- <td contenteditable="true"><input type="text" id="Remarks<?php echo $index ?>" name="Remarks<?php echo $index ?>"class="form-control" maxlength="100"></td> -->
<!-- <td data-name="sel" id="Action<?php echo $index ?>" onchange="saveToDatabase(this.options[this.selectedIndex].value,'question','<?php echo $record->StoreReqNo ; ?>','<?php echo $index ; ?>')">
<select name="status<?php echo $index ?>" id="status<?php echo $index ?>">
<option value="-1">Select Action</option>
<option value="1">Approve</option>
<option value="2">Reject</option>
</select>
</td> -->
<td> <select name="selectId" id="selectId" title="Select Your Option" onchange="saveToDatabase('<?php echo $record->StoreReqNo ?>','<?php echo $index ; ?>',this.options[this.selectedIndex].value,'<?php echo $record->Comments ?>');">
<option value="-1" >Select Option</option>
<option value="1">Approve</option>
<option value="2">Reject</option>
</select></td>
<?php
}
else
{
?>
<td><?php echo "---";//$record->Comments ?></td>
<!-- <td><?php echo $record->StatusName ?></td> -->
<?php
}
?>
<td contenteditable="true" id="newcomments<?php echo $index ; ?>" ><?php echo $record->Comments ?></td>
</tr>
<?php
}
}
?>
</tbody>
</table>
<br>
</div>
</div>
</section>
</div>
<script>
var startDate = '';
var endDate = '';
function Reset()
{
$('#RequisitionStatus').val("-1");
$('#SearchDate').val('');
}
$("#myModal").on("shown.bs.modal", function(e) {
var ReqId = $(e.relatedTarget).data('userid');
$("#StReqno").html(ReqId);
$('#ReqNO').val(ReqId);
$("#CostCenter").val('');
$("#tbleAppend").empty();
$("#ReqDate").val('');
$("#Desigination").val('');
$('#content').loader('show');
$.ajax({
data:{id:ReqId},
type:"POST",
dataType: 'json',
url:"<?php echo base_url() ?>storerequisitionlist/ViewRequest",
success:function(json) {
//success:function(data) {
$('#content').loader('hide');
//alert(json.Requist);
if(json.Requist != '')
{
//alert(json.Requist[0]['Requestedby']) ;
$("#Requestedby").val(json.Requist[0]['FirstName']);
$("#ReqDate").val(json.Requist[0]['ReqDate']);
$("#Desigination").val(json.Requist[0]['DepartmentName']);
$("#CostCenter").val(json.Requist[0]['CostCenterName']);
$("#tbleAppend").append(json.Items);
}
}
});
});
function saveToDatabase(ReqId,Index,option,com)
{
var newcomments=document.getElementById('newcomments'+Index+'').innerHTML;
var id=ReqId;
var Status= '';
if (option == -1 )
{
alert("Please Select Approve/Reject option");
return false;
}
else if (option == 1 )
{
// alert(' The Approval ');
Status='<?php echo STORE_APPROVAL;?>';
var strMsg='Do You want to Approve this requisition?';
}
else
{
Status='<?php echo STORE_REJECT;?>';
var strMsg='Do You want to Reject this requisition?';
}
var answer = confirm(strMsg);
if (answer)
{
$('#content').loader('show');
$.ajax({
data:{id:id,newcomments:newcomments},
type:"POST",
url:"<?php echo base_url() ?>storerequisitionlist/ApproveRequest?Status="+Status,
success:function(data) {
if(data)
{
$('#content').loader('hide');
alert(data);
location.reload();
}
else
{
alert("Error");
}
}
});
}
else
{
return;
}
}
$(function() {
var d = new Date();
var month = d.getMonth();
var day = d.getDate();
var year = d.getFullYear() ;
var SIAStartYear = year - 2015;
var mindt = year-70;
var maxdt = year-15;
$( ".datePicker" ).datepicker(
{
minDate : new Date(year-SIAStartYear,1,1),
maxDate :'now',
dateFormat: 'mm/dd/yy',changeMonth: true, changeYear: true,
}
);
//$('#SearchDate').daterangepicker( );
//Initialize Select2 Elements
$(".select2").select2();
//$('#SearchDate').val('');
$('#SearchDate').daterangepicker(
{
locale: {
format: 'DD-MM-YYYY'
},
showDropdowns: true
},
function(start, end, label) {
startDate = start.format('DD-MM-YYYY');
endDate = end.format('DD-MM-YYYY');
$('#FromDate').val(startDate);
$('#ToDate').val(endDate);
//alert("A new date range was chosen: " + start.format('DD-MM-YYYY') + ' to ' + end.format('DD-MM-YYYY'));
});
});
$(function () {
$('#Items').DataTable({
"paging": false,
"lengthChange": true,
"searching": false,
"ordering": false,
"info": false,
"autoWidth": false
});
$('#Requisition').DataTable({
"paging": true,
"lengthChange": true,
"searching": true,
"ordering": true,
"columnDefs" : [{"targets":2, "type":"date-eu"}],
"info": true,
"autoWidth": true
});
});
</script>
<script src="https://cdn.datatables.net/plug-ins/1.10.11/sorting/date-eu.js"></script>