ria/app/Views/porelease_view.php

639 lines
17 KiB
PHP
Executable File

<?php
//echo "OUTIF";
if (empty($Status)) {
//echo "INIF";
//print_r($Status);
}
?>
<style>
/* Default minimized state */
.supplier-content {
max-width: 150px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
cursor: pointer;
height: 20px;
/* Minimized height */
transition: height 0.3s ease-out;
/* Smooth transition */
}
/* Expanded state with fixed height and scrolling */
.supplier-content.expand {
height: 100px;
/* Fixed height for expanded state */
white-space: normal;
/* Allows wrapping */
overflow-y: auto;
/* Enable vertical scrolling */
transition: height 0.3s ease-in;
/* Smooth transition for height */
}
.table-bordered>thead>tr>th,
.table-bordered>tbody>tr>th,
.table-bordered>tfoot>tr>th,
.table-bordered>thead>tr>td,
.table-bordered>tbody>tr>td,
.table-bordered>tfoot>tr>td {
border: 1px solid #333;
}
.modal-content {
width: 1000px ! important;
}
.modal {
padding-right: 25% ! important;
}
#Requisition_filter {
float: inline-end;
}
#Requisition_wrapper .row .col-sm-4 {
flex-basis: 50%;
float: inline-end;
}
#Requisition_paginate .pagination {
flex-basis: 50%;
float: inline-end;
margin: 0 0 15px;
}
#Requisition_wrapper .row:nth-child(3),
#Requisition_wrapper .row:nth-child(1) {
padding: 0 15px;
}
#Requisition_info {
margin-top: 5px;
}
.dataTables_wrapper {
padding-bottom: 0;
}
</style>
<style>
.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">
<h4 class="page-title">Purchase Order Approve List</h4>
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="card">
<form class="Date-filter-form" id="DateRangeFilter" style="margin-top: 14px;margin-bottom: -11px;margin-left: 33px;">
<input type="hidden" name="table" value="requisition">
<label for="fromDate">From:</label>
<input class="form-control date_range" type="date" id="fromDate" name="fromDate" placeholder="Select From Date" autocomplete="off" required>
<label for="toDate">To:</label>
<input class="form-control date_range" type="date" 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" aria-hidden="true" class="icon-button" id="resetButton" title="Reset"></i>
<div class="error" id="error"></div>
</form>
<div class="card-body">
<table id="po_release" class="table dt-responsive nowrap w-100">
<thead>
<tr>
<th>PO Date</th>
<th>Purchase Order Number</th>
<th>Purchase Order Type</th>
<th>Cost Center Name</th>
<th>Supplier Name</th>
<th>Created By</th>
<th>Department</th>
<!-- <th>Created Date</th> -->
<th>Total Order Value</th>
<th>Approved By</th>
<th>Status</th>
<th>Action</th>
<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->PODate);
$PODate = $podt->format('d-m-Y');
echo $PODate;
?></td>
<td><a 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 ?>"><u><?php echo $record->PONO ?> </td>
<td><?php echo $record->RType ?> </td>
<td><?php echo $record->CostCenterName ?> </td>
<!-- <td><?php // echo $record->CostCenterCode
?></td> -->
<td class="supplier-name" style="text-wrap: balance;">
<div class="supplier-content">
<?php echo $record->SupplierName ?>
</div>
</td>
<td><?php echo $record->FirstName ?></td>
<td><?php echo $record->DepartmentName ?></td>
<!-- <td align="right"><?php // $Cdt = new DateTime($record->CreatedDate);
// $CreatedDate = $Cdt->format('d-m-Y');
// echo $CreatedDate;
?></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($record->StatusName == 'RELEASER ONHOLD' or $record->StatusName == 'AWAITING RELEASE' or $record->StatusName == 'AMENDMENT PO'){
if ($record->StatusCode == PO_APPROVER_ONHOLD or $record->StatusCode == PO_CREATED or $record->StatusCode == REQITEM_Emergency_PO_CREATED) {
?>
<td>
<select name="selectId" id="selectId" onchange="showvalue('<?php echo $record->PONO ?>','<?php echo $index; ?>',this.options[this.selectedIndex].value,'<?php echo $record->Remarks ?>');">
<option value="-1">Select Action</option>
<!-- <option value="1">Release</option> -->
<option value="1">Approve And Release</option>
<option value="2">OnHold</option>
</select>
</td>
<?php } else {
echo "<td><center>-</center></td>";
} ?>
<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) {
$('#content').loader('show');
$.ajax({
data: {
PONO: PO,
SCode: StatusCode,
NewRemarks: Remarks
},
type: "POST",
url: "<?php echo base_url() ?>purchaseorder/ReleasePO",
success: function(data) {
if (data) {
$('#content').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;");
$('#content').loader('show');
$.ajax({
data: {
id: ReqId
},
type: "POST",
dataType: 'json',
url: "<?php echo base_url() ?>requisitionform/ViewRequest",
success: function(json) {
// success:function(data) {
$('#content').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
});
$.fn.dataTable.moment('DD-MM-YYYY');
// $('#Requisition').DataTable({
// columnDefs: [{ width: 200}],
// fixedColumns: true,
// paging: true,
// lengthChange: true,
// searching: true,
// ordering: true,
// aaSorting: [[ 0, "desc" ]],
// 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>
<script src="https://cdn.datatables.net/buttons/2.3.4/js/dataTables.buttons.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.3.4/js/buttons.html5.min.js"></script>
<script src="https://cdn.datatables.net/buttons/2.3.4/js/buttons.print.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/pdfmake.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.7/vfs_fonts.js"></script>
<script src="https://cdn.datatables.net/plug-ins/1.13.6/sorting/datetime-moment.js"></script>
<script>
$.fn.dataTable.ext.type.order['date-eu-pre'] = function(date) {
var dateSplit = date.split('/');
return (dateSplit[2] + dateSplit[1] + dateSplit[0]) * 1;
};
</script>
<script>
$(document).ready(function() {
// Initialize the DataTable
var table = $('#po_release').DataTable({
dom: 'Blfrtip', // Buttons, length menu, filter, table, information, pagination
buttons: [
'copy', 'csv', 'excel', 'pdf', 'print' // Export buttons
],
pageLength: 10, // Default rows per page
lengthMenu: [
[10, 20, 30, 50, -1],
[10, 20, 30, 50, "All"]
], // Rows per page options
responsive: true, // Responsive table
order: [], // Default ordering (column index 0, descending)
language: {
paginate: {
next: '<i class="fas fa-angle-right"></i>', // Next button icon
previous: '<i class="fas fa-angle-left"></i>' // Previous button icon
}
},
autoWidth: true
});
// Date range filter function
$.fn.dataTable.ext.search.push(
function(settings, data, dataIndex) {
var fromDate = $('#fromDate').val();
var toDate = $('#toDate').val();
if (!fromDate || !toDate) {
return true; // If no dates selected, don't filter
}
var dateStr = data[0]; // Assuming the date is in the first column
var dateParts = dateStr.split("-");
var date = new Date(dateParts[2], dateParts[1] - 1, dateParts[0]); // Convert dd-mm-yyyy to Date object
var startDate = new Date(fromDate);
var endDate = new Date(toDate);
// Adjust startDate to include the day before the selected fromDate
startDate.setDate(startDate.getDate() - 1);
// Ensure endDate includes the entire end date by setting time to the end of the day
endDate.setHours(23, 59, 59, 999);
// Return true if the date is within the range
return date >= startDate && date <= endDate;
}
);
// Handle form submission for the date range filter
$("#DateRangeFilter").submit(function(e) {
e.preventDefault();
table.draw(); // Redraw the table to apply the filter
});
// Reset button functionality
$("#resetButton").click(function() {
$("#fromDate").val('');
$("#toDate").val('');
table.draw(); // Redraw the table to clear the filter
});
// Automatically focus and open the To Date picker when From Date is selected
document.getElementById('fromDate').addEventListener('change', function() {
var fromDate = this.value;
var toDateInput = document.getElementById('toDate');
// Set the min attribute of the To Date input to the selected From Date
toDateInput.min = fromDate;
// Optionally reset the To Date input if the current value is before the new min date
if (toDateInput.value < fromDate) {
toDateInput.value = fromDate;
}
});
});
$(document).ready(function() {
$('.supplier-content').on('click', function() {
var $this = $(this);
if (!$this.hasClass('expand')) {
// Expand: Set to fixed height with scroll
$this.addClass('expand');
} else {
// Collapse: Reset to minimized height
// $this.css('height', '20px').removeClass('expand');
$this.removeClass('expand');
}
});
});
</script>