Created
July 18, 2023 15:30
-
-
Save joeyhipolito/1f324d541ab3f77e0b250762a252e6a5 to your computer and use it in GitHub Desktop.
OT
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(){if(typeof easepick === 'undefined'){const easepickScripts = ['https://cdn.jsdelivr.net/npm/@easepick/[email protected]/dist/index.umd.min.js','https://cdn.jsdelivr.net/npm/@easepick/[email protected]/dist/index.umd.min.js','https://cdn.jsdelivr.net/npm/@easepick/[email protected]/dist/index.umd.min.js','https://cdn.jsdelivr.net/npm/@easepick/[email protected]/dist/index.umd.min.js'];easepickScripts.forEach(script => {var scriptElem = document.createElement('script');scriptElem.type = 'text/javascript';scriptElem.src = script;document.head.appendChild(scriptElem);});}function waitForScriptLoad(){if(typeof easepick !== 'undefined' && typeof easepick.RangePlugin !== 'undefined'){mainFunction();}else{setTimeout(waitForScriptLoad, 250);}}waitForScriptLoad();function mainFunction(){let modalHTML = `<div id="modal" style="display: none; position: fixed; z-index: 1; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.4);"><div style="background-color: #fefefe; margin: 15% auto; padding: 20px; border: 1px solid #888; width: 300px;"><h2>Select Date Range</h2><input id="datepicker"/><button id="saveBtn" style="display: block; margin-top: 10px;">Save</button></div></div>`;document.body.insertAdjacentHTML('beforeend', modalHTML);const picker = new easepick.create({element: document.getElementById('datepicker'),css: ['https://cdn.jsdelivr.net/npm/@easepick/[email protected]/dist/index.css','https://cdn.jsdelivr.net/npm/@easepick/[email protected]/dist/index.css'],plugins: ['RangePlugin'],RangePlugin: {tooltip: true}});document.getElementById("modal").style.display = "block";document.querySelector("#saveBtn").addEventListener('click', async function(){var range = {start: picker.getStartDate(),end: picker.getEndDate()};for (var d = new Date(range.start); d <= range.end; d.setDate(d.getDate() + 1)){if (d.getDay() === 6 || d.getDay() === 0) continue;let date = ((d.getMonth() > 8) ? (d.getMonth() + 1) : ('0' + (d.getMonth() + 1))) + '/' + ((d.getDate() > 9) ? d.getDate() : ('0' + d.getDate())) + '/' + d.getFullYear();let nextDate = ((d.getMonth() > 8) ? (d.getMonth() + 1) : ('0' + (d.getMonth() + 1))) + '/' + ((d.getDate() + 1 > 9) ? (d.getDate() + 1) : ('0' + (d.getDate() + 1))) + '/' + d.getFullYear();let url = "https://ess.bposerve.com/ot_filing/save?recordid=0";let headers = {"accept": "*/*","accept-language": "en-US,en;q=0.9,pt;q=0.8","content-type": "application/x-www-form-urlencoded; charset=UTF-8","sec-ch-ua": "\"Not.A/Brand\";v=\"8\", \"Chromium\";v=\"114\", \"Google Chrome\";v=\"114\"","sec-ch-ua-mobile": "?0","sec-ch-ua-platform": "\"macOS\"","sec-fetch-dest": "empty","sec-fetch-mode": "cors","sec-fetch-site": "same-origin","x-requested-with": "XMLHttpRequest"};let body = `authenticity_token=${encodeURIComponent(window.Ext.Ajax.extraParams.authenticity_token)}&IsValidDate=1&IsValidTime=1&Date=${date}&StartDate=${nextDate}&EndDate=${nextDate}&StartTime=6%3A00%20AM&EndTime=7%3A00%20AM&HoursFiled=1&Comment=1hr%20additional%20ND&IsConvertToLeave=false`;await fetch(url, {headers: headers,referrer: "https://ess.bposerve.com/app",referrerPolicy: "strict-origin-when-cross-origin",body: body,method: "POST",mode: "cors",credentials: "include"});}document.getElementById("modal").style.display = "none";});}})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment