528 lines
14 KiB
PHP
Executable File
528 lines
14 KiB
PHP
Executable File
<?php
|
|
//echo "OUTIF";
|
|
if (empty($Status)) {
|
|
//echo "INIF";
|
|
//print_r($Status);
|
|
}
|
|
?>
|
|
|
|
<style>
|
|
|
|
|
|
.dataTables_wrapper .top {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: center;
|
|
}
|
|
th,
|
|
td {
|
|
white-space: nowrap;
|
|
}
|
|
.Date-filter-form {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 10px;
|
|
/* Adjust the gap as needed */
|
|
}
|
|
|
|
.Date-filter-form input,
|
|
.Date-filter-form button {
|
|
padding: 5px;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.Date-filter-form button {
|
|
background-color: #007bff;
|
|
color: white;
|
|
border: none;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.Date-filter-form button:hover {
|
|
background-color: #0056b3;
|
|
}
|
|
|
|
.icon-button {
|
|
background: none;
|
|
border: none;
|
|
cursor: pointer;
|
|
color: #007bff;
|
|
font-size: 18px;
|
|
}
|
|
|
|
.icon-button:hover {
|
|
color: #0056b3;
|
|
}
|
|
</style>
|
|
|
|
|
|
<div class="content-page">
|
|
<div class="content">
|
|
<!-- Start Content-->
|
|
<div class="container-fluid">
|
|
<!-- start page title -->
|
|
<div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="page-title-box page-title-box-alt">
|
|
<div class="page-title-right">
|
|
<ol class="breadcrumb m-0">
|
|
<li class="breadcrumb-item"><a href="javascript: void(0);">Purchase</a></li>
|
|
<li class="breadcrumb-item"><a href="javascript: void(0);">Purchase Order</a></li>
|
|
<li class="breadcrumb-item active">
|
|
<h4 class="page-title">Approve Purchase Order </h4>
|
|
</li>
|
|
</ol>
|
|
</div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-12">
|
|
<div class="card">
|
|
<form class="Date-filter-form" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;" method="post" action="<?= base_url('PORelease'); ?>">
|
|
|
|
<label for="fromDate">From:</label>
|
|
<input class="form-control date_range form-date-search"
|
|
value="<?= $fromDate?>"
|
|
id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
|
|
|
|
<label for="toDate">To:</label>
|
|
<input class="form-control date_range to-date-search"
|
|
value="<?= $toDate ?>"
|
|
id="toDate" name="toDate" placeholder="Select To Date" autocomplete="off" required>
|
|
|
|
<button type="submit" class="range_search_button" >
|
|
<i class="fe-search" aria-hidden="true" class="icon-button" title="Search"></i>
|
|
</button>
|
|
|
|
<i class="fe-rotate-cw range_reset_button"
|
|
style="cursor:pointer;"
|
|
aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
|
|
|
|
|
|
<div class="error" id="error"></div>
|
|
</form>
|
|
<div class="card-body" style="overflow-x:scroll;">
|
|
<table id="po_release" class="table table-bordered table-hover">
|
|
<thead>
|
|
<tr>
|
|
<th>Created Date</th>
|
|
<th>PONO</th>
|
|
<th>PO Type</th>
|
|
<th>Cost Center</th>
|
|
<th>Supplier Name</th>
|
|
<th>Created By</th>
|
|
<th>Department</th>
|
|
<th>Total Order Value</th>
|
|
<th>Approved By</th>
|
|
<th>Status</th>
|
|
<?php if(session()->get('roleText') != 'Auditor'){?>
|
|
<th>Action</th>
|
|
<?php } ?>
|
|
<th>Remarks</th>
|
|
|
|
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php
|
|
if (!empty($AppList)) {
|
|
$index = 0;
|
|
foreach ($AppList as $record) {
|
|
$index = $index + 1;
|
|
//echo $index;
|
|
?>
|
|
<tr id="<?php echo $index ?>">
|
|
<td><?php $podt = new DateTime($record->CreatedDate);
|
|
$PODate = $podt->format('d-m-Y');
|
|
echo $PODate;
|
|
?></td>
|
|
<td><a style="cursor: pointer; color: #039985; text-decoration: none;" target="_blank" href="<?php echo base_url() ?>purchaseorder/CreatePOPrint?PONO=<?php echo $record->PONO ?>&ReqType=<?php echo $record->RType ?>" data-id="<%=index%>" data-userid="<?php echo $record->PONO ?>"><?php echo $record->PONO ?> </td>
|
|
<td><?php echo $record->RType ?> </td>
|
|
<td><?php echo $record->CostCenterName ?> </td>
|
|
|
|
<td >
|
|
|
|
<?php echo $record->SupplierName ?>
|
|
|
|
</td>
|
|
<td><?php echo $record->FirstName ?></td>
|
|
<td><?php echo $record->DepartmentName ?></td>
|
|
|
|
|
|
<td><?php echo $record->TotalOrderValue ?></td>
|
|
|
|
|
|
<td><?php echo $record->Approver ?></td>
|
|
<td>
|
|
<?php
|
|
$statusMappings = [
|
|
'PO APPROVED' => 'AWAITING APPROVE',
|
|
'AWAITING RELEASE' => 'AWAITING APPROVE',
|
|
'RELEASER ONHOLD' => 'APPROVER ONHOLD',
|
|
'PO RELEASED' => 'PO APPROVED',
|
|
];
|
|
|
|
if (isset($record->StatusName) && !empty($record->StatusName)) {
|
|
if (isset($statusMappings[$record->StatusName])) {
|
|
echo $statusMappings[$record->StatusName];
|
|
} else {
|
|
echo $record->StatusName;
|
|
}
|
|
} else {
|
|
echo "Status not provided";
|
|
}
|
|
|
|
|
|
|
|
?>
|
|
</td>
|
|
|
|
<?php if(session()->get('roleText') != 'Auditor'){?>
|
|
<td>
|
|
<?php if ($record->StatusCode == PO_APPROVER_ONHOLD or $record->StatusCode == PO_CREATED or $record->StatusCode == REQITEM_Emergency_PO_CREATED) { ?>
|
|
|
|
|
|
<select
|
|
class="form-control"
|
|
name="selectId" id="selectId"
|
|
onchange="showvalue('<?php echo $record->PONO ?>','<?php echo $index; ?>',this.options[this.selectedIndex].value,'<?php echo $record->Remarks ?>');"
|
|
style="width: 193px;">
|
|
<option value="-1">Select Action</option>
|
|
<!-- <option value="1">Release</option> -->
|
|
<option value="1">Approve And Release</option>
|
|
<option value="2">OnHold</option>
|
|
</select>
|
|
|
|
|
|
<?php } ?>
|
|
</td>
|
|
<?php } ?>
|
|
|
|
<td contenteditable="true" id="remarks<?php echo $index; ?>">
|
|
<?php
|
|
if ($record->Remarks == '') {
|
|
} else {
|
|
echo $record->Remarks;
|
|
} ?>
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
<?php
|
|
}
|
|
}
|
|
|
|
?>
|
|
|
|
</tbody>
|
|
</table>
|
|
</div> <!-- end card body-->
|
|
</div> <!-- end card -->
|
|
</div><!-- end col-->
|
|
</div>
|
|
</div>
|
|
</div> <!-- container -->
|
|
</div> <!-- content -->
|
|
</div>
|
|
|
|
<script>
|
|
function showvalue(PONO, value, Status, Remark) {
|
|
var Remarks = '';
|
|
var curtremarks = document.getElementById('remarks' + value + '').innerHTML;
|
|
//var curtremarks = curtremarks.trim();
|
|
var PO = PONO;
|
|
var Status = Status;
|
|
var StatusCode = '';
|
|
var srtMsg = '';
|
|
|
|
if ((curtremarks == '<br>' || curtremarks == '') && Remark == '') {
|
|
Remarks = '';
|
|
//alert("To Store both empty:-" + Remarks)
|
|
} else if ((curtremarks != '' && Remark == '')) {
|
|
Remarks = curtremarks;
|
|
//alert("To Store current empty:-" + Remarks)
|
|
} else if ((Remark != '') && (curtremarks == '' || curtremarks == '<br>')) {
|
|
Remarks = Remark;
|
|
//alert("To Store current empty:-" + Remarks)
|
|
} else {
|
|
Remarks = Remark + "||" + curtremarks;
|
|
//alert("To Store both:-" + Remarks)
|
|
}
|
|
//alert(PO+"-"+Status+"-"+StatusCode);
|
|
if (Status != '-1') {
|
|
if (Status == '1') {
|
|
// var strMsg='Do you want to Release this Purchase Order?'
|
|
var strMsg = 'Do you want to Approve and Release this Purchase Order?'
|
|
var StatusCode = 'ST026';
|
|
//alert(StatusCode);
|
|
} else if (Status == '2') {
|
|
var strMsg = 'Do you want to put Hold this Purchase Order?';
|
|
var StatusCode = 'ST052';
|
|
//alert(StatusCode);
|
|
}
|
|
|
|
/* MSG*/
|
|
var answer = confirm(strMsg);
|
|
if (answer) {
|
|
$('#loader').show();
|
|
$.ajax({
|
|
data: {
|
|
PONO: PO,
|
|
SCode: StatusCode,
|
|
NewRemarks: Remarks
|
|
},
|
|
type: "POST",
|
|
url: "<?php echo base_url() ?>purchaseorder/ReleasePO",
|
|
success: function(data) {
|
|
if (data) {
|
|
$('#loader').hide();
|
|
alert(data);
|
|
location.reload();
|
|
} else {
|
|
alert("Error");
|
|
}
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
} else {
|
|
return;
|
|
}
|
|
|
|
|
|
/* MSG*/
|
|
|
|
} else {
|
|
alert('please Select Status!');
|
|
}
|
|
|
|
|
|
} //End of showvalue function for approve/hold po status
|
|
</script>
|
|
|
|
|
|
<script>
|
|
var startDate = '';
|
|
var endDate = '';
|
|
|
|
function Reset() {
|
|
$('#RequisitionStatus').val("-1");
|
|
$('#SearchDate').val('');
|
|
}
|
|
// <!--JQuery For POP UP and Getting all relevant Data-- >
|
|
$("#myModal").on("shown.bs.modal", function(e) {
|
|
var ReqId = $(e.relatedTarget).data('userid');
|
|
$("#RequistionNo").val('');
|
|
$("#drpSupplier").val('');
|
|
$("#POType").val('');
|
|
$("#Tax Range").val(''); //not conform
|
|
$("#SupAddress").val('');
|
|
$("#DeliveryAddr").val('');
|
|
$("#PODate").val('');
|
|
$("#Deliverydt").val('');
|
|
$("#tbleAppend").empty();
|
|
$("#txtTotBasicAmount").val('');
|
|
$("#txtTotalDiscount").val('');
|
|
$("#txtTotalVat").val('');
|
|
$("#txtTotCST").val('');
|
|
$("#txtTotalPackaing").val('');
|
|
$("#txtTotExciseDuty").val('');
|
|
$("#txtTotalGST").val('');
|
|
$("#txtTotalInsurance").val('');
|
|
$("#txtTotalFreight").val('');
|
|
$("#txtTotalOtherTaxes").val('');
|
|
$("#txtTotalOrderValueSummary").val('');
|
|
$("#txtSpcialInstruction").val('');
|
|
$('#AlertImg').attr("style", "display:none;");
|
|
|
|
$('#loader').show();
|
|
$.ajax({
|
|
data: {
|
|
id: ReqId
|
|
},
|
|
type: "POST",
|
|
dataType: 'json',
|
|
url: "<?php echo base_url() ?>requisitionform/ViewRequest",
|
|
success: function(json) {
|
|
|
|
$('#loader').hide();
|
|
//alert(data);
|
|
$("#ReqType").val(json.Requist[0]['ReqType']);
|
|
$("#ReqBy").val(json.Requist[0]['Requestedby']);
|
|
$("#ReqDate").val(json.Requist[0]['CreatedDate']);
|
|
$("#Desigination").val(json.Requist[0]['Designation']);
|
|
$("#CostCenter").val(json.Requist[0]['CostCenterCode']);
|
|
$("#AvlBudgetAmount").val(json.AvilBudAmount);
|
|
|
|
$("#tbleAppend").append(json.Items);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
function printpdf(PONO, value, Status) {
|
|
|
|
|
|
var PONO = PONO;
|
|
var Status = Status;
|
|
var value = value;
|
|
alert(PONO + Status + value);
|
|
|
|
if (PONO != '' && Status != '' && value != '') {
|
|
alert('inside if ' + PONO + Status + value);
|
|
|
|
$.ajax({
|
|
data: {
|
|
PONO1: PONO,
|
|
Status1: Status
|
|
},
|
|
type: "POST",
|
|
url: "<?php echo base_url() ?>purchaseorder/Poprintpdf",
|
|
/*success:function(data) {
|
|
if(data)
|
|
{
|
|
alert(data);
|
|
}
|
|
else
|
|
{
|
|
alert("Error");
|
|
}
|
|
|
|
}*/
|
|
|
|
|
|
});
|
|
|
|
} else {
|
|
alert('inside else ' + PONO + Status + value);
|
|
}
|
|
}
|
|
|
|
|
|
$(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
|
|
|
|
});
|
|
|
|
});
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
|
|
|
|
// Initialize the DataTable
|
|
var table = $('#po_release').DataTable({
|
|
dom: 'Blfrtip', // Buttons, length menu, filter, table, information, pagination
|
|
buttons: [
|
|
'excel', 'pdf'
|
|
],
|
|
pageLength: 10, // Default rows per page
|
|
lengthMenu: [
|
|
[10, 20, 30, 50, -1],
|
|
[10, 20, 30, 50, "All"]
|
|
], // Rows per page options
|
|
responsive: false,
|
|
order: false,
|
|
|
|
language: {
|
|
paginate: {
|
|
next: '<i class="fas fa-angle-right"></i>', // Next button icon
|
|
previous: '<i class="fas fa-angle-left"></i>' // Previous button icon
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
// Reset button functionality
|
|
$("#resetButton").click(function() {
|
|
$("#fromDate").val('');
|
|
$("#toDate").val('');
|
|
window.location="PORelease"
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
$('#fromDate , #toDate').change(function() {
|
|
|
|
let fromDate = $('#fromDate').val();
|
|
let toDate = $('#toDate').val();
|
|
|
|
let fromDateObj = new Date(fromDate.split('-').reverse().join('-'));
|
|
let toDateObj = new Date(toDate.split('-').reverse().join('-'));
|
|
if (fromDateObj > toDateObj) {
|
|
alert('Incorrect Date Applied For Filter..!!');
|
|
$('#toDate').attr('min', fromDate);
|
|
$('#toDate').val('');
|
|
|
|
}
|
|
});
|
|
});
|
|
|
|
</script>
|