425 lines
14 KiB
PHP
425 lines
14 KiB
PHP
<?php $defaultDate = ''; ?>
|
||
<style>
|
||
.modal-dialog-centered {
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: center;
|
||
min-height: 100vh;
|
||
}
|
||
.modal-content-custom-width {
|
||
width: 75%; /* Adjust the width as needed */
|
||
}
|
||
|
||
.dataTables_paginate {
|
||
margin-top: -5%;
|
||
}
|
||
|
||
.dataTables_wrapper {
|
||
padding-bottom: 0px;
|
||
margin-top: -3%;
|
||
}
|
||
|
||
.content-wrapper {
|
||
min-height: 733px;
|
||
}
|
||
|
||
#REQLIST_filter {
|
||
float: inline-end;
|
||
}
|
||
|
||
#REQLIST_wrapper .row .col-sm-4 {
|
||
flex-basis: 50%;
|
||
float: inline-end;
|
||
}
|
||
|
||
#REQLIST_paginate {
|
||
flex-basis: 50%;
|
||
float: inline-end;
|
||
}
|
||
</style>
|
||
<div class="content-wrapper">
|
||
<?php $attributes = array('class' => 'form-label-left CreatePO ', 'name' => 'CreatePO', 'id' => 'CreatePO', 'method' => 'post', 'role' => 'form');
|
||
echo form_open(base_url() . 'purchaseOrder', $attributes); ?>
|
||
|
||
<section class="content">
|
||
|
||
<div class="box">
|
||
<div class="box-header">
|
||
<center>
|
||
<h3 class="box-title"> Create Purchase Order from Requistion</h3>
|
||
</center>
|
||
</div>
|
||
|
||
<div class="container-fluid">
|
||
<div id="content"></div>
|
||
<div class="row">
|
||
<div class="col-md-4">
|
||
<?php
|
||
helper('form');
|
||
$error = session()->getFlashdata('error');
|
||
if ($error) {
|
||
?>
|
||
<div class="alert alert-danger alert-dismissable">
|
||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||
<?php echo session()->getFlashdata('error'); ?>
|
||
</div>
|
||
<?php } ?>
|
||
<?php
|
||
$success = session()->getFlashdata('success');
|
||
if ($success) {
|
||
?>
|
||
<div class="alert alert-success alert-dismissable">
|
||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||
<?php echo session()->getFlashdata('success'); ?>
|
||
</div>
|
||
<?php } ?>
|
||
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
<?php // \Config\Services::validation()->listErrors('<div class="alert alert-danger alert-dismissable">', ' <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button></div>');
|
||
?> </div>
|
||
</div>
|
||
</div>
|
||
<?php
|
||
$listErrors = session()->getFlashdata('listErrors');
|
||
if ($listErrors) {
|
||
?>
|
||
<div class="row">
|
||
<div class="col-md-12">
|
||
<div class="alert alert-danger alert-dismissable">
|
||
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
|
||
<?php echo session()->getFlashdata('listErrors'); ?>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<?php } ?>
|
||
<div class="col-md-12">
|
||
<div class="col-md-3 col-md-offset-9">
|
||
<p>
|
||
<div align="right" style="padding-right:0px">
|
||
<!--<a href="<?php echo base_url(); ?>purchaseorderform/purchaseorder"> -->
|
||
<!--<button type="button" class="btn btn-success">Create PO</button></a> -->
|
||
<!--<input type="submit" class="btn btn-success" onclick="return Validate();" value="Create Purchase Order"> -->
|
||
<a class="btn btn-success" onclick="Validate();">Create Purchase Order</a>
|
||
<input type="hidden" name="txtReqNo" id="txtReqNo" />
|
||
<input type="hidden" name="txtReqType" id="txtReqType" />
|
||
</div>
|
||
</p>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="container-fluid">
|
||
|
||
<div class="modal fade" id="RequisitionDtlsModal" role="dialog">
|
||
<div class="modal-dialog" style="vertical-align: middle;width: fit-content">
|
||
<!-- Modal content-->
|
||
<form>
|
||
<div class="modal-content" style="width:800px">
|
||
<div class="modal-header">
|
||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||
<center>
|
||
<h4> Requisition Details - <label id="SelReqNo" name="SelReqNo"></label> </h4>
|
||
</center>
|
||
</div>
|
||
<div class="modal-body">
|
||
<div class="row">
|
||
<div class="col-md-4">
|
||
<label>Request 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-4">
|
||
<label>Requested By</label>
|
||
<div class="form-group">
|
||
<?php
|
||
$data = array('name' => 'ReqBy', 'value' => set_value('ReqBy'), 'id' => 'ReqBy', 'class' => 'form-control', 'readonly' => 'true');
|
||
echo form_input($data);
|
||
?>
|
||
</div>
|
||
</div>
|
||
<div class="col-md-4">
|
||
<label>Designation</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="row">
|
||
<div class="col-md-4">
|
||
<label>Requested Date</label>
|
||
<div class="form-group">
|
||
<?php
|
||
$data = array('name' => 'RequistionDate', 'value' => set_value('RequistionDate'), 'id' => 'RequistionDate', 'class' => 'form-control', 'readonly' => 'true');
|
||
echo form_input($data);
|
||
?>
|
||
</div>
|
||
</div>
|
||
<div class="col-md-4">
|
||
<label>Cost Center Code</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> <img id="AlertImg" src="<?php echo base_url(); ?>public/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>
|
||
<div class="row">
|
||
<table class="table table-bordered editableTable" style="border:1px solid #fff">
|
||
<thead style="background-color: #ddd !important;">
|
||
<tr>
|
||
<th style="white-space: nowrap;">SNo</th>
|
||
<th style="white-space: nowrap;">Item Code</th>
|
||
<th style="white-space: nowrap;">Item Description</th>
|
||
<th style="white-space: nowrap;">UOM</th>
|
||
<th style="white-space: nowrap;">Requested Quantity</th>
|
||
<th style="white-space: nowrap;">Ordered Quantity</th>
|
||
<th style="white-space: nowrap;">Status</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody id="tbleAppend"></tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<div class="col-md-12">
|
||
<a class="btn btn-info" data-dismiss="modal" value="Cancel">Ok</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div>
|
||
|
||
<table id="REQLIST" 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: #ddd !important;">
|
||
<tr>
|
||
<th>Select</th>
|
||
<th>Requested Date</th>
|
||
<th>Requistion Number</th>
|
||
<th>Requistion Type </th>
|
||
<th>Requested By</th>
|
||
<th>Tot. No. Of Line Items</th>
|
||
<th>Po Created Line Items</th>
|
||
<th>Partial PO Created Line Items</th>
|
||
<th>New Line Items</th>
|
||
<th>Status</th>
|
||
<th>Department</th>
|
||
<th>Designation</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody id="AppendReqList">
|
||
<?php
|
||
if (!empty($ReqList)) { //alert($ReqList);
|
||
$index = 1;
|
||
foreach ($ReqList as $record) {
|
||
?>
|
||
<tr id="<?php echo $index; ?>">
|
||
<td><input type="checkbox" name="chk<?php echo $index; ?>" id="chk<?php echo $index; ?>" onclick="selectReqNo(<?php echo $index; ?>)" /> </td>
|
||
<td align="right">
|
||
<?php
|
||
$dt = new DateTime($record->ReqDate);
|
||
$RequestedDate = $dt->format('d-m-Y');
|
||
echo $RequestedDate;
|
||
?>
|
||
</td>
|
||
<td><a data-toggle="modal" data-target="#RequisitionDtlsModal" data-id="<%=index%>" data-userid="<?php echo $record->ReqNo ?>"><u><?php echo $record->ReqNo; ?> </u></a></td>
|
||
<td><?php echo $record->ReqType; ?></td>
|
||
<td><?php echo $record->FirstName; ?></td>
|
||
<td align="right"><?php echo $record->TotalNoofLineItems; ?></td>
|
||
<td align="right"><?php echo $record->PolineItems; ?></td>
|
||
<td align="right"><?php echo $record->PartilallyLineItems; ?></td>
|
||
<td align="right"><?php echo $record->newLineItem; ?></td>
|
||
<td><?php echo $record->StatusName; ?></td>
|
||
<td><?php echo $record->DepartmentName; ?></td>
|
||
<td><?php echo $record->Designation; ?></td>
|
||
</tr>
|
||
<?php $index = $index + 1;
|
||
}
|
||
}
|
||
?>
|
||
</tbody>
|
||
</table>
|
||
|
||
<div align="right">
|
||
<!-- <input type="submit" class="btn btn-success" onclick="return Validate();" value="Create Purchase Order"> -->
|
||
</div>
|
||
|
||
<div class="modal fade" id="ImportPOCheck" role="dialog">
|
||
<div class="modal-dialog modal-dialog-centered">
|
||
<!-- Modal content-->
|
||
<div class="modal-content modal-content-custom-width">
|
||
<div class="modal-header">
|
||
<button type="button" class="close" data-dismiss="modal">×</button>
|
||
<h4 class="modal-title">Do You want to create Import PO for this Requistion?</h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<form>
|
||
<div class="radio">
|
||
<label><input type="radio" name="optImport" value="0" id="optImport">YES</label>
|
||
</div>
|
||
<div class="radio">
|
||
<label><input type="radio" name="optImport" value="1" id="optImport" checked="checked">NO</label>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<!--<a class="btn btn-success" ID="Import" onclick="SetImportPO();" style="margin-top: -24px;">-->
|
||
<a class="btn btn-cancel" data-dismiss="modal" value="Cancel">Cancel</a>
|
||
<input type="submit" class="btn btn-success" onclick="SetImportPO();" value="OK" />
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
</div>
|
||
<script>
|
||
var POType = '';
|
||
function SetImportPO() {
|
||
POType = $("input:radio[name='optImport']:checked").val();
|
||
$('#ImportPOCheck').modal('hide');
|
||
$('#txtReqType').val(POType == 0 ? 'IMPORT' : '');
|
||
}
|
||
|
||
$('#ReqDate').val('');
|
||
var Fromdt = '';
|
||
var Todt = '';
|
||
var baseurl = "<?php print base_url(); ?>";
|
||
|
||
//Date range picker
|
||
$('#ReqDate').daterangepicker({
|
||
locale: {
|
||
format: 'YYYY/MM/DD'
|
||
}
|
||
});
|
||
|
||
var coll = [];
|
||
var RequistionList = {
|
||
Req: []
|
||
};
|
||
|
||
var Type = '';
|
||
var i = 0;
|
||
|
||
|
||
function selectReqNo(rowId) {
|
||
ckb = $('#chk' + rowId).is(':checked');
|
||
var tr = document.getElementById(rowId);
|
||
var cellval = tr.cells;
|
||
//coo/kie_value_add = {};
|
||
if (!ckb) {
|
||
var removeItem = cellval[2].innerText;
|
||
$.each(RequistionList.Req, function(i, el) {
|
||
if (this.ReqNo == removeItem) { //Type = '';
|
||
RequistionList.Req.splice(i, 1);
|
||
}
|
||
});
|
||
} else {
|
||
var tr = document.getElementById(rowId);
|
||
var cellval = tr.cells;
|
||
//alert(RequistionList.Req.length);
|
||
if (RequistionList.Req.length > 0) {
|
||
|
||
if (Type == cellval[3].innerText) {
|
||
RequistionList.Req.push({
|
||
"ReqNo": cellval[2].innerText,
|
||
"ReqType": cellval[3].innerText,
|
||
"ReqBy": cellval[4].innerText,
|
||
});
|
||
} else {
|
||
alert('Same type of Requistion only can be together.')
|
||
$('#chk' + rowId).attr('checked', false);
|
||
}
|
||
|
||
} else {
|
||
|
||
RequistionList.Req.push({
|
||
"ReqNo": cellval[2].innerText,
|
||
"ReqType": cellval[3].innerText,
|
||
"ReqBy": cellval[4].innerText,
|
||
});
|
||
Type = cellval[3].innerText;
|
||
|
||
}
|
||
i = i + 1;
|
||
}
|
||
$('#txtReqNo').val(JSON.stringify(RequistionList));
|
||
}
|
||
|
||
$("#RequisitionDtlsModal").on("shown.bs.modal", function(e) {
|
||
var ReqId = $(e.relatedTarget).data('userid');
|
||
$('#SelReqNo').html(ReqId);
|
||
$('#content').loader('show');
|
||
$.ajax({
|
||
data: { id: ReqId },
|
||
type: "POST",
|
||
dataType: 'json',
|
||
url: "<?php echo base_url() ?>requisitionform/ViewRequest",
|
||
success: function(json) {
|
||
$('#content').loader('hide');
|
||
var getAvalAmt = json.AvilBudAmount;
|
||
getAvalAmt = getAvalAmt.replace(/\,/g, '');
|
||
$("#ReqType").val(json.Requist[0]['ReqType']);
|
||
$("#ReqBy").val(json.Requist[0]['FirstName']);
|
||
$("#RequistionDate").val(json.Requist[0]['ReqDate']);
|
||
$("#Desigination").val(json.Requist[0]['Designation']);
|
||
$("#CostCenter").val(json.Requist[0]['CostCenterCode']);
|
||
$("#AvlBudgetAmount").val(parseFloat(getAvalAmt).toFixed(2));
|
||
$("#tbleAppend").empty();
|
||
$("#tbleAppend").append(json.Items);
|
||
}
|
||
});
|
||
});
|
||
|
||
function Validate() {
|
||
var ReqNo = $('#txtReqNo').val();
|
||
if (ReqNo.length <= 0) {
|
||
alert('Please select the Requisition Number to Create Purchase Order');
|
||
return false;
|
||
} else {
|
||
$('#ImportPOCheck').modal('show');
|
||
}
|
||
}
|
||
|
||
$(function() {
|
||
$('#REQLIST').DataTable({
|
||
"paging": true,
|
||
"lengthChange": true,
|
||
"searching": true,
|
||
"columnDefs": [{
|
||
"targets": 1,
|
||
"type": "date-eu"
|
||
}],
|
||
"aaSorting": [
|
||
[2, "desc"]
|
||
],
|
||
"ordering": true,
|
||
"info": true,
|
||
"autoWidth": true,
|
||
"pageLength": 10,
|
||
"lengthMenu": [10, 25, 50, 100]
|
||
});
|
||
});
|
||
</script>
|
||
<script src="https://cdn.datatables.net/plug-ins/1.10.11/sorting/date-eu.js"></script>
|