(function (w) { 'use strict'; if (w.pciConfirmRevisedPcFromApproved) { return; } /** * @param {string} beginUrl * @param {number|string} approvedFormId * @param {object} data revision-availability payload * @param {function|null} onCancel optional — e.g. reset scheme / modal selection when user clicks Cancel */ w.pciConfirmRevisedPcFromApproved = function (beginUrl, approvedFormId, data, onCancel) { var fromScheme = data && data.revision_from_scheme_approved; var html = fromScheme ? '

This scheme is approved in the core register. Continue on this page to prepare a Revised PC-I using the latest saved PC-I data as the baseline.

' : '

An approved PC-I already exists for this scheme. Open the revision workspace to prepare a Revised PC-I from that approved record.

'; var navigate = function () { var id = approvedFormId != null && approvedFormId !== '' ? String(approvedFormId) : ''; if (!beginUrl || !id) { return; } w.location.href = beginUrl + '?pc_form_id=' + encodeURIComponent(id); }; var dismiss = function () { if (typeof onCancel === 'function') { try { onCancel(); } catch (e) { /* ignore */ } } }; if (typeof Swal !== 'undefined' && Swal && typeof Swal.fire === 'function') { Swal.fire({ icon: 'question', title: fromScheme ? 'Revised PC-I from approved scheme' : 'Revised PC-I', html: html, showCancelButton: true, confirmButtonText: 'Proceed', cancelButtonText: 'Cancel', focusCancel: true, reverseButtons: true, }).then(function (result) { if (result.isConfirmed) { navigate(); } else { dismiss(); } }); } else if (w.confirm(fromScheme ? 'This scheme is approved. Continue to create a Revised PC-I on this page?' : 'An approved PC-I exists for this scheme. Open the revision workspace to create a Revised PC-I?')) { navigate(); } else { dismiss(); } }; /** * Approved scheme with no PC-I row to clone: confirm staying on create. Proceed does not navigate. * @param {function|null} onCancel — reset scheme / hide revised UI when user cancels (skipped when cookie-locked) */ w.pciConfirmBlankRevisedPcOnCreate = function (onCancel) { var html = '

This scheme is approved in the core register. Continue on this page to create a Revised PC-I. When you submit, it will be recorded as a revision.

'; var dismiss = function () { if (typeof onCancel === 'function') { try { onCancel(); } catch (e) { /* ignore */ } } }; if (typeof Swal !== 'undefined' && Swal && typeof Swal.fire === 'function') { Swal.fire({ icon: 'question', title: 'Revised PC-I from approved scheme', html: html, showCancelButton: true, confirmButtonText: 'Proceed', cancelButtonText: 'Cancel', focusCancel: true, reverseButtons: true, }).then(function (result) { if (!result.isConfirmed) { dismiss(); } }); } else if (w.confirm('This scheme is approved with no PC-I record yet. Continue on this page to create a Revised PC-I?')) { /* stay on page */ } else { dismiss(); } }; })(window);