2024-06-13 09:16:09 +00:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html>
|
|
|
|
<head>
|
|
|
|
<title>OPT IN ANALYST</title>
|
|
|
|
<!-- Tabulator CSS -->
|
|
|
|
<link href="https://unpkg.com/tabulator-tables@5.4.4/dist/css/tabulator.min.css" rel="stylesheet">
|
|
|
|
<style>
|
|
|
|
.button {
|
|
|
|
border: none;
|
|
|
|
color: white;
|
|
|
|
padding: 4px 4px;
|
|
|
|
text-align: center;
|
|
|
|
text-decoration: none;
|
|
|
|
display: inline-block;
|
|
|
|
font-size: 12px;
|
|
|
|
margin: 4px 2px;
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
2024-06-18 09:42:52 +00:00
|
|
|
.button1 {background-color: #04AA6D;}
|
|
|
|
.button2 {background-color: #008CBA;}
|
|
|
|
.button3 {background-color: #9bba00;}
|
|
|
|
.loader {
|
|
|
|
position: fixed;
|
|
|
|
left: 50%;
|
|
|
|
top: 50%;
|
|
|
|
transform: translate(-50%, -50%);
|
|
|
|
border: 16px solid #f3f3f3;
|
|
|
|
border-radius: 50%;
|
|
|
|
border-top: 16px solid #3498db;
|
|
|
|
width: 120px;
|
|
|
|
height: 120px;
|
|
|
|
animation: spin 2s linear infinite;
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
@keyframes spin {
|
|
|
|
0% { transform: rotate(0deg); }
|
|
|
|
100% { transform: rotate(360deg); }
|
|
|
|
}
|
2024-06-20 06:03:33 +00:00
|
|
|
/* //background-color: #2b9af3; */
|
|
|
|
.tabulator .tabulator-header .tabulator-col { color: black;}
|
2024-06-13 09:16:09 +00:00
|
|
|
</style>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<!-- {% extends "templates/web.html" %} -->
|
|
|
|
|
|
|
|
{% block title %}Pricing{% endblock %}
|
|
|
|
{% block content %}
|
2024-06-18 09:42:52 +00:00
|
|
|
<div id="loader" class="loader"></div>
|
|
|
|
<p style="padding-left: 5px;"><strong>Opt In Data </strong> </p>
|
2024-06-13 09:16:09 +00:00
|
|
|
|
2024-06-18 09:42:52 +00:00
|
|
|
<div style="padding-left: 5px;">
|
2024-06-13 09:16:09 +00:00
|
|
|
<button id="download-csv" class="button button1">Download CSV</button>
|
|
|
|
<button id="download-xlsx" class="button button2">Download XLSX</button>
|
|
|
|
<button id="download-pdf" class="button button3">Download PDF</button>
|
|
|
|
</div>
|
2024-06-18 09:42:52 +00:00
|
|
|
<div style="padding-left: 5px; padding-bottom: 5px;" id="tabulator-table" class="tabulator-table"></div>
|
2024-06-13 09:16:09 +00:00
|
|
|
|
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
|
|
|
|
{% block script %}
|
|
|
|
<script src="https://unpkg.com/tabulator-tables@5.4.4/dist/js/tabulator.min.js"></script>
|
|
|
|
<script frappe.csrf_token = "{{frappe.session.csrf_token}}"; ></script>
|
|
|
|
<script type="text/javascript" src="https://oss.sheetjs.com/sheetjs/xlsx.full.min.js"></script>
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.4.0/jspdf.umd.min.js"></script>
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.5.20/jspdf.plugin.autotable.min.js"></script>
|
|
|
|
<script>
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
2024-06-20 06:03:33 +00:00
|
|
|
|
2024-06-18 09:42:52 +00:00
|
|
|
const loader = document.getElementById('loader');
|
|
|
|
const content = document.getElementById('tabulator-table');
|
2024-06-13 09:16:09 +00:00
|
|
|
var data = [];
|
2024-06-18 09:42:52 +00:00
|
|
|
var table;
|
2024-06-20 06:03:33 +00:00
|
|
|
let loading = false;
|
|
|
|
function loadData() {
|
|
|
|
return new Promise((resolve) => {
|
|
|
|
setTimeout(() => {
|
|
|
|
resolve("Data loaded");
|
|
|
|
}, 12000); // Simulate a 3-second loading time
|
|
|
|
});
|
|
|
|
}
|
|
|
|
window.loadData = loadData();
|
|
|
|
frappe.call({
|
|
|
|
method: 'optmanagementprod.www.optanlaystauth.isUserLoggedIn',
|
|
|
|
callback: function(r) {
|
|
|
|
console.log(r.message);
|
|
|
|
if(!r.message)
|
|
|
|
{
|
|
|
|
window.location.href = '/login?redirect-to=/optanalystview';
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
|
|
|
|
|
2024-06-13 09:16:09 +00:00
|
|
|
frappe.call({
|
|
|
|
method: 'optmanagementprod.www.optanalystview.fetch_data',
|
|
|
|
callback: function(r) {
|
2024-06-20 06:03:33 +00:00
|
|
|
// console.log(r);
|
|
|
|
if (r.message.length > 0) {
|
|
|
|
loading = false;
|
2024-06-13 09:16:09 +00:00
|
|
|
data = r.message;
|
2024-06-20 06:03:33 +00:00
|
|
|
loader.setAttribute('style', 'display : none !important');
|
2024-06-13 09:16:09 +00:00
|
|
|
// Render data in the HTML
|
2024-06-20 06:03:33 +00:00
|
|
|
// console.log(data);
|
2024-06-13 09:16:09 +00:00
|
|
|
// You can use the data to populate your table or any other HTML element
|
|
|
|
|
2024-06-20 06:03:33 +00:00
|
|
|
|
|
|
|
|
2024-06-13 09:16:09 +00:00
|
|
|
// Sample data for the table
|
|
|
|
var tableData = [];
|
|
|
|
for(var rec in data)
|
|
|
|
{
|
2024-06-18 09:42:52 +00:00
|
|
|
tableData.push({
|
2024-06-20 06:03:33 +00:00
|
|
|
kol_id:rec.kol_id, kol_name:rec["kol_name"],project_name: rec["project_name"], client_name:rec["client_name"], client_poc:rec["client_poc"],optin_received_date:rec["optin_received_date"] == null ? ' ' : rec["optin_received_date"],optin_approved_date:rec["optin_approved_date"],status:rec["status"],instance:rec["instance"]
|
|
|
|
// cs_Assigned_poc:rec["cs_Assigned_poc"],optin_type:rec["optin_type"],data_processed_date:rec["data_processed_date"]
|
2024-06-13 09:16:09 +00:00
|
|
|
});
|
|
|
|
}
|
2024-06-20 06:03:33 +00:00
|
|
|
// console.log(tableData);
|
2024-06-13 09:16:09 +00:00
|
|
|
// var tableData = [(
|
|
|
|
// {kol_id:1, kol_name:"Oli Bob",project_name: "", client_name:"12", client_poc:"red", cs_Assigned_poc:""} )
|
2024-06-18 09:42:52 +00:00
|
|
|
|
2024-06-13 09:16:09 +00:00
|
|
|
// ];
|
|
|
|
|
|
|
|
// Create Tabulator table
|
|
|
|
|
2024-06-18 09:42:52 +00:00
|
|
|
table = new Tabulator("#tabulator-table", {
|
2024-06-13 09:16:09 +00:00
|
|
|
data:data, // Assign data to table
|
2024-06-20 06:03:33 +00:00
|
|
|
//layout:"fitDataTable",
|
2024-06-13 09:16:09 +00:00
|
|
|
// filterMode: "remote",
|
|
|
|
pagination:true,
|
|
|
|
paginationSize: 20,
|
2024-06-20 06:03:33 +00:00
|
|
|
placeholder:"No results",
|
|
|
|
layout:"fitDataStretch",
|
|
|
|
|
|
|
|
// ajaxLoaderLoading:"<span>Loading Data</span>",
|
2024-06-13 09:16:09 +00:00
|
|
|
// paginationMode:"remote",
|
|
|
|
paginationSizeSelector: [5, 10, 50, 100],
|
|
|
|
paginationCounter: "rows",
|
|
|
|
columns:[ // Define table columns
|
2024-06-20 06:03:33 +00:00
|
|
|
{title:"KOL ID", field:"kol_id",headerFilterPlaceholder: "Search",hozAlign:"center", headerFilter: true,width:150},
|
2024-06-13 09:16:09 +00:00
|
|
|
{title:"KOL Name", field:"kol_name",headerFilterPlaceholder: "Search", headerFilter: true,},
|
2024-06-18 09:42:52 +00:00
|
|
|
{title:"Project Name", field:"project_name",headerFilterPlaceholder: "Search", headerFilter: true,width:250},
|
2024-06-13 09:16:09 +00:00
|
|
|
{title:"Client Name", field:"client_name",headerFilterPlaceholder: "Search", headerFilter: true,},
|
|
|
|
{title:"Client POC", field:"client_poc",headerFilterPlaceholder: "Search", headerFilter: true,},
|
2024-06-20 06:03:33 +00:00
|
|
|
|
2024-06-13 09:16:09 +00:00
|
|
|
{title:"Requested Date", field:"optin_received_date",headerFilterPlaceholder: "Search", headerFilter: true,},
|
|
|
|
{title:"Approved Date", field:"optin_approved_date",headerFilterPlaceholder: "Search", headerFilter: true,},
|
|
|
|
{title:"Status", field:"status",headerFilterPlaceholder: "Search", headerFilter: true,},
|
2024-06-20 06:03:33 +00:00
|
|
|
{title:"Instance", field:"instance",headerFilterPlaceholder: "Search", headerFilter: true,},
|
|
|
|
// {title:"CS Assigned POC", field:"cs_assigned_poc",headerFilterPlaceholder: "Search", headerFilter: true,},
|
|
|
|
// {title:"Opt-In Type", field:"optin_type",headerFilterPlaceholder: "Search", headerFilter: true,},
|
|
|
|
// {title:"Data Processed Date", field:"data_processed_date",headerFilterPlaceholder: "Search", headerFilter: true}
|
2024-06-13 09:16:09 +00:00
|
|
|
],
|
|
|
|
});
|
|
|
|
document.getElementById("download-csv").addEventListener("click", function(){
|
|
|
|
table.download("csv", "optInData.csv");
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-06-18 09:42:52 +00:00
|
|
|
//trigger download of data.xlsx file
|
|
|
|
document.getElementById("download-xlsx").addEventListener("click", function(){
|
|
|
|
table.download("xlsx", "optInData.xlsx", {sheetName:"Opt In Data"});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2024-06-13 09:16:09 +00:00
|
|
|
//trigger download of data.xlsx file
|
|
|
|
document.getElementById("download-xlsx").addEventListener("click", function(){
|
|
|
|
table.download("xlsx", "optInData.xlsx", {sheetName:"Opt In Data"});
|
|
|
|
});
|
|
|
|
|
|
|
|
//trigger download of data.pdf file
|
|
|
|
document.getElementById("download-pdf").addEventListener("click", function(){
|
|
|
|
table.download("pdf", "optInData.pdf", {
|
|
|
|
orientation:"portrait", //set page orientation to portrait
|
|
|
|
title:"opt In Data Report", //add title to report
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2024-06-20 06:03:33 +00:00
|
|
|
}else{
|
|
|
|
loading = true;
|
2024-06-13 09:16:09 +00:00
|
|
|
}
|
|
|
|
}
|
2024-06-18 09:42:52 +00:00
|
|
|
|
2024-06-13 09:16:09 +00:00
|
|
|
});
|
2024-06-18 09:42:52 +00:00
|
|
|
async function init() {
|
2024-06-20 06:03:33 +00:00
|
|
|
|
|
|
|
//console.log(data);
|
|
|
|
// Hide loader
|
|
|
|
if(loading){
|
|
|
|
|
|
|
|
loader.style.display = 'none';
|
|
|
|
// loader.setAttribute('style', 'display : none !important');
|
|
|
|
// Display content
|
|
|
|
content.innerHTML = table;
|
|
|
|
content.style.display = 'block';
|
|
|
|
}else{
|
|
|
|
// Show loader
|
2024-06-18 09:42:52 +00:00
|
|
|
loader.style.display = 'block';
|
2024-06-20 06:03:33 +00:00
|
|
|
|
2024-06-18 09:42:52 +00:00
|
|
|
// Load data
|
2024-06-20 06:03:33 +00:00
|
|
|
// const data2 = await loadData();
|
|
|
|
}
|
|
|
|
|
2024-06-18 09:42:52 +00:00
|
|
|
}
|
2024-06-13 09:16:09 +00:00
|
|
|
|
2024-06-18 09:42:52 +00:00
|
|
|
// Initialize the loader and content
|
|
|
|
init();
|
2024-06-20 06:03:33 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2024-06-13 09:16:09 +00:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
{% endblock %}
|
|
|
|
</body>
|
2024-06-18 09:42:52 +00:00
|
|
|
</html>
|