Wednesday, 28 January 2026

Estimator ( Cost Estimator)

<?php

// ------------------- PHP SECTION -------------------

// Load CSV into array


/*

Techstack Platform Env T-Shirt Size Compute License Input Notes

Oracle Cloud PROD Micro 30000 1000 License Included in Cost

Oracle Cloud COB Micro 30000 1000 License Included in Cost

*/


function loadCSV($filename) {

    $rows = array_map('str_getcsv', file($filename));

    $header = array_shift($rows);

    $csv = [];

    foreach ($rows as $row) {

        $csv[] = array_combine($header, $row);

    }

    return $csv;

}


$data = loadCSV("estimator.csv");


function loadXML($filename) {

    $xml = simplexml_load_file($filename) or die("Unable to load XML file");

    $data = [];


    foreach ($xml->Estimator as $est) {

        $data[] = [

            "Techstack"   => trim((string)$est->Techstack),

            "Platform"    => trim((string)$est->Platform),

            "Env"         => trim((string)$est->Env),

            "T-Shirt Size"=> trim((string)$est->TShirtSize),

            "Compute"     => trim((string)$est->Compute),

            "License"     => trim((string)$est->License),

            "Input Notes" => trim((string)$est->InputNotes)

        ];

    }

    return $data;

}


//$data = loadXML("estimator.xml");



// Handle AJAX requests


if (isset($_GET['action'])) {

    header('Content-Type: application/json');

    $action = $_GET['action'];


    // Techstack

/*

    if ($action == 'getTechstack') {

        $techs = [];

        foreach ($data as $row) {

            if (!empty(trim($row['Techstack']))) {

                $techs[] = trim($row['Techstack']);

            }

        }

        echo json_encode(array_values(array_unique($techs)));

        exit;

    }

*/

if ($action == 'getTechstack') {

    $techs = [];

    foreach ($data as $row) {

        if (!empty($row['Techstack'])) {

            $techs[] = $row['Techstack'];

        }

    }

    echo json_encode(array_values(array_unique($techs)));

    exit;

}


    // Platform

    if ($action == 'getPlatform' && !empty($_GET['tech'])) {

        $platforms = [];

        foreach ($data as $row) {

            if (trim($row['Techstack']) === trim($_GET['tech'])) {

                $platforms[] = trim($row['Platform']);

            }

        }

        echo json_encode(array_values(array_unique($platforms)));

        exit;

    }


    // Env

    if ($action == 'getEnv' && !empty($_GET['tech']) && !empty($_GET['platform'])) {

        $envs = [];

        foreach ($data as $row) {

            if (trim($row['Techstack']) === trim($_GET['tech']) &&

                trim($row['Platform']) === trim($_GET['platform'])) {

                $envs[] = trim($row['Env']);

            }

        }

        echo json_encode(array_values(array_unique($envs)));

        exit;

    }


    // T-Shirt Size

    if ($action == 'getSize' && !empty($_GET['tech']) && !empty($_GET['platform']) && !empty($_GET['env'])) {

        $sizes = [];

        foreach ($data as $row) {

            if (trim($row['Techstack']) === trim($_GET['tech']) &&

                trim($row['Platform']) === trim($_GET['platform']) &&

                trim($row['Env']) === trim($_GET['env'])) {

                $sizes[] = trim($row['T-Shirt Size']);

            }

        }

        echo json_encode(array_values(array_unique($sizes)));

        exit;

    }


    // Details (Compute, License, Notes)

    if ($action == 'getDetails' && !empty($_GET['tech']) && !empty($_GET['platform']) && !empty($_GET['env']) && !empty($_GET['size'])) {

        foreach ($data as $row) {

            if (trim($row['Techstack']) === trim($_GET['tech']) &&

                trim($row['Platform']) === trim($_GET['platform']) &&

                trim($row['Env']) === trim($_GET['env']) &&

                trim($row['T-Shirt Size']) === trim($_GET['size'])) {

                echo json_encode([

                    "compute" => trim($row['Compute']),

                    "license" => trim($row['License']),

                    "notes"   => trim($row['Input Notes'])

                ]);

                exit;

            }

        }

    }

}



?>


<!DOCTYPE html>

<html>

<head>

    <title>Estimator</title>

    <style>

        body { font-family: Arial, sans-serif; background: #f4f6f9; }

        table { border-collapse: collapse; width: 100%; margin: 20px 0; }

        th, td { border: 1px solid #ddd; padding: 8px; text-align: center; }

        th { background: #007acc; color: white; }

        tr:nth-child(even) { background: #f9f9f9; }

        button { background: #007acc; color: white; border: none; padding: 6px 12px; cursor: pointer; }

        button:hover { background: #005f99; }

        #grandTotal { font-weight: bold; margin-top: 20px; }

/* Grand Total row styling */

.grand-total {

    background-color: #f4f6f9;   /* subtle light gray background */

    font-weight: bold;           /* bold text */

    color: #2c3e50;              /* dark slate text */

    border-top: 2px solid #34495e; /* strong top border */

}


.grand-total td {

    padding: 8px 12px;           /* consistent spacing */

    text-align: center;          /* center align numbers */

}


.grand-total td:first-child {

    text-align: left;            /* label aligned left */

    font-size: 1.1em;            /* slightly larger font */

    color: #1a5276;              /* accent color for label */

}


/* Dropdown styling */

select {

    padding: 8px 12px;

    border: 1px solid #ccc;

    border-radius: 6px;

    background-color: #fdfdfd;

    font-family: Arial, sans-serif;

    font-size: 14px;

    color: #333;

    transition: all 0.2s ease-in-out;

}


select:hover {

    border-color: #3498db;

    box-shadow: 0 0 5px rgba(52, 152, 219, 0.4);

}


select:focus {

    outline: none;

    border-color: #2980b9;

    box-shadow: 0 0 6px rgba(41, 128, 185, 0.5);

}


/* General Table Styling */

table {

    border-collapse: collapse;

    width: 100%;

    margin: 20px 0;

    font-family: Arial, sans-serif;

    font-size: 14px;

    background-color: #fff;

    border-radius: 8px;

    overflow: hidden;

    box-shadow: 0 2px 8px rgba(0,0,0,0.1);

}


/* Header */

table th {

    background-color: #2c3e50;

    color: #fff;

    text-transform: uppercase;

    font-weight: bold;

    padding: 12px;

    text-align: center;

}


/* Cells */

table td {

    border: 1px solid #ddd;

    padding: 10px;

    text-align: center;

    color: #333;

}


/* Zebra striping */

table tr:nth-child(even) {

    background-color: #f9f9f9;

}


/* Hover effect */

table tr:hover {

    background-color: #f1f7fd;

}


/* Grand Total row */

table .grand-total {

    background-color: #f4f6f9;

    font-weight: bold;

    border-top: 2px solid #34495e;

}


table .grand-total td {

    color: #1a5276;

    font-size: 1.05em;

}


/* Highlight one-time license Year 1 */

.one-time-license {

    background-color: #ffeaa7;

    font-weight: bold;

    color: #d35400;

}


/* CAPEX Table Header Row */

#capexTable tr:first-child {

    background: black;

    color: white;              /* white text for contrast */

    font-weight: bold;

    text-transform: uppercase;

    font-size: 15px;

    letter-spacing: 0.5px;

}


#capexTable tr:first-child td,

#capexTable tr:first-child th {

    color: white;   

    padding: 12px;

    border: none;

    text-align: center;

}


.capex-title {

    font-family: Arial, sans-serif;

    font-size: 18px;

    font-weight: bold;

    color: #2c3e50;

    margin: 10px 0;

    padding: 8px 12px;

    background-color: #ecf0f1;

    border-left: 5px solid #3498db;

    border-radius: 4px;

}




    </style>

</head>

<body>


<h2>Estimator Table</h2>

<button onclick="addRow()">Add Row</button>

<button onclick="exportCSV()">Export to CSV</button>


<table id="estimatorTable">

    <tr>

        <th>Techstack</th>

        <th>Platform</th>

        <th>Env</th>

        <th>T-Shirt Size</th>

        <th>Compute</th>

        <th>License</th>

        <th>Units/Cluster</th>

        <th>Input Notes</th>

        <th>User Notes</th>

        <th>Total Cost/Year</th>

        <th>Delete</th>

    </tr>

</table>



<div id="grandTotal">Grand Total: 0 | HW: 0 | SW: 0</div>

<br>

<br>

<div class="capex-title">5-Year CAPEX Projection</div>

<table id="capexTable"></table>


<script>

let table = document.getElementById("estimatorTable");

let grandTotal = document.getElementById("grandTotal");


console.log("Platforms for", tech, data);


function addRow() {

    let row = table.insertRow();

    // Techstack dropdown

    let techCell = row.insertCell();

    let techSelect = document.createElement("select");

    techSelect.onchange = () => {

    if (techSelect.value) {

        loadPlatform(row, techSelect.value);

    }

};


// After populating options, trigger once

techSelect.selectedIndex = 0; // or 1 if you want first real value

techSelect.dispatchEvent(new Event("change"));




    techCell.appendChild(techSelect);


    // Platform dropdown

    let platCell = row.insertCell();

    let platSelect = document.createElement("select");

    platSelect.onchange = () => loadEnv(row, techSelect.value, platSelect.value);

    platCell.appendChild(platSelect);


    // Env dropdown

    let envCell = row.insertCell();

    let envSelect = document.createElement("select");

    envSelect.onchange = () => loadSize(row, techSelect.value, platSelect.value, envSelect.value);

    envCell.appendChild(envSelect);


    // Size dropdown

    let sizeCell = row.insertCell();

    let sizeSelect = document.createElement("select");

    sizeSelect.onchange = () => loadDetails(row, techSelect.value, platSelect.value, envSelect.value, sizeSelect.value);

    sizeCell.appendChild(sizeSelect);


    // Compute

    let computeCell = row.insertCell();

    computeCell.innerHTML = "0";


    // License

    let licenseCell = row.insertCell();

    licenseCell.innerHTML = "0";


    // Units

    let unitCell = row.insertCell();

    let unitInput = document.createElement("input");

    unitInput.type = "number"; unitInput.value = 1;

    unitInput.oninput = () => calculateRow(row);

    unitCell.appendChild(unitInput);


    // Input Notes

    let notesCell = row.insertCell();

    notesCell.innerHTML = "";


    // User Notes

    let userNotesCell = row.insertCell();

    let userNotesInput = document.createElement("input");

    userNotesInput.type = "text";

    userNotesCell.appendChild(userNotesInput);


    // Total Cost

    let costCell = row.insertCell();

    costCell.innerHTML = "0";


    // Delete

    let delCell = row.insertCell();

    let delBtn = document.createElement("button");

    delBtn.innerHTML = "Delete";

    delBtn.onclick = () => { table.deleteRow(row.rowIndex); updateTotals(); };

    delCell.appendChild(delBtn);


    // Load Techstack options

 fetch("?action=getTechstack")

    .then(res => res.json())

    .then(data => {

        techSelect.innerHTML = "";

        let defaultOpt = document.createElement("option");

        defaultOpt.value = "";

        defaultOpt.text = "-- Select Techstack --";

        techSelect.add(defaultOpt);


        data.forEach(val => {

            let opt = document.createElement("option");

            opt.value = val;

            opt.text = val;

            techSelect.add(opt);

        });

    });

//updateGrandTotal();

}


function loadPlatform1(row, tech) {

    fetch("?action=getPlatform&tech="+tech)

        .then(res => res.json())

        .then(data => {

            let platSelect = row.cells[1].children[0];

            platSelect.innerHTML = "";

            data.forEach(val => {

                let opt = document.createElement("option");

                opt.value = val; opt.text = val;

                platSelect.add(opt);

            });

        });

}


function loadPlatform(row, tech) {

    fetch("?action=getPlatform&tech=" + encodeURIComponent(tech))

        .then(res => res.json())

        .then(data => {

            let platSelect = row.cells[1].children[0];

            platSelect.innerHTML = "";


            // Add default option

            let defaultOpt = document.createElement("option");

            defaultOpt.value = "";

            defaultOpt.text = "-- Select Platform --";

            platSelect.add(defaultOpt);


            data.forEach(val => {

                let opt = document.createElement("option");

                opt.value = val;

                opt.text = val;

                platSelect.add(opt);

            });

        });

}



function loadEnv(row, tech, platform) {

    fetch("?action=getEnv&tech=" + encodeURIComponent(tech) + "&platform=" + encodeURIComponent(platform))

        .then(res => res.json())

        .then(data => {

            let envSelect = row.cells[2].children[0];

            envSelect.innerHTML = "";


            let defaultOpt = document.createElement("option");

            defaultOpt.value = "";

            defaultOpt.text = "-- Select Env --";

            envSelect.add(defaultOpt);


            data.forEach(val => {

                let opt = document.createElement("option");

                opt.value = val;

                opt.text = val;

                envSelect.add(opt);

            });

        });

}


function loadSize(row, tech, platform, env) {

    fetch("?action=getSize&tech=" + encodeURIComponent(tech) + "&platform=" + encodeURIComponent(platform) + "&env=" + encodeURIComponent(env))

        .then(res => res.json())

        .then(data => {

            let sizeSelect = row.cells[3].children[0];

            sizeSelect.innerHTML = "";


            let defaultOpt = document.createElement("option");

            defaultOpt.value = "";

            defaultOpt.text = "-- Select Size --";

            sizeSelect.add(defaultOpt);


            data.forEach(val => {

                let opt = document.createElement("option");

                opt.value = val;

                opt.text = val;

                sizeSelect.add(opt);

            });

        });

}


function loadDetails(row, tech, platform, env, size) {

    fetch("?action=getDetails&tech="+tech+"&platform="+platform+"&env="+env+"&size="+size)

        .then(res => res.json())

        .then(data => {

            row.cells[4].innerHTML = data.compute;

            row.cells[5].innerHTML = data.license;

            row.cells[7].innerHTML = data.notes;

            row.dataset.compute = data.compute;

            row.dataset.license = data.license;

            calculateRow(row);

        });

}


// ------------------- CALCULATIONS -------------------

function calculateRow(row) {

    let compute = parseFloat(row.dataset.compute || 0);

    let license = parseFloat(row.dataset.license || 0);

    let units = parseInt(row.cells[6].children[0].value || 1);

    let total = (compute + license) * units;

    row.cells[9].innerHTML = total.toFixed(2);

    updateTotals();

//updateGrandTotal();

}


// Techstacks with one-time license cost



function updateTotals() {

const oneTimeLicenseStacks = ["mongodb", "oracle", "postgresql"];

    let total = 0;

    let hwYears = [0,0,0,0,0];

    let swYears = [0,0,0,0,0];

    let hasOneTimeLicense = false;


    for (let i = 1; i < table.rows.length; i++) {

        let row = table.rows[i];

        let units = parseInt(row.cells[6].children[0]?.value || 1);

        let compute = parseFloat(row.dataset.compute || 0);

        let license = parseFloat(row.dataset.license || 0);


        let techstack = row.cells[0].children[0]?.value?.toLowerCase() || "";


        total += parseFloat(row.cells[9].innerHTML || 0);


        // HW always recurring

        for (let y = 0; y < 5; y++) {

            hwYears[y] += compute * units;

        }


        // SW depends on techstack list

        if (oneTimeLicenseStacks.includes(techstack)) {

            swYears[0] += license * units;

            hasOneTimeLicense = true;

        } else {

            for (let y = 0; y < 5; y++) {

                swYears[y] += license * units;

            }

        }

    }


    grandTotal.innerHTML = `Grand Total: ${total.toFixed(0)} | HW: ${hwYears.reduce((a,b)=>a+b,0).toFixed(0)} | SW: ${swYears.reduce((a,b)=>a+b,0).toFixed(0)}`;


    generateCAPEX(hwYears, swYears, hasOneTimeLicense);

}



function generateCAPEX(hwYears, swYears, hasOneTimeLicense=false) {

    let capexTable = document.getElementById("capexTable");

    capexTable.innerHTML = "";


    // Header

    let headerRow = capexTable.insertRow();

    headerRow.insertCell().innerHTML = "Cost Type";

    for (let year = 1; year <= 5; year++) {

        headerRow.insertCell().innerHTML = `Year ${year}`;

    }

    headerRow.insertCell().innerHTML = "Grand Total (5 yrs)";


    // HW row

    let hwRow = capexTable.insertRow();

    hwRow.insertCell().innerHTML = "HW Cost";

    let hwTotal = 0;

    for (let y = 0; y < 5; y++) {

        hwRow.insertCell().innerHTML = hwYears[y].toFixed(0);

        hwTotal += hwYears[y];

    }

    hwRow.insertCell().innerHTML = hwTotal.toFixed(0);


    // SW row

    let swRow = capexTable.insertRow();

    swRow.insertCell().innerHTML = "SW Cost";

    let swTotal = 0;

    for (let y = 0; y < 5; y++) {

        let cell = swRow.insertCell();

        cell.innerHTML = swYears[y].toFixed(0);


        // Highlight Year 1 if one-time license

        if (hasOneTimeLicense && y === 0) {

            cell.classList.add("one-time-license");

        }

        swTotal += swYears[y];

    }

    swRow.insertCell().innerHTML = swTotal.toFixed(0);


    // Total row

    let totalRow = capexTable.insertRow();

    totalRow.classList.add("grand-total");

    totalRow.insertCell().innerHTML = "Total";

    let grandTotal = 0;

    for (let y = 0; y < 5; y++) {

        let val = hwYears[y] + swYears[y];

        totalRow.insertCell().innerHTML = val.toFixed(0);

        grandTotal += val;

    }

    totalRow.insertCell().innerHTML = grandTotal.toFixed(0);

}



// ------------------- EXPORT TO CSV -------------------


function exportCSV() {

    let csv = [];


    // ---------------- Estimator Table ----------------

    let estTable = document.getElementById("estimatorTable");

    let estRows = estTable.querySelectorAll("tr");


    estRows.forEach(row => {

        let cols = row.querySelectorAll("th, td");

        let rowData = [];

        cols.forEach((col, idx) => {

            // Skip the last column (Delete button)

            if (idx === cols.length - 1) return;


            let text = "";


            // Handle dropdowns

            if (col.querySelector("select")) {

                let sel = col.querySelector("select");

                text = sel.options[sel.selectedIndex]?.text || "";

            }

            // Handle inputs

            else if (col.querySelector("input")) {

                text = col.querySelector("input").value;

            }

            // Otherwise plain text

            else {

                text = col.innerText.trim();

            }


            text = '"' + text.replace(/"/g, '""') + '"';

            rowData.push(text);

        });

        csv.push(rowData.join(","));

    });


    // ---------------- CAPEX Table ----------------

    csv.push(""); // Blank line separator

    csv.push("CAPEX Projection");


    let capexTable = document.getElementById("capexTable");

    let capexRows = capexTable.querySelectorAll("tr");


    capexRows.forEach(row => {

        let cols = row.querySelectorAll("th, td");

        let rowData = [];

        cols.forEach(col => {

            let text = col.innerText.trim();

            text = '"' + text.replace(/"/g, '""') + '"';

            rowData.push(text);

        });

        csv.push(rowData.join(","));

    });


    // ---------------- Branded Footer ----------------

    // csv.push("");

    // csv.push('"Developed by Dilip"');


    // ---------------- Download ----------------

    let csvString = csv.join("\n");

    let blob = new Blob([csvString], { type: "text/csv;charset=utf-8;" });

    let link = document.createElement("a");

    link.href = URL.createObjectURL(blob);

    link.download = "estimator_with_capex.csv";

    document.body.appendChild(link);

    link.click();

    document.body.removeChild(link);

}


function updateGrandTotal() {

    let table = document.getElementById("estimatorTable");

    let rows = table.querySelectorAll("tr");


    let hwSum = 0, swSum = 0;


    // Loop through rows to accumulate HW and SW

    rows.forEach((row, idx) => {

        if (idx === 0) return; // skip header

        let computeCell = row.cells[4]; // HW

        let licenseCell = row.cells[5]; // SW


        let hwVal = parseFloat(computeCell.innerText || computeCell.querySelector("input")?.value || 0);

        let swVal = parseFloat(licenseCell.innerText || licenseCell.querySelector("input")?.value || 0);


        hwSum += hwVal || 0;

        swSum += swVal || 0;

    });


    // Remove old Grand Total row if exists

    let lastRow = table.rows[table.rows.length - 1];

    if (lastRow && lastRow.classList.contains("grand-total")) {

        table.deleteRow(table.rows.length - 1);

    }


    // Add new Grand Total row

    let totalRow = table.insertRow();

    totalRow.classList.add("grand-total");


    let cell = totalRow.insertCell();

    cell.colSpan = 4;

    cell.innerHTML = "<b>Grand Total</b>";


    let hwCell = totalRow.insertCell();

    hwCell.innerHTML = hwSum.toFixed(2);


    let swCell = totalRow.insertCell();

    swCell.innerHTML = swSum.toFixed(2);


    let totalCell = totalRow.insertCell();

    totalCell.colSpan = 4;

    totalCell.innerHTML = "<b>" + (hwSum + swSum).toFixed(2) + "</b>";

}



</script>

</body>

</html>





///   PHP for Deliverables



<?php

if ($_SERVER['REQUEST_METHOD'] === 'POST') {

    $projectName = $_POST['projectName'];

    $wrNumber = $_POST['wrNumber'];

$region = $_POST['region'];

    $spLocation = rtrim($_POST['spLocation'], '/');

    $templatePath = rtrim($_POST['templatePath'], '/');

    $targetPath = rtrim($_POST['targetPath'], '/');


    // File names with format

    $bomFile = "$wrNumber-BOM-$projectName-$region-v1.0.xlsx";

    $taddFile = "$wrNumber-TADD-$projectName-$region-v1.0.xlsx";

    $nfrFile = "$wrNumber-NFR-$projectName-$region-v1.0.xlsx";

    $solutionFile = "$wrNumber-SolutionPaper-$projectName-$region-v1.0.pptx";

    $message = "";


    if (isset($_POST['copyTemplate'])) {

        // BOM

        if (file_exists("$templatePath/BOM.xlsb")) {

            copy("$templatePath/BOM.xlsb", "$targetPath/$bomFile");

            $message .= "✔ BOM copied successfully.<br>";

        } else {

            $message .= "⚠ BOM.xlsb not found.<br>";

        }


        // TADD

        if (file_exists("$templatePath/TADD.xlsx")) {

            copy("$templatePath/TADD.xlsx", "$targetPath/$taddFile");

            $message .= "✔ TADD copied successfully.<br>";

        } else {

            $message .= "⚠ TADD.xlsx not found.<br>";

        }


        // NFR

        if (file_exists("$templatePath/NFR.xlsx")) {

            copy("$templatePath/NFR.xlsx", "$targetPath/$nfrFile");

            $message .= "✔ NFR copied successfully.<br>";

        } else {

            $message .= "⚠ NFR.xlsx not found.<br>";

        }


        // Solution Paper

        if (file_exists("$templatePath/SolutionPaper.pptx")) {

            copy("$templatePath/SolutionPaper.pptx", "$targetPath/$solutionFile");

            $message .= "✔ Solution Paper copied successfully.<br>";

        } else {

            $message .= "⚠ SolutionPaper.pptx not found.<br>";

        }

    }


if (isset($_POST['pushSP'])) {

    $pushedFiles = [];


    // BOM

    if (file_exists("$targetPath/$bomFile")) {

        copy("$targetPath/$bomFile", "$spLocation/$bomFile");

        $message .= "✔ BOM pushed to SharePoint.<br>";

        $pushedFiles[] = $bomFile;

    } else {

        $message .= "⚠ BOM file not found in Target Path.<br>";

    }


    // TADD

    if (file_exists("$targetPath/$taddFile")) {

        copy("$targetPath/$taddFile", "$spLocation/$taddFile");

        $message .= "✔ TADD pushed to SharePoint.<br>";

        $pushedFiles[] = $taddFile;

    } else {

        $message .= "⚠ TADD file not found in Target Path.<br>";

    }


    // NFR

    if (file_exists("$targetPath/$nfrFile")) {

        copy("$targetPath/$nfrFile", "$spLocation/$nfrFile");

        $message .= "✔ NFR pushed to SharePoint.<br>";

        $pushedFiles[] = $nfrFile;

    } else {

        $message .= "⚠ NFR file not found in Target Path.<br>";

    }


    // Solution Paper

    if (file_exists("$targetPath/$solutionFile")) {

        copy("$targetPath/$solutionFile", "$spLocation/$solutionFile");

        $message .= "✔ Solution Paper pushed to SharePoint.<br>";

        $pushedFiles[] = $solutionFile;

    } else {

        $message .= "⚠ Solution Paper file not found in Target Path.<br>";

    }

}


}

?>



<!DOCTYPE html>

<html>

<head>

    <title>Infra Deliver - CAPEX Tool</title>

    <style>

        body {

            font-family: Arial, sans-serif;

            background: #f4f6f9;

            margin: 0;

            padding: 20px;

        }

        h1 {

            background: #2c3e50;

            color: #fff;

            padding: 15px;

            border-radius: 6px;

            text-align: center;

        }

        form {

            background: #fff;

            padding: 20px;

            border-radius: 8px;

            box-shadow: 0 2px 8px rgba(0,0,0,0.1);

            max-width: 600px;

            margin: 20px auto;

        }

        label {

            display: block;

            margin: 12px 0 6px;

            font-weight: bold;

            color: #2c3e50;

        }

        input[type="text"] {

            width: 100%;

            padding: 10px;

            border: 1px solid #ccc;

            border-radius: 6px;

            font-size: 14px;

        }

        .buttons {

            margin-top: 20px;

            display: flex;

            justify-content: space-between;

        }

        button {

            padding: 12px 20px;

            border: none;

            border-radius: 6px;

            font-size: 14px;

            cursor: pointer;

            transition: 0.3s;

        }

        button.copy {

            background: #3498db;

            color: #fff;

        }

        button.copy:hover {

            background: #2980b9;

        }

        button.push {

            background: #27ae60;

            color: #fff;

        }

        button.push:hover {

            background: #1e8449;

        }

        .message {

            margin-top: 20px;

            padding: 12px;

            background: #ecf0f1;

            border-left: 5px solid #3498db;

            border-radius: 4px;

            font-weight: bold;

            color: #2c3e50;

        }

.message {

    margin-top: 20px;

    padding: 12px;

    border-radius: 6px;

    font-weight: bold;

    font-size: 14px;

    line-height: 1.5;

}


.message.success {

    background: #eafaf1;

    border-left: 5px solid #27ae60;

    color: #1e8449;

}


.message.warning {

    background: #fff3cd;

    border-left: 5px solid #f39c12;

    color: #856404;

}


.sp-table {

    border-collapse: collapse;

    width: 100%;

    margin-top: 20px;

    font-family: Arial, sans-serif;

    font-size: 14px;

    background-color: #fff;

    border-radius: 6px;

    overflow: hidden;

    box-shadow: 0 2px 6px rgba(0,0,0,0.1);

}


.sp-table th {

    background-color: #2c3e50;

    color: #fff;

    padding: 10px;

    text-align: center;

}


.sp-table td {

    border: 1px solid #ddd;

    padding: 10px;

    text-align: center;

}


.sp-table tr:nth-child(even) {

    background-color: #f9f9f9;

}


.sp-table tr:hover {

    background-color: #f1f7fd;

}



    </style>

</head>

<body>

    <h1>Infra Delivery - Template Manager</h1>

   <form method="post">

    <label>Project Name</label>

    <input type="text" name="projectName" value="<?php echo htmlspecialchars($_POST['projectName'] ?? ''); ?>" required>


    <label>WR Number</label>

    <input type="text" name="wrNumber" value="<?php echo htmlspecialchars($_POST['wrNumber'] ?? ''); ?>" required>


<label>Region OR Country</label>

    <input type="text" name="region" value="<?php echo htmlspecialchars($_POST['region'] ?? ''); ?>" required>

    <label>SharePoint Location</label>

    <input type="text" name="spLocation" value="<?php echo htmlspecialchars($_POST['spLocation'] ?? ''); ?>" required>


    <label>Template Path</label>

    <input type="text" name="templatePath" value="<?php echo htmlspecialchars($_POST['templatePath'] ?? ''); ?>" required>


    <label>Target Local Path</label>

    <input type="text" name="targetPath" value="<?php echo htmlspecialchars($_POST['targetPath'] ?? ''); ?>" required>


    <div class="buttons">

        <button type="submit" name="copyTemplate" class="copy">Copy Template</button>

        <button type="submit" name="pushSP" class="push">Push to SP</button>

    </div>


    <?php if (!empty($message)): ?>

        <div class="message <?php echo (strpos($message, '⚠') !== false) ? 'warning' : 'success'; ?>">

            <?php echo $message; ?>

        </div>

    <?php endif; ?>

</form>


<?php if (!empty($pushedFiles)): ?>

    <h2>Pushed Files</h2>

    <table class="sp-table">

        <tr>

            <th>File</th>

            <th>SharePoint Link</th>

        </tr>

        <?php foreach ($pushedFiles as $file): 

            $fileNameNoExt = pathinfo($file, PATHINFO_FILENAME);

            $fileUrl = $spLocation . "/" . $file;

        ?>

        <tr>

            <td><?php echo $file; ?></td>

            <td><a href="<?php echo $fileUrl; ?>" target="_blank"><?php echo $fileNameNoExt; ?></a></td>

        </tr>

        <?php endforeach; ?>

    </table>

<?php endif; ?>



</body>

</html>

No comments:

Post a Comment