Files
citrus-cms/resources/views/components/joint-release-popup.blade.php
T
2026-04-28 21:15:09 +03:00

247 lines
9.8 KiB
PHP

<div id="jointReleasePopup"></div>
<style>
.joint-release-popup-cell {
position: relative;
padding-right: 26px !important;
}
.joint-release-popup-trigger {
position: absolute;
top: 50%;
right: 4px;
transform: translateY(-50%);
display: inline-flex;
align-items: center;
justify-content: center;
width: 18px;
height: 18px;
border-radius: 50%;
font-size: 11px;
color: #e65100; /* Different color (Orange) to distinguish from RFI popup */
cursor: pointer;
background: rgba(255, 255, 255, 0.6);
border: 1px solid rgba(230, 81, 0, 0.4);
}
.joint-release-popup-trigger:hover {
color: #bf360c;
border-color: #bf360c;
}
</style>
<script>
(function () {
var popupState = {
popup: null,
grid: null,
dataSource: null,
params: null
};
function buildRequestUrl(params) {
var query = [];
if (params.rfiNo) {
query.push("rfi_no=" + encodeURIComponent(params.rfiNo));
}
return "{{url('admin-ajax/get-joint-for-rfi-log')}}" + "?" + query.join("&");
}
function ensureDataSource() {
popupState.dataSource = new DevExpress.data.CustomStore({
key: "id",
load: function (loadOptions) {
var deferred = $.Deferred();
var params = popupState.params || {};
if (!params.rfiNo) {
deferred.resolve({ data: [], totalCount: 0 });
return deferred.promise();
}
var requestUrl = buildRequestUrl(params);
if (loadOptions && loadOptions.skip !== undefined && loadOptions.take !== undefined) {
var separator = requestUrl.indexOf('?') === -1 ? '?' : '&';
requestUrl += separator + 'skip=' + loadOptions.skip + '&take=' + loadOptions.take;
}
$.getJSON(requestUrl).then(function (result) {
var data = [];
var totalCount = 0;
if (result && Array.isArray(result.data)) {
data = result.data;
totalCount = result.totalCount;
} else if (Array.isArray(result)) {
data = result;
totalCount = result.length;
}
deferred.resolve({ data: data, totalCount: totalCount });
}, function (error) {
var message = (error && (error.responseText || error.statusText)) || "Unknown error";
console.error("Joint Release Load Error", message);
deferred.resolve({ data: [], totalCount: 0 });
});
return deferred.promise();
}
});
return popupState.dataSource;
}
function ensurePopup() {
if (popupState.popup) {
return popupState.popup;
}
var $popup = $("#jointReleasePopup");
$popup.dxPopup({
title: "{{e2('Related Joint Release Logs')}}",
width: 1200,
height: 600,
visible: false,
showCloseButton: true,
shading: true,
resizeEnabled: true,
contentTemplate: function (contentElement) {
var $grid = $('<div class="joint-release-grid" style="height: 100%;"></div>');
contentElement.append($grid);
popupState.grid = $grid.dxDataGrid({
dataSource: ensureDataSource(),
remoteOperations: {
paging: true,
filtering: false,
sorting: false
},
keyExpr: "id",
showBorders: true,
hoverStateEnabled: true,
height: "100%",
columnAutoWidth: true,
allowColumnResizing: true,
paging: {
pageSize: 20,
enabled: true
},
pager: {
visible: true,
showPageSizeSelector: true,
allowedPageSizes: [20, 50, 100]
},
columns: [
{
dataField: "iso_number",
caption: "ISO Number",
width: 150
},
{
dataField: "line_number",
caption: "Line Number",
width: 150
},
{
dataField: "spool_number",
caption: "Spool Number",
width: 120
},
{
dataField: "joint_no",
caption: "Joint No",
width: 80
},
{
dataField: "type_of_welds",
caption: "Weld Type",
width: 80
},
{
dataField: "welding_date",
caption: "Welding Date",
dataType: "date",
format: "dd/MM/yyyy",
width: 100
},
{
dataField: "matched_types",
caption: "Found In Release",
width: 200,
cellTemplate: function(container, options) {
$('<span>').text(options.value).css('font-weight', 'bold').appendTo(container);
}
}
]
}).dxDataGrid("instance");
},
onShowing: function () {
if (popupState.grid) {
popupState.grid.clearSelection();
popupState.dataSource = null;
var newDataSource = ensureDataSource();
popupState.grid.option('dataSource', newDataSource);
popupState.grid.refresh();
}
}
});
popupState.popup = $popup.dxPopup("instance");
return popupState.popup;
}
window.showJointReleasePopup = function (options) {
options = options || {};
popupState.params = {
rfiNo: options.rfiNo || ""
};
var popup = ensurePopup();
var titleSuffix = popupState.params.rfiNo ? " (" + popupState.params.rfiNo + ")" : "";
popup.option("title", "{{e2('Related Joint Release Logs')}}" + titleSuffix);
if (popupState.grid) {
popupState.dataSource = null;
var newDataSource = ensureDataSource();
popupState.grid.option('dataSource', newDataSource);
popupState.grid.refresh();
}
popup.show();
};
window.setupJointLogPopupHelpers = function (dataGrid) {
if (!dataGrid) {
return;
}
// Helper function to attach magnifier to specific column
window.attachJointLogMagnifier = function (columnDataField) {
dataGrid.on("cellPrepared", function (e) {
if (e.rowType === "data" && e.column && e.column.dataField === columnDataField) {
var $cell = $(e.cellElement);
// Avoid double adding
if (!$cell.hasClass("joint-release-popup-cell")) {
$cell.addClass("joint-release-popup-cell");
// Check if value exists, but even if empty maybe we want to search (for empty?) No, usually searched by value.
// User request: "rfi no da joint release log daki bilgiler gözüksün"
var $trigger = $('<span class="joint-release-popup-trigger" title="Show Related Joints">🔍</span>');
$cell.append($trigger);
$trigger.on("click", function (event) {
event.stopPropagation();
var rowData = e.data;
var val = rowData[columnDataField];
if(val) {
window.showJointReleasePopup({
rfiNo: val
});
} else {
DevExpress.ui.notify("No RFI No to search", "warning", 2000);
}
});
}
}
});
};
};
})();
</script>