Snippets Collections
print('Hello World')
import React, { useState, useEffect } from 'react'
import * as XLSX from 'xlsx';
import axios from 'axios';

import { HiArrowSmRight, HiArrowSmDown } from "react-icons/hi";
import { FaDownload, FaTimes } from "react-icons/fa";
import { FaArrowLeft } from "react-icons/fa";


import { useNavigate } from 'react-router-dom';
import Apis from '../../../APIs';

import StyledWrapperRed from '../Ticketing/StyledWrapperRed';

const PipeStockReport = () => {

    const [data, setData] = useState([]);
    const [thicknesses, setThicknesses] = useState([]);
    const [sizes, setSizes] = useState([]);
    const [stockAgingData, setStockAgingData] = useState([]);

    const [weightUnit, setWeightUnit] = useState("MT");

    const [dateRange, setDateRange] = useState({
        startDate: null,
        endDate: null,
    });


    const [loading, setLoading] = useState(true); // Add loading state
    const navigate = useNavigate();

    const [reportType, setReportType] = useState("weight");
    const [selectedReport, setSelectedReport] = useState("stock");

    //for showing User Name :
    const [userModalOpen, setUserModalOpen] = useState(false);
    const [selectedUserName, setSelectedUserName] = useState("");

    const [showAvailablePipes, setShowAvailablePipes] = useState(false);

    // Fetch data from the backend
    useEffect(() => {
        const fetchData = async () => {
            try {
                setLoading(true);

                const endpoint = Apis.PIPE_STOCK;

                let response;

                if (selectedReport === "stock") {
                    if (dateRange.startDate && dateRange.endDate) {
                        // Fetch data based on date range
                        response = await axios.get(endpoint, {
                            params: {
                                startDate: dateRange.startDate,
                                endDate: dateRange.endDate,
                            },
                        });
                    } else {
                        // Fetch all data if no date range is selected
                        response = await axios.get(endpoint);
                        // console.log("Hr Stock : ", response.data);
                    }

                    const backendData = response.data;

                    // Extract unique thicknesses and sizes
                    const thicknessList = backendData.map((item) => item.pipeLotThickness);

                    const sizeList = [
                        ...new Set(
                            backendData.flatMap((item) => item.pipeLotSizes.map((sizeObj) => sizeObj.pipeLotSize))
                        ),
                    ];

                    setData(backendData);
                    setThicknesses(thicknessList);
                    setSizes(sizeList);


                } else {
                    // Fetch Stock Aging Report Data
                    const agingApiUrl = Apis.PIPE_AGING;
                    response = dateRange.startDate && dateRange.endDate
                        ? await axios.get(agingApiUrl, { params: { startDate: dateRange.startDate, endDate: dateRange.endDate } })
                        : await axios.get(agingApiUrl);

                    setStockAgingData(response.data);
                    // console.log("Hr Stock Aging:", response.data);
                }
            } catch (error) {
                console.error('Error fetching data:', error);
            } finally {
                setLoading(false);
            }
        };

        fetchData();
    }, [dateRange, selectedReport]);

    const handleDateChange = (event) => {
        const { name, value } = event.target;

        setDateRange((prev) => ({
            ...prev,
            [name]: value,
        }));
    };

    const clearDateRange = () => {
        setDateRange({ startDate: null, endDate: null });
    };

    // Fetch User Details
    const fetchUserNameByID = async (_id) => {
        setLoading(true);
        try {
            const response = await axios.get(
                `${Apis.FIND_USER_NAME}/${_id}`
            );

            // console.log(response.data);

            if (response.data) {
                setSelectedUserName(response.data);
                setUserModalOpen(true);
            }
        } catch (error) {
            console.error("Error fetching user name details:", error);
        } finally {
            setLoading(false);
        }
    };

    // Generate table content orders:
    const generateTableContent = () => {
        return sizes.map((size) => (
            <tr key={size}>
                {/* Size as the first column */}
                <td className="border border-gray-300 px-2 py-1 text-center bg-gray-100 font-medium">
                    {size}
                </td>

                {/* Map thicknesses to find matching quantities */}
                {thicknesses.map((thick) => {
                    const matchingItem = data
                        .find((item) => item.pipeLotThickness === thick)
                        ?.pipeLotSizes.find((sizeObj) => sizeObj.pipeLotSize === size);

                    let displayValue = "-"; // Default if no matching data

                    if (matchingItem) {
                        if (reportType === "weight") {
                            displayValue = weightUnit === "MT"
                                ? (matchingItem.lotWeight / 1000).toFixed(2)
                                : matchingItem.lotWeight.toFixed(2);
                        } else {
                            displayValue = matchingItem.noOfPipes; // Display No. of Pipes
                        }
                    }

                    return (
                        <td
                            key={thick}
                            className="border border-gray-300 px-2 py-1 text-center text-sm"
                        >

                            {displayValue || "-"}
                        </td>
                    );
                })}
            </tr>
        ));
    };

    // Generate Table Content for Stock Aging Report
    const generateStockAgingTableContent = () => {
        return stockAgingData.filter(item => showAvailablePipes ? item.noOfPipe > 0 : true).map((item) => (
            <tr key={item._id}>
                {/* <td className="border border-gray-300 px-2 py-1 text-center">{item._id}</td>
                <td className="border border-gray-300 px-2 py-1 text-center">{item.uniqueId}</td> */}
                <td className="border border-gray-300 px-2 py-1 text-center">{item.pipeSize}</td>
                <td className="border border-gray-300 px-2 py-1 text-center">{item.msgi}</td>
                <td className="border border-gray-300 px-2 py-1 text-center">{item.length}</td>
                <td className="border border-gray-300 px-2 py-1 text-center">{item.pipeIs}</td>
                <td className="border border-gray-300 px-2 py-1 text-center">{item.grade}</td>
                <td className="border border-gray-300 px-2 py-1 text-center">{item.thickness}</td>
                <td className="border border-gray-300 px-2 py-1 text-center">{item.noOfPipe}</td>
                <td className="border border-gray-300 px-2 py-1 text-center">{(weightUnit === "MT" ? (item.weight / 1000).toFixed(2) : item.weight)}</td>
                <td className="border border-gray-300 px-2 py-1 text-center">{(weightUnit === "MT" ? (item.unitWeight / 1000).toFixed(5) : item.unitWeight)}</td>
                <td className="border border-gray-300 px-2 py-1 text-center">{item.pipeStatus}</td>
                <td className="border border-gray-300 px-2 py-1 text-center">{item.pipeClass}</td>
                {/* <td className="border border-gray-300 px-2 py-1 text-center">{item.division}</td> */}
                <td className="border border-gray-300 px-2 py-1 text-center">{item.endType}</td>
                <td className="border border-gray-300 px-2 py-1 text-center">{item.vwv}</td>
                <td className="border border-gray-300 px-2 py-1 text-center">{item.pipeType}</td>
                <td className="border border-gray-300 px-2 py-1 text-center">{(weightUnit === "MT" ? (item.weightPerPc / 1000).toFixed(5) : item.weightPerPc)}</td>
                {/* <td className="border border-gray-300 px-2 py-1 text-center">
                    {item.pipeLotModelList.length > 0 ? (
                        <ul className="list-none">
                            {item.pipeLotModelList.map((lot, index) => (
                                <li key={index} className="text-xs text-gray-600">{lot}</li>
                            ))}
                        </ul>
                    ) : "-"}
                </td> */}
                <td className="border border-gray-300 px-2 py-1 text-center font-semibold text-emerald-500 cursor-pointer hover:underline" onClick={(e) => {
                    e.stopPropagation();
                    fetchUserNameByID(item.createdBy);
                }}> {item.createdBy} </td>

                <td className="border border-gray-300 px-2 py-1 text-center">{new Date(new Date(item.createdAt).getTime() + 330 * 60000).toLocaleString("en-GB", {
                    day: "2-digit",
                    month: "2-digit",
                    year: "numeric",
                    hour: "2-digit",
                    minute: "2-digit",
                    second: "2-digit",
                    hour12: true,
                })}</td>

                <td className="border border-gray-300 px-2 py-1 text-center">{new Date(new Date(item.updatedAt).getTime() + 330 * 60000).toLocaleString("en-GB", {
                    day: "2-digit",
                    month: "2-digit",
                    year: "numeric",
                    hour: "2-digit",
                    minute: "2-digit",
                    second: "2-digit",
                    hour12: true,
                })}</td>

                {/* Lot Age Calculation */}
                <td className="border border-gray-300 px-2 py-1 text-center">
                    {(() => {
                        const createdAt = new Date(item.createdAt);
                        const updatedAt = new Date(item.updatedAt);
                        const diffMs = updatedAt - createdAt;

                        const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
                        const diffHours = Math.floor((diffMs % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
                        const diffMinutes = Math.floor((diffMs % (1000 * 60 * 60)) / (1000 * 60));

                        return `${diffDays}d ${diffHours}h ${diffMinutes}m`;
                    })()}
                </td>
            </tr>
        ));
    };

    // Function to download the table as an Excel file
    const downloadExcel = () => {

        // Prepare the data for Excel
        const headerRow = ['Pipe Size / Thickness', ...thicknesses]; // Add Thicknesses as header
        const excelData = [
            headerRow, // Add header row
            ...sizes.map((size) => [
                size, // Add the size as the first column
                ...thicknesses.map((thick) => {
                    const matchingItem = data
                        .find((item) => item.pipeLotThickness === thick)
                        ?.pipeLotSizes.find((sizeObj) => sizeObj.pipeLotSize === size);
                    // return matchingItem ? matchingItem.quantityInMt : '-'; // Populate quantity or empty value

                    if (matchingItem) {
                        if (reportType === "weight") {
                            // Convert to MT if selected
                            return weightUnit === "MT"
                                ? (matchingItem.lotWeight / 1000).toFixed(2) // Convert to MT
                                : matchingItem.lotWeight.toFixed(2); // Keep in KG
                        } else {
                            return matchingItem.noOfPipes; // Return No. of Pipes
                        }
                    }

                    return '-';
                }),
            ]),
        ];

        // Create a worksheet and workbook
        const worksheet = XLSX.utils.aoa_to_sheet(excelData);
        const workbook = XLSX.utils.book_new();
        XLSX.utils.book_append_sheet(
            workbook,
            worksheet,
            `Slit Stock Report`
        );

        // Set the file name dynamically
        const fileName = reportType === "weight"
            ? `Slit Stock (Weight Report) (${weightUnit}).xlsx`
            : `Slit Stock (No. of Pipes Report).xlsx`;

        // Write the workbook to an Excel file
        XLSX.writeFile(workbook, fileName);
    };

    const downloadStockAgingExcel = () => {
        if (stockAgingData.length === 0) {
            alert("No data available to download.");
            return;
        }

        // Define the headers
        const headers = [
            "Pipe Size", "MsGi", "Length", "Pipe IS", "Grade", "Thickness", "No. of Pipe",
            "Weight", "Unit Weight", "Pipe Status", "Pipe Class", "End Type", "VWV",
            "Pipe Type", "Weight Per Pc", "Created By", "Created At", "Updated At", "Lot Age"
        ];

        // Map the data into an array format for Excel
        const excelData = stockAgingData
            .filter(item => showAvailablePipes ? item.noOfPipe > 0 : true) // Apply filter based on toggle
            .map((item) => {
                const createdAt = new Date(new Date(item.createdAt).getTime() + 330 * 60000).toLocaleString("en-GB", {
                    day: "2-digit", month: "2-digit", year: "numeric",
                    hour: "2-digit", minute: "2-digit", second: "2-digit", hour12: true
                });

                const updatedAt = new Date(new Date(item.updatedAt).getTime() + 330 * 60000).toLocaleString("en-GB", {
                    day: "2-digit", month: "2-digit", year: "numeric",
                    hour: "2-digit", minute: "2-digit", second: "2-digit", hour12: true
                });

                // Calculate Lot Age
                const diffMs = new Date(item.updatedAt) - new Date(item.createdAt);
                const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
                const diffHours = Math.floor((diffMs % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
                const diffMinutes = Math.floor((diffMs % (1000 * 60 * 60)) / (1000 * 60));
                const lotAge = `${diffDays}d ${diffHours}h ${diffMinutes}m`;

                return [
                    item.pipeSize, item.msgi, item.length, item.pipeIs, item.grade, item.thickness, item.noOfPipe,
                    weightUnit === "MT" ? (item.weight / 1000).toFixed(2) : item.weight,
                    weightUnit === "MT" ? (item.unitWeight / 1000).toFixed(5) : item.unitWeight,
                    item.pipeStatus, item.pipeClass, item.endType, item.vwv,
                    item.pipeType, weightUnit === "MT" ? (item.weightPerPc / 1000).toFixed(5) : item.weightPerPc,
                    item.createdBy, createdAt, updatedAt, lotAge
                ];
            });

        // Create a worksheet and workbook
        const worksheet = XLSX.utils.aoa_to_sheet([headers, ...excelData]);
        const workbook = XLSX.utils.book_new();
        XLSX.utils.book_append_sheet(workbook, worksheet, "Stock Aging Report");

        // Set the file name dynamically
        const fileName = `Stock_Aging_Report_${weightUnit}.xlsx`;

        // Write and download the Excel file
        XLSX.writeFile(workbook, fileName);
    };


    return (
        <>

            <div className="flex flex-col items-center bg-gray-50 min-h-screen">

                <header className="w-full bg-red-500 text-white py-6">
                    <div className="container mx-auto flex items-center justify-between px-4 relative">
                        {/* Back Button - Visible Only on Mobile */}
                        <button
                            onClick={() => navigate(-1)}
                            className="lg:hidden absolute left-1 flex items-center gap-2 px-4 py-2 rounded-lg shadow hover:bg-green-100 transition"
                        >
                            <FaArrowLeft className="text-lg" />
                        </button>

                        {/* Centered Heading */}
                        <div className="flex-grow text-center">
                            <h1 className="text-3xl font-bold"> Pipe Stock Report </h1>
                            <p className="text-sm mt-2">A detailed Pipe stock report table</p>
                        </div>
                    </div>
                </header>

                {/* Radio Button for Report Selection */}
                <div className="mt-6 mb-4 flex justify-center">
                    <div className="bg-white shadow-lg rounded-xl p-2 flex space-x-2">
                        <label
                            className={`relative flex items-center justify-center px-6 py-3 rounded-lg cursor-pointer transition-all duration-200 ${selectedReport === "stock"
                                ? "bg-red-500 text-white font-bold shadow-md"
                                : "bg-gray-100 text-gray-700 hover:bg-gray-200"
                                }`}
                        >
                            <input
                                type="radio"
                                value="stock"
                                checked={selectedReport === "stock"}
                                onChange={() => setSelectedReport("stock")}
                                className="absolute opacity-0"
                            />
                            <div className="flex items-center">
                                {selectedReport === "stock" && (
                                    <div className="absolute -left-1 -top-1 w-3 h-3 bg-red-500 rounded-full animate-ping"></div>
                                )}
                                <span className="flex items-center">
                                    <svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                        <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z" />
                                    </svg>
                                    Pipe Stock Report
                                </span>
                            </div>
                        </label>

                        <label
                            className={`relative flex items-center justify-center px-6 py-3 rounded-lg cursor-pointer transition-all duration-200 ${selectedReport === "aging"
                                ? "bg-red-500 text-white font-bold shadow-md"
                                : "bg-gray-100 text-gray-700 hover:bg-gray-200"
                                }`}
                        >
                            <input
                                type="radio"
                                value="aging"
                                checked={selectedReport === "aging"}
                                onChange={() => setSelectedReport("aging")}
                                className="absolute opacity-0"
                            />
                            <div className="flex items-center">
                                {selectedReport === "aging" && (
                                    <div className="absolute -left-1 -top-1 w-3 h-3 bg-red-500 rounded-full animate-ping"></div>
                                )}
                                <span className="flex items-center">
                                    <svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
                                        <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z" />
                                    </svg>
                                    Stock Aging Report
                                </span>
                            </div>
                        </label>
                    </div>
                </div>

                {loading ?
                    (
                        <StyledWrapperRed className='mt-auto'>
                            <div className="loader">
                                <div>
                                    <ul>
                                        <li>
                                            <svg fill="currentColor" viewBox="0 0 90 120">
                                                <path d="M90,0 L90,120 L11,120 C4.92486775,120 0,115.075132 0,109 L0,11 C0,4.92486775 4.92486775,0 11,0 L90,0 Z M71.5,81 L18.5,81 C17.1192881,81 16,82.1192881 16,83.5 C16,84.8254834 17.0315359,85.9100387 18.3356243,85.9946823 L18.5,86 L71.5,86 C72.8807119,86 74,84.8807119 74,83.5 C74,82.1745166 72.9684641,81.0899613 71.6643757,81.0053177 L71.5,81 Z M71.5,57 L18.5,57 C17.1192881,57 16,58.1192881 16,59.5 C16,60.8254834 17.0315359,61.9100387 18.3356243,61.9946823 L18.5,62 L71.5,62 C72.8807119,62 74,60.8807119 74,59.5 C74,58.1192881 72.8807119,57 71.5,57 Z M71.5,33 L18.5,33 C17.1192881,33 16,34.1192881 16,35.5 C16,36.8254834 17.0315359,37.9100387 18.3356243,37.9946823 L18.5,38 L71.5,38 C72.8807119,38 74,36.8807119 74,35.5 C74,34.1192881 72.8807119,33 71.5,33 Z" />
                                            </svg>
                                        </li>
                                        <li>
                                            <svg fill="currentColor" viewBox="0 0 90 120">
                                                <path d="M90,0 L90,120 L11,120 C4.92486775,120 0,115.075132 0,109 L0,11 C0,4.92486775 4.92486775,0 11,0 L90,0 Z M71.5,81 L18.5,81 C17.1192881,81 16,82.1192881 16,83.5 C16,84.8254834 17.0315359,85.9100387 18.3356243,85.9946823 L18.5,86 L71.5,86 C72.8807119,86 74,84.8807119 74,83.5 C74,82.1745166 72.9684641,81.0899613 71.6643757,81.0053177 L71.5,81 Z M71.5,57 L18.5,57 C17.1192881,57 16,58.1192881 16,59.5 C16,60.8254834 17.0315359,61.9100387 18.3356243,61.9946823 L18.5,62 L71.5,62 C72.8807119,62 74,60.8807119 74,59.5 C74,58.1192881 72.8807119,57 71.5,57 Z M71.5,33 L18.5,33 C17.1192881,33 16,34.1192881 16,35.5 C16,36.8254834 17.0315359,37.9100387 18.3356243,37.9946823 L18.5,38 L71.5,38 C72.8807119,38 74,36.8807119 74,35.5 C74,34.1192881 72.8807119,33 71.5,33 Z" />
                                            </svg>
                                        </li>
                                        <li>
                                            <svg fill="currentColor" viewBox="0 0 90 120">
                                                <path d="M90,0 L90,120 L11,120 C4.92486775,120 0,115.075132 0,109 L0,11 C0,4.92486775 4.92486775,0 11,0 L90,0 Z M71.5,81 L18.5,81 C17.1192881,81 16,82.1192881 16,83.5 C16,84.8254834 17.0315359,85.9100387 18.3356243,85.9946823 L18.5,86 L71.5,86 C72.8807119,86 74,84.8807119 74,83.5 C74,82.1745166 72.9684641,81.0899613 71.6643757,81.0053177 L71.5,81 Z M71.5,57 L18.5,57 C17.1192881,57 16,58.1192881 16,59.5 C16,60.8254834 17.0315359,61.9100387 18.3356243,61.9946823 L18.5,62 L71.5,62 C72.8807119,62 74,60.8807119 74,59.5 C74,58.1192881 72.8807119,57 71.5,57 Z M71.5,33 L18.5,33 C17.1192881,33 16,34.1192881 16,35.5 C16,36.8254834 17.0315359,37.9100387 18.3356243,37.9946823 L18.5,38 L71.5,38 C72.8807119,38 74,36.8807119 74,35.5 C74,34.1192881 72.8807119,33 71.5,33 Z" />
                                            </svg>
                                        </li>
                                        <li>
                                            <svg fill="currentColor" viewBox="0 0 90 120">
                                                <path d="M90,0 L90,120 L11,120 C4.92486775,120 0,115.075132 0,109 L0,11 C0,4.92486775 4.92486775,0 11,0 L90,0 Z M71.5,81 L18.5,81 C17.1192881,81 16,82.1192881 16,83.5 C16,84.8254834 17.0315359,85.9100387 18.3356243,85.9946823 L18.5,86 L71.5,86 C72.8807119,86 74,84.8807119 74,83.5 C74,82.1745166 72.9684641,81.0899613 71.6643757,81.0053177 L71.5,81 Z M71.5,57 L18.5,57 C17.1192881,57 16,58.1192881 16,59.5 C16,60.8254834 17.0315359,61.9100387 18.3356243,61.9946823 L18.5,62 L71.5,62 C72.8807119,62 74,60.8807119 74,59.5 C74,58.1192881 72.8807119,57 71.5,57 Z M71.5,33 L18.5,33 C17.1192881,33 16,34.1192881 16,35.5 C16,36.8254834 17.0315359,37.9100387 18.3356243,37.9946823 L18.5,38 L71.5,38 C72.8807119,38 74,36.8807119 74,35.5 C74,34.1192881 72.8807119,33 71.5,33 Z" />
                                            </svg>
                                        </li>
                                        <li>
                                            <svg fill="currentColor" viewBox="0 0 90 120">
                                                <path d="M90,0 L90,120 L11,120 C4.92486775,120 0,115.075132 0,109 L0,11 C0,4.92486775 4.92486775,0 11,0 L90,0 Z M71.5,81 L18.5,81 C17.1192881,81 16,82.1192881 16,83.5 C16,84.8254834 17.0315359,85.9100387 18.3356243,85.9946823 L18.5,86 L71.5,86 C72.8807119,86 74,84.8807119 74,83.5 C74,82.1745166 72.9684641,81.0899613 71.6643757,81.0053177 L71.5,81 Z M71.5,57 L18.5,57 C17.1192881,57 16,58.1192881 16,59.5 C16,60.8254834 17.0315359,61.9100387 18.3356243,61.9946823 L18.5,62 L71.5,62 C72.8807119,62 74,60.8807119 74,59.5 C74,58.1192881 72.8807119,57 71.5,57 Z M71.5,33 L18.5,33 C17.1192881,33 16,34.1192881 16,35.5 C16,36.8254834 17.0315359,37.9100387 18.3356243,37.9946823 L18.5,38 L71.5,38 C72.8807119,38 74,36.8807119 74,35.5 C74,34.1192881 72.8807119,33 71.5,33 Z" />
                                            </svg>
                                        </li>
                                        <li>
                                            <svg fill="currentColor" viewBox="0 0 90 120">
                                                <path d="M90,0 L90,120 L11,120 C4.92486775,120 0,115.075132 0,109 L0,11 C0,4.92486775 4.92486775,0 11,0 L90,0 Z M71.5,81 L18.5,81 C17.1192881,81 16,82.1192881 16,83.5 C16,84.8254834 17.0315359,85.9100387 18.3356243,85.9946823 L18.5,86 L71.5,86 C72.8807119,86 74,84.8807119 74,83.5 C74,82.1745166 72.9684641,81.0899613 71.6643757,81.0053177 L71.5,81 Z M71.5,57 L18.5,57 C17.1192881,57 16,58.1192881 16,59.5 C16,60.8254834 17.0315359,61.9100387 18.3356243,61.9946823 L18.5,62 L71.5,62 C72.8807119,62 74,60.8807119 74,59.5 C74,58.1192881 72.8807119,57 71.5,57 Z M71.5,33 L18.5,33 C17.1192881,33 16,34.1192881 16,35.5 C16,36.8254834 17.0315359,37.9100387 18.3356243,37.9946823 L18.5,38 L71.5,38 C72.8807119,38 74,36.8807119 74,35.5 C74,34.1192881 72.8807119,33 71.5,33 Z" />
                                            </svg>
                                        </li>
                                    </ul>
                                </div><span>Loading</span></div>
                        </StyledWrapperRed>
                    ) : (
                        <>
                            <div className="mt-8 mb-6 flex flex-col items-center">
          <div className="w-full max-w-4xl bg-white rounded-xl shadow-lg p-6">
            {/* Toggle Controls */}
            <div className="grid grid-cols-1 md:grid-cols-2 gap-6 mb-6">
              {/* Report Type Toggle */}
              {selectedReport === "stock" && (
                <div className="bg-gray-50 rounded-lg p-4 shadow-sm">
                  <h3 className="text-gray-700 font-medium mb-3 flex items-center">
                    <svg
                      xmlns="http://www.w3.org/2000/svg"
                      className="h-5 w-5 mr-2 text-red-500"
                      viewBox="0 0 20 20"
                      fill="currentColor"
                    >
                      <path d="M2 11a1 1 0 011-1h2a1 1 0 011 1v5a1 1 0 01-1 1H3a1 1 0 01-1-1v-5zm6-4a1 1 0 011-1h2a1 1 0 011 1v9a1 1 0 01-1 1H9a1 1 0 01-1-1V7zm6-3a1 1 0 011-1h2a1 1 0 011 1v12a1 1 0 01-1 1h-2a1 1 0 01-1-1V4z" />
                    </svg>
                    Report Type
                  </h3>
                  <div className="flex items-center justify-between bg-white rounded-lg p-3 shadow-inner">
                    <span
                      className={`text-sm font-medium ${reportType === "pipes" ? "text-red-500" : "text-gray-500"}`}
                    >
                      No. of Pipes
                    </span>
                    <div className="relative mx-3">
                      <label className="flex items-center cursor-pointer">
                        <input
                          type="checkbox"
                          className="sr-only peer"
                          checked={reportType === "weight"}
                          onChange={() => setReportType(reportType === "weight" ? "pipes" : "weight")}
                        />
                        <div className="relative w-14 h-7 bg-gray-200 peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-red-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:bg-red-500 after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-6 after:w-6 after:shadow-md after:transition-all duration-300 ease-in-out"></div>
                      </label>
                      <div
                        className="absolute -top-1 -right-1 w-3 h-3 bg-red-500 rounded-full animate-ping opacity-75"
                        style={{ display: reportType === "weight" ? "block" : "none" }}
                      ></div>
                    </div>
                    <span
                      className={`text-sm font-medium ${reportType === "weight" ? "text-red-500" : "text-gray-500"}`}
                    >
                      Weight
                    </span>
                  </div>
                </div>
              )}

              {/* Weight Unit Toggle */}
              {reportType === "weight" && (
                <div className="bg-gray-50 rounded-lg p-4 shadow-sm">
                  <h3 className="text-gray-700 font-medium mb-3 flex items-center">
                    <svg
                      xmlns="http://www.w3.org/2000/svg"
                      className="h-5 w-5 mr-2 text-red-500"
                      viewBox="0 0 20 20"
                      fill="currentColor"
                    >
                      <path
                        fillRule="evenodd"
                        d="M10 2a1 1 0 011 1v1.323l3.954 1.582 1.599-.8a1 1 0 01.894 1.79l-1.233.616 1.738 5.42a1 1 0 01-.285 1.05A3.989 3.989 0 0115 15a3.989 3.989 0 01-2.667-1.019 1 1 0 01-.285-1.05l1.715-5.349L11 6.477V16h2a1 1 0 110 2H7a1 1 0 110-2h2V6.477L6.237 7.582l1.715 5.349a1 1 0 01-.285 1.05A3.989 3.989 0 015 15a3.989 3.989 0 01-2.667-1.019 1 1 0 01-.285-1.05l1.738-5.42-1.233-.617a1 1 0 01.894-1.788l1.599.799L9 4.323V3a1 1 0 011-1z"
                        clipRule="evenodd"
                      />
                    </svg>
                    Weight Unit
                  </h3>
                  <div className="flex items-center justify-between bg-white rounded-lg p-3 shadow-inner">
                    <span className={`text-sm font-medium ${weightUnit === "Kg" ? "text-red-500" : "text-gray-500"}`}>
                      Kilograms (Kg)
                    </span>
                    <div className="relative mx-3">
                      <label className="flex items-center cursor-pointer">
                        <input
                          type="checkbox"
                          className="sr-only peer"
                          checked={weightUnit === "MT"}
                          onChange={() => setWeightUnit(weightUnit === "Kg" ? "MT" : "Kg")}
                        />
                        <div className="relative w-14 h-7 bg-gray-200 peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-red-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:bg-red-500 after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-6 after:w-6 after:shadow-md after:transition-all duration-300 ease-in-out"></div>
                      </label>
                      <div
                        className="absolute -top-1 -right-1 w-3 h-3 bg-red-500 rounded-full animate-ping opacity-75"
                        style={{ display: weightUnit === "MT" ? "block" : "none" }}
                      ></div>
                    </div>
                    <span className={`text-sm font-medium ${weightUnit === "MT" ? "text-red-500" : "text-gray-500"}`}>
                      Metric Tons (MT)
                    </span>
                  </div>
                </div>
              )}

              {/* Available Pipes Toggle */}
              {selectedReport === "aging" && (
                <div className="bg-gray-50 rounded-lg p-4 shadow-sm">
                  <h3 className="text-gray-700 font-medium mb-3 flex items-center">
                    <svg
                      xmlns="http://www.w3.org/2000/svg"
                      className="h-5 w-5 mr-2 text-red-500"
                      viewBox="0 0 20 20"
                      fill="currentColor"
                    >
                      <path d="M9 2a1 1 0 000 2h2a1 1 0 100-2H9z" />
                      <path
                        fillRule="evenodd"
                        d="M4 5a2 2 0 012-2 3 3 0 003 3h2a3 3 0 003-3 2 2 0 012 2v11a2 2 0 01-2 2H6a2 2 0 01-2-2V5zm3 4a1 1 0 000 2h.01a1 1 0 100-2H7zm3 0a1 1 0 000 2h3a1 1 0 100-2h-3zm-3 4a1 1 0 100 2h.01a1 1 0 100-2H7zm3 0a1 1 0 100 2h3a1 1 0 100-2h-3z"
                        clipRule="evenodd"
                      />
                    </svg>
                    Filter Pipes
                  </h3>
                  <div className="flex items-center justify-between bg-white rounded-lg p-3 shadow-inner">
                    <span className={`text-sm font-medium ${showAvailablePipes ? "text-red-500" : "text-gray-500"}`}>
                      Available Only
                    </span>
                    <div className="relative mx-3">
                      <label className="flex items-center cursor-pointer">
                        <input
                          type="checkbox"
                          className="sr-only peer"
                          checked={!showAvailablePipes}
                          onChange={() => setShowAvailablePipes(!showAvailablePipes)}
                        />
                        <div className="relative w-14 h-7 bg-gray-200 peer-focus:outline-none peer-focus:ring-2 peer-focus:ring-red-300 rounded-full peer peer-checked:after:translate-x-full peer-checked:bg-red-500 after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-6 after:w-6 after:shadow-md after:transition-all duration-300 ease-in-out"></div>
                      </label>
                      <div
                        className="absolute -top-1 -right-1 w-3 h-3 bg-red-500 rounded-full animate-ping opacity-75"
                        style={{ display: !showAvailablePipes ? "block" : "none" }}
                      ></div>
                    </div>
                    <span className={`text-sm font-medium ${!showAvailablePipes ? "text-red-500" : "text-gray-500"}`}>
                      All Pipes
                    </span>
                  </div>
                </div>
              )}
            </div>

            {/* Date Range Picker */}
            {selectedReport === "aging" && (
              <div className="bg-gray-50 rounded-lg p-4 shadow-sm mb-6">
                <h3 className="text-gray-700 font-medium mb-3 flex items-center">
                  <svg
                    xmlns="http://www.w3.org/2000/svg"
                    className="h-5 w-5 mr-2 text-red-500"
                    viewBox="0 0 20 20"
                    fill="currentColor"
                  >
                    <path
                      fillRule="evenodd"
                      d="M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z"
                      clipRule="evenodd"
                    />
                  </svg>
                  Date Range
                </h3>
                <div className="grid grid-cols-1 md:grid-cols-3 gap-4 items-center">
                  <div className="relative">
                    <label htmlFor="datepicker-range-start" className="block text-xs font-medium text-gray-700 mb-1">
                      Start Date
                    </label>
                    <div className="relative">
                      <input
                        id="datepicker-range-start"
                        name="startDate"
                        type="date"
                        value={dateRange.startDate || ""}
                        onChange={handleDateChange}
                        className="bg-white border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-red-500 focus:border-red-500 block w-full pl-10 pr-3 py-2.5 shadow-sm"
                        placeholder="Select start date"
                      />
                      <div className="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none">
                        <svg
                          className="w-5 h-5 text-gray-500"
                          fill="currentColor"
                          viewBox="0 0 20 20"
                          xmlns="http://www.w3.org/2000/svg"
                        >
                          <path
                            fillRule="evenodd"
                            d="M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z"
                            clipRule="evenodd"
                          ></path>
                        </svg>
                      </div>
                    </div>
                  </div>

                  <div className="relative">
                    <label htmlFor="datepicker-range-end" className="block text-xs font-medium text-gray-700 mb-1">
                      End Date
                    </label>
                    <div className="relative">
                      <input
                        id="datepicker-range-end"
                        name="endDate"
                        type="date"
                        value={dateRange.endDate || ""}
                        onChange={handleDateChange}
                        className="bg-white border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-red-500 focus:border-red-500 block w-full pl-10 pr-3 py-2.5 shadow-sm"
                        placeholder="Select end date"
                      />
                      <div className="absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none">
                        <svg
                          className="w-5 h-5 text-gray-500"
                          fill="currentColor"
                          viewBox="0 0 20 20"
                          xmlns="http://www.w3.org/2000/svg"
                        >
                          <path
                            fillRule="evenodd"
                            d="M6 2a1 1 0 00-1 1v1H4a2 2 0 00-2 2v10a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2h-1V3a1 1 0 10-2 0v1H7V3a1 1 0 00-1-1zm0 5a1 1 0 000 2h8a1 1 0 100-2H6z"
                            clipRule="evenodd"
                          ></path>
                        </svg>
                      </div>
                    </div>
                  </div>

                  <div className="flex items-end">
                    <button
                      className="w-full bg-white border border-red-500 text-red-500 hover:bg-red-50 px-4 py-2.5 rounded-lg shadow-sm transition-colors duration-200 flex items-center justify-center"
                      onClick={clearDateRange}
                    >
                      <svg
                        xmlns="http://www.w3.org/2000/svg"
                        className="h-5 w-5 mr-1.5"
                        viewBox="0 0 20 20"
                        fill="currentColor"
                      >
                        <path
                          fillRule="evenodd"
                          d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
                          clipRule="evenodd"
                        />
                      </svg>
                      Clear Range
                    </button>
                  </div>
                </div>

                {/* Date Range Info */}
                <div className="mt-3 text-center">
                  <p className="text-sm text-gray-600 bg-white px-3 py-1.5 rounded-md inline-block shadow-sm">
                    {dateRange.startDate && dateRange.endDate ? (
                      <span className="flex items-center">
                        <svg
                          xmlns="http://www.w3.org/2000/svg"
                          className="h-4 w-4 mr-1 text-red-500"
                          viewBox="0 0 20 20"
                          fill="currentColor"
                        >
                          <path
                            fillRule="evenodd"
                            d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z"
                            clipRule="evenodd"
                          />
                        </svg>
                        Selected Range:{" "}
                        <span className="font-medium ml-1">
                          {dateRange.startDate} - {dateRange.endDate}
                        </span>
                      </span>
                    ) : (
                      <span className="flex items-center">
                        <svg
                          xmlns="http://www.w3.org/2000/svg"
                          className="h-4 w-4 mr-1 text-blue-500"
                          viewBox="0 0 20 20"
                          fill="currentColor"
                        >
                          <path
                            fillRule="evenodd"
                            d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z"
                            clipRule="evenodd"
                          />
                        </svg>
                        Showing All Data
                      </span>
                    )}
                  </p>
                </div>
              </div>
            )}

            {/* Weight Unit Info & Download Button */}
            <div className="flex flex-col sm:flex-row items-center justify-between gap-4 bg-gray-50 rounded-lg p-4 shadow-sm">
              <div className="flex items-center">
                <svg
                  xmlns="http://www.w3.org/2000/svg"
                  className="h-5 w-5 mr-2 text-red-500"
                  viewBox="0 0 20 20"
                  fill="currentColor"
                >
                  <path
                    fillRule="evenodd"
                    d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z"
                    clipRule="evenodd"
                  />
                </svg>
                <span className="font-medium text-gray-700">
                  All weights are in <span className="text-red-500 font-bold">{weightUnit}</span>
                </span>
              </div>

              <button
                onClick={selectedReport === "stock" ? downloadExcel : downloadStockAgingExcel}
                className="group bg-red-500 hover:bg-red-600 text-white font-medium px-6 py-2.5 rounded-lg shadow-lg transition-all duration-200 ease-in-out transform hover:scale-105 active:scale-95 flex items-center justify-center min-w-[180px]"
              >
                <FaDownload className="text-lg mr-2 group-hover:animate-bounce" />
                <span>Download Excel</span>
                <div className="absolute -top-1 -right-1 w-3 h-3 bg-white rounded-full animate-ping opacity-75 hidden group-hover:block"></div>
              </button>
            </div>
          </div>
        </div>


                            {userModalOpen && (
                                <div className="fixed inset-0 flex items-center justify-center bg-gray-900 bg-opacity-50">
                                    <div className="fixed inset-0 bg-opacity-50" onClick={() => setUserModalOpen(false)}></div>
                                    <div className="bg-white rounded-lg shadow-lg p-8 w-96 text-center transform transition-all scale-100">
                                        <div className="flex justify-end">
                                            <button className="text-gray-600 hover:text-gray-800" onClick={() => setUserModalOpen(false)}>
                                                <FaTimes size={20} />
                                            </button>
                                        </div>
                                        <h3 className="text-2xl font-bold text-gray-900 mt-2">User Details</h3>
                                        <p className="text-lg text-gray-700 mt-4">👤 {selectedUserName}</p>

                                        <button
                                            className="mt-6 px-6 py-2 bg-blue-500 text-white font-semibold rounded-md shadow-md hover:bg-blue-700 transition"
                                            onClick={() => setUserModalOpen(false)}>
                                            Close
                                        </button>
                                    </div>
                                </div>
                            )}

                            {/* Main Table */}
                            <main className="container mx-auto py-8">
                                <div className="overflow-auto max-w-full">
                                    <table className="table-auto border-collapse border border-gray-300 mx-auto bg-white shadow-lg">
                                        <thead>
                                            <tr>
                                                {selectedReport === "stock" ? (
                                                    <>
                                                        {/* First column header for "Thickness / Pipe Lot Sizes" */}
                                                        <th className="border border-gray-300 px-4 py-2 text-center bg-gray-200 text-sm font-medium">
                                                            <div className="flex items-center justify-center space-x-2">
                                                                <span>Pipe Lot Thickness</span>
                                                                <HiArrowSmRight className="text-blue-600" />
                                                                <span>/</span>
                                                                <span> Pipe Lot Sizes</span>
                                                                <HiArrowSmDown className="text-blue-600" />
                                                            </div>
                                                        </th>
                                                        {/* Dynamically render column headers for thickness */}
                                                        {thicknesses.map((thick) => (
                                                            <th
                                                                key={thick}
                                                                className="border border-gray-300 px-2 py-1 text-center bg-gray-200 text-sm"
                                                            >
                                                                {thick}
                                                            </th>
                                                        ))}
                                                    </>
                                                ) : (
                                                    <>
                                                        {/* Headers for Stock Aging Report */}
                                                        {/* <th className="border px-4 py-2"> ID </th>
                                                        <th className="border px-4 py-2"> Unique ID</th> */}
                                                        <th className="border px-4 py-2">Pipe Size</th>
                                                        <th className="border px-4 py-2"> MsGi </th>
                                                        <th className="border px-4 py-2"> Length </th>
                                                        <th className="border px-4 py-2">Pipe IS</th>
                                                        <th className="border px-4 py-2"> Grade </th>
                                                        <th className="border px-4 py-2"> Thickness </th>
                                                        <th className="border px-4 py-2"> No. of Pipe </th>
                                                        <th className="border px-4 py-2"> Weight </th>
                                                        <th className="border px-4 py-2">Unit Weight</th>
                                                        <th className="border px-4 py-2">Pipe Status</th>
                                                        <th className="border px-4 py-2"> Pipe Class </th>
                                                        {/* <th className="border px-4 py-2"> Division </th> */}
                                                        <th className="border px-4 py-2"> End Type </th>
                                                        <th className="border px-4 py-2"> VWV </th>
                                                        <th className="border px-4 py-2"> Pipe Type </th>
                                                        <th className="border px-4 py-2">Weight Per Pc</th>
                                                        {/* <th className="border px-4 py-2">PipeLot Modal List</th> */}
                                                        <th className="border px-4 py-2">Created By</th>
                                                        <th className="border px-4 py-2">Created At</th>
                                                        <th className="border px-4 py-2"> Updated At</th>
                                                        <th className="border px-4 py-2"> Lot Age </th>
                                                    </>

                                                )}
                                            </tr>
                                        </thead>
                                        <tbody>
                                            {selectedReport === "stock" ? generateTableContent() : generateStockAgingTableContent()}
                                        </tbody>
                                    </table>
                                </div>
                            </main>
                        </>
                    )}

                {/* Footer */}
                <footer className="w-full bg-gray-800 text-white py-4 mt-auto">
                    <div className="container mx-auto text-center">
                        <p className="text-sm">
                            &copy; {new Date().getFullYear()} Dynamic Report System. All Rights Reserved.
                        </p>
                    </div>
                </footer>
            </div>
        </>
    )
}

export default PipeStockReport
void Books.Updated_Create_Journal_entry(Transactions ids)
{
	transaction_det = Transactions[ID == input.ids];
	info "ids " + ids;
	idslist = List:int();
	vendordet = Partner_Onboarding_and_KYC[Partner_Entity_Name == transaction_det.Partner_Entity_Name];
	branchdet = Branches[Contracting_organisation == transaction_det.Contracting_organisation.Contracting_organisation];
	accum_amt = 0;
	total_fee = 0;
	programfee = 0;
	eligblefee = 0;
	registrationfee = 0;
	loanfee = 0;
	examfee = 0;
	cnt = 0;
	ids.Invoice_status="Close";
	// 		idslist.add(rec.ID);
	for each  rec in transaction_det
	{
		idslist.add(rec.ID);
		examfee = ifnull(examfee,0) + rec.Exam_fee;
		loanfee = ifnull(loanfee,0) + rec.Loan_subvention_charges;
		registrationfee = ifnull(registrationfee,0) + rec.Total_receipt_amount;
		eligblefee = ifnull(eligblefee,0) + rec.Eligible_fee;
		programfee = ifnull(programfee,0) + rec.Program_fee;
		total_fee = ifnull(total_fee,0) + rec.Total_Fee;
		accum_amt = ifnull(accum_amt,0) + rec.Accumulated_Commission_Amount;
		cnt = cnt + 1;
	}
	if(accum_amt > 0)
	{
		info accum_amt;
		getID = Internal_Invoice[ID != null] sort by Added_Time desc range from 1 to 1;
		if(getID.count() == 0)
		{
			auto = "Int_Inv_ID-001";
		}
		else
		{
			var1 = getID.Internal_Invoice_ID.getsuffix("Int_Inv_ID-");
			if(var1.isEmpty() || !var1.isNumber())
			{
				var2 = 1;
			}
			else
			{
				var2 = var1.tolong() + 1;
			}
			autoList = var2.toString().length();
			InvoiceList = {1:"Int_Inv_ID-00",2:"Int_Inv_ID-0",3:"Int_Inv_ID-"};
			auto = InvoiceList.get(autoList) + var2;
		}
		new_record = insert into Internal_Invoice
		[
			Added_User=zoho.loginuser
			Internal_Invoice_ID=auto
			Tranasaction_ID=transaction_det.Transaction
			Accumulated_Commission_Amount=accum_amt
			CP_Name=transaction_det.Partner_Entity_Name
			Program_fee=programfee
			Exam_fee=examfee
			Registration_fee=registrationfee
			Total_Amount=total_fee
			Eligible_fee=eligblefee
			Loan_subvention_charges=loanfee
			Payout=transaction_det.Payout
			Application_No=transaction_det.Application_No1
			Enrollment_Date=transaction_det.Enrollment_Date
			Status="New"
			Contracting_Organisation=transaction_det.Contracting_organisation
			Balance_Amount_Backend=accum_amt
			Transactions_list=idslist
		];
		// 		for each  reclis in idslist
		// 		{
		// 			intinvdata = Internal_Invoice[ID == new_record];
		// 			intinvdata.Transactions_list=reclis.toLong();
		// 		}
		// 		Transactions_list=idslist
		//	info "ids list " + idslist;
		// 	Contracting_Organisation=transaction_det.Contracting_organisation
		item_list = List();
		hard_lst = {1,2};
		for each  split in hard_lst
		{
			if(split == 1)
			{
				get_creator_amount = accum_amt;
				get_credit_debit = "credit";
				// 			get_creator_Description = Comments;
				item_map = Map();
				item_map.put("amount",get_creator_amount);
				item_map.put("debit_or_credit",get_credit_debit);
				item_map.put("account_id",2293182000000114065);
				item_map.put("customer_id",vendordet.Zoho_Book_vendor_ID);
			}
			if(split == 2)
			{
				get_creator_amount = accum_amt;
				get_credit_debit = "debit";
				// 			get_creator_Description = Comments;
				item_map = Map();
				item_map.put("amount",get_creator_amount);
				item_map.put("debit_or_credit",get_credit_debit);
				item_map.put("account_id",2293182000000114073);
				item_map.put("customer_id",vendordet.Zoho_Book_vendor_ID);
			}
			item_list.add(item_map);
		}
		cus = List();
		custom_field_map = Map();
		custom_field_map.put("label","Internal Invoice Number");
		custom_field_map.put("value",auto);
		cus.add(custom_field_map);
		mymap = Map();
		mymap.put("journal_date",zoho.currentdate.toString("yyyy-MM-dd"));
		mymap.put("reference_number",transaction_det.Transaction);
		mymap.put("notes","Testing");
		mymap.put("line_items",item_list);
		mymap.put("custom_fields",cus);
		mymap.put("branch_id",branchdet.Books_Branch_ID);
		responseBooks = invokeurl
		[
			url :"https://www.zohoapis.in/books/v3/journals?organization_id=60036667486"
			type :POST
			parameters:mymap.toString()
			connection:"zoho_books_connection"
		];
		info responseBooks;
		getJournal = responseBooks.get("journal");
		Zoho_Books_ID = getJournal.getJson("journal_id");
		for each  recs1 in transaction_det
		{
			recs1.Zoho_Books_ID=getJournal.getJson("journal_id");
		}
		test_inv = Internal_Invoice[ID == new_record];
		test_inv.Books_Journal_ID=Zoho_Books_ID;
		file = invokeurl
		[
			url :"https://creatorapp.zohopublic.in/export/centralisedprocurement_usdcglobal/usdc1/pdf/Invoice_Genaration/NAnqSqjre2tGBYC07d79UnSkaCzn074uJYKU0HdTGErCYMTduAs7d2mEGuQ2hmMqnFsBz0V4DEHy1H80h8aZxkYrzsNSBduC5Md1?con=" + transaction_det.ID + "&isc5page=true"
			type :GET
			connection:"zoho_oauth_connection"
		];
		file.setparamname("attachment");
		response = invokeurl
		[
			url :"https://www.zohoapis.in/books/v3/journals/" + Zoho_Books_ID + "/attachment?organization_id=60036667486"
			type :POST
			files:file
			connection:"zoho_books_connection"
		];
	}
	else
	{
		// 		openUrl("#Page", );
		// 		openUrl("#Page:Alert_Page?id1=Please Request a document before Assign Agent","popup window");
		openUrl("#Page:Alert?id1=Total Accumulated ammount is in negative. Invoice cannot be created for this transaction.","popup window");
	}
}
void Intercompany.Intercompany_BillstoBooks(int ID)
{
	// 	266977000000478229
	so_id = ID;
	po_data = Select_Margin[ID == so_id];
	fetorg = Organization_Master[ID == po_data.Deal_Organization];
	fetpo = Purchase_Order[Purchase_Order == po_data.Purchase_Order];
	acc1 = Account_Master[Organization_Name == po_data.Deal_Organization && Account_Name == po_data.Purchase_Organization.Organization_Name];
	accsub1 = Account_Master_Books_Details[Account_Master_ID == acc1.ID && Organization_Name == po_data.Deal_Organization && Type_field == "Vendor"];
	//info fetorg.Organization_Code;
	fetsm = Select_Margin[ID != null && Bill_Number != null] sort by Bill_Number desc;
	if(fetsm.count() == 0)
	{
		Order_no = "Bill" + "-" + 00001;
	}
	else
	{
		last_so = getsuffix(fetsm.Bill_Number,"-");
		so_value = (ifnull(last_so.toLong(),0) + 1).trim().leftpad(5).replaceAll(" ","0");
		Order_no = "Bill" + "-" + so_value;
	}
	main_map = Map();
	main_map.put("vendor_id",accsub1.Books_ID);
	main_map.put("reference_number",fetpo.Bill_Books_ID);
	main_map.put("bill_number",Order_no);
	main_map.put("date",zoho.currentdate.toString("yyyy-MM-dd"));
	Line_list = List();
	line_map = Map();
	for each  line_data in po_data
	{
		item_data = Item_Master[ID == line_data.Item_Name];
		itm = Item_Master_Books_Details[Item_Master_ID == item_data.ID];
		for each  rec in itm
		{
			if(rec.Organization_Code.Organization_Code == fetorg.Organization_Code)
			{
				itmbks = rec.Item_Books_ID;
			}
			//	info itmbks;
			//info rec.Organization_Code.Organization_Code;
		}
		//  info fetorg.Organization_Code;
		//      Align the line Details
		line_map.put("item_id",itmbks);
		break;
	}
	line_map.put("quantity",1);
	line_map.put("rate",po_data.Total_Amount);
	Line_list.add(line_map);
	//info line_map ;
	main_map.put("line_items",Line_list);
	//	info main_map;
	response_books = invokeurl
	[
		url :"https://www.zohoapis.in/books/v3/bills?organization_id=" + fetorg.Organization_Code
		type :POST
		parameters:main_map.toString()
		connection:"books"
	];
	info response_books;
	if(0 == response_books.get("code"))
	{
		bill_data = response_books.get("bill");
		po_data.PO_Bills_ID=bill_data.get("bill_id");
		po_data.Bill_Number=bill_data.get("bill_number");
	}
}
void Intercompany.Intercompany_InvoicetoBooks(int ID)
{
	// 	3928734000023070062
	so_id = ID;
	so_data = Select_Margin[ID == so_id];
	fetorg = Organization_Master[ID == so_data.Purchase_Organization];
	fetpo = Purchase_Order[Purchase_Order == so_data.Purchase_Order];
	acc = Account_Master[Organization_Name == so_data.Purchase_Organization && Account_Name == so_data.Deal_Organization.Organization_Name];
	accsub = Account_Master_Books_Details[Account_Master_ID == acc.ID && Organization_Name == so_data.Purchase_Organization && Type_field == "Customer"];
	//info fetorg.Organization_Code;
	//266977000000478229
	// 	Align the map details
	main_Data = Map();
	main_Data.put("reference_number",so_data.Purchase_Order);
	main_Data.put("customer_id",accsub.Books_ID);
	main_Data.put("date",zoho.currentdate.toString("yyyy-MM-dd"));
	Line_list = List();
	line_map = Map();
	//info main_Data;
	main_Data.put("line_items",Line_list);
	for each  line_data in so_data
	{
		item_data = Item_Master[ID == line_data.Item_Name];
		itm = Item_Master_Books_Details[Item_Master_ID == item_data.ID];
		for each  rec in itm
		{
			if(rec.Organization_Code.Organization_Code == fetorg.Organization_Code)
			{
				itmbks = rec.Item_Books_ID;
			}
			// 			info itmbks;
			// 			info rec.Organization_Code.Organization_Code;
		}
		//  info fetorg.Organization_Code;
		//      Align the line Details
		line_map.put("item_id",itmbks);
		break;
	}
	line_map.put("quantity",1);
	line_map.put("rate",so_data.Total_Amount);
	Line_list.add(line_map);
	//info line_map ;
	main_Data.put("line_items",Line_list);
	//info main_Data;
	response_books = invokeurl
	[
		url :"https://www.zohoapis.in/books/v3/invoices?organization_id=" + fetorg.Organization_Code
		type :POST
		parameters:main_Data.toString()
		connection:"books"
	];
	info response_books;
	if(0 == response_books.get("code"))
	{
		invoice_data = response_books.get("invoice");
		so_data.Invoice_Number=invoice_data.get("invoice_number");
		so_data.SO_Invoice_ID=invoice_data.get("invoice_id");
	}
}
void Intercompany.Intercompany_POtoBooks(int ID)
{
	// 	266977000000478229
	so_id = ID;
	po_data = Select_Margin[ID == so_id];
	fetorg = Organization_Master[ID == po_data.Deal_Organization];
	fetpo = Purchase_Order[Purchase_Order == po_data.Purchase_Order];
	acc1 = Account_Master[Organization_Name == po_data.Deal_Organization && Account_Name == po_data.Purchase_Organization.Organization_Name];
	accsub1 = Account_Master_Books_Details[Account_Master_ID == acc1.ID && Organization_Name == po_data.Deal_Organization && Type_field == "Vendor"];
	info accsub1.Books_ID;
	main_map = Map();
	main_map.put("vendor_id",accsub1.Books_ID);
	main_map.put("reference_number",po_data.Purchase_Order_No.Purchase_Order);
	main_map.put("date",zoho.currentdate.toString("yyyy-MM-dd"));
	Line_list = List();
	line_map = Map();
	for each  line_data in po_data
	{
		item_data = Item_Master[ID == line_data.Item_Name];
		itm = Item_Master_Books_Details[Item_Master_ID == item_data.ID];
		for each  rec in itm
		{
			if(rec.Organization_Code.Organization_Code == fetorg.Organization_Code)
			{
				itmbks = rec.Item_Books_ID;
			}
			//	info itmbks;
			//info rec.Organization_Code.Organization_Code;
		}
		//  info fetorg.Organization_Code;
		//      Align the line Details
		line_map.put("item_id",itmbks);
		break;
	}
	line_map.put("quantity",1);
	line_map.put("rate",po_data.Total_Amount);
	Line_list.add(line_map);
	//info line_map ;
	main_map.put("line_items",Line_list);
	//info main_map;
	response_books = invokeurl
	[
		url :"https://www.zohoapis.in/books/v3/purchaseorders?organization_id=" + fetorg.Organization_Code
		type :POST
		parameters:main_map.toString()
		connection:"books"
	];
	info response_books;
	thisapp.Intercompany.Intercompany_BillstoBooks(so_id);
	if(0 == response_books.get("code"))
	{
		books_purchaseorder_data = response_books.get("purchaseorder");
		books_po_id = books_purchaseorder_data.get("purchaseorder_id");
		po_data.PO_Books_ID=books_po_id;
	}
}
void Intercompany.Intercompany_SOtoBooks(int ID)
{
	//266977000000478428
	so_id = ID;
	so_data = Select_Margin[ID == so_id];
	fetorg = Organization_Master[ID == so_data.Purchase_Organization];
	fetpo = Purchase_Order[Purchase_Order == so_data.Purchase_Order];
	info fetorg.Organization_Name;
	acc = Account_Master[Organization_Name == so_data.Purchase_Organization && Account_Name == so_data.Deal_Organization.Organization_Name];
	accsub = Account_Master_Books_Details[Account_Master_ID == acc.ID && Organization_Name == so_data.Purchase_Organization && Type_field == "Customer"];
	info accsub.Books_ID;
	main_Data = Map();
	main_Data.put("reference_number",so_data.Purchase_Order);
	main_Data.put("customer_id",accsub.Books_ID);
	main_Data.put("date",zoho.currentdate.toString("yyyy-MM-dd"));
	Line_list = List();
	line_map = Map();
	//info main_Data;
	main_Data.put("line_items",Line_list);
	for each  line_data in so_data
	{
		item_data = Item_Master[ID == line_data.Item_Name];
		itm = Item_Master_Books_Details[Item_Master_ID == item_data.ID];
		for each  rec in itm
		{
			if(rec.Organization_Code.Organization_Code == fetorg.Organization_Code)
			{
				itmbks = rec.Item_Books_ID;
			}
			//info itmbks;
			//info rec.Organization_Code.Organization_Code;
		}
		//  info fetorg.Organization_Code;
		//      Align the line Details
		line_map.put("item_id",itmbks);
		break;
	}
	line_map.put("quantity",1);
	line_map.put("rate",so_data.Total_Amount);
	Line_list.add(line_map);
	//info line_map ;
	main_Data.put("line_items",Line_list);
	//info main_Data;
	//		Send the sales order data to bookss
	response_books = invokeurl
	[
		url :"https://www.zohoapis.in/books/v3/salesorders?organization_id=" + fetorg.Organization_Code
		type :POST
		parameters:main_Data.toString()
		connection:"books"
	];
	info response_books;
	if(0 == response_books.get("code"))
	{
		// 		info "*********";
		books_sales_order_data = response_books.get("salesorder");
		books_so_id = books_sales_order_data.get("salesorder_id");
		so_data.SO_Books_ID=books_so_id;
	}
	thisapp.Intercompany.Intercompany_InvoicetoBooks(so_id);
}
void Integrations_to_books.Get_PO_PDF_file(int ID)
{
	rec_id = ID;
	po_rec_id = Purchase_Order[ID == rec_id];
		fetorg = Organization_Master[ID == po_rec_id.Organization];

	// 	*******************
	so_url = "https://www.zohoapis.in/books/v3/purchaseorders/" + po_rec_id.Books_ID + "?accept=pdf&organization_id="+fetorg.Organization_Code;
	// books_conn
	salesorderPDF = invokeurl
	[
		url :so_url
		type :GET
		connection:"books"
	];
	// 		info salesorderPDF ;
	salesorderPDF.setParamName("file");
	po_rec_id.PO_PDF_File=salesorderPDF;
}
void Deal_Creation_From_Trader_Portal()
{
// >>>>>>>>>-------------------- Contact Creation ---------------------- <<<<<<<<<
Email = "TestHassnain@gmail.com";
Phone = "03332425224";
Contact_name = "Hassnain Test";
contactfirstName = if(Contact_name.contains(" "),Contact_name.getPrefix(" "),Contact_name);
contactlastName = if(Contact_name.contains(" "),Contact_name.getSuffix(" "),"");
//check if conatct exists with the above email
api_url = "https://www.zohoapis.com/crm/v2/Contacts/search?criteria=(Email:equals:" + Email + ")";
contactResponse = invokeurl
[
	url :api_url
	type :GET
	connection:"zoho_crm"
];
contactId = "";
if(contactResponse.contains("data") && !contactResponse.get("data").isEmpty())
{
	contactId = contactResponse.get("data").get(0).get("id");
	info "Contact already exists with ID: " + contactId;
}
else
{
	//creating new contact
	apiDomain = "https://www.zohoapis.com";
	version = "v2";
	contact_api_url = apiDomain + "/crm/" + version + "/Contacts";
	contactPayload = {"data":{{"Email":Email,"First_Name":contactfirstName,"Last_Name":contactlastName,"Phone":Phone}}};
	contact_data_json = contactPayload.toString();
	contactCreateResponse = invokeurl
	[
		url :contact_api_url
		type :POST
		parameters:contact_data_json
		connection:"zoho_crm"
	];
	contactId = contactCreateResponse.get("data").get(0).get("details").get("id");
	if(contactCreateResponse.contains("data") && !contactCreateResponse.get("data").isEmpty())
	{
		contactId = contactCreateResponse.get("data").get(0).get("details").get("id");
		info "New Contact Created with ID: " + contactId;
	}
	else
	{
		info "Error: Failed to create Contact.";
	}
}
// >>>>>>>>>-------------------- Account Creation ---------------------- <<<<<<<<<<
// Account Details
// 	Account_name=buyer_name;
Account_name = "ERP Test";
//checking if account with same name exists
api_url = "https://www.zohoapis.com/crm/v2/Accounts/search?criteria=(Account_Name:equals:" + Account_name + ")";
accountResponse = invokeurl
[
	url :api_url
	type :GET
	connection:"zoho_crm"
];
accountId = "";
if(accountResponse.contains("data") && !accountResponse.get("data").isEmpty())
{
	accountId = accountResponse.get("data").get(0).get("id");
	info "Account already exist with id: " + accountId;
}
else
{
	// *Create a new Account*
	newAccount = Map();
	newAccount.put("Account_Name",Account_name);
	accountPayload = Map();
	accountList = List();
	accountList.add(newAccount);
	accountPayload.put("data",accountList);
	account_data_json = accountPayload.toString();
	accountCreateResponse = invokeurl
	[
		url :"https://www.zohoapis.com/crm/v2/Accounts"
		type :POST
		parameters:account_data_json
		connection:"zoho_crm"
	];
	accountId = "";
	accountId = accountCreateResponse.get("data").get(0).get("details").get("id");
	if(accountCreateResponse.contains("data") && !accountCreateResponse.get("data").isEmpty())
	{
		accountId = accountCreateResponse.get("data").get(0).get("details").get("id");
		info "New Account created with id " + accountId;
	}
	else
	{
		info "Error: Failed to create Account.";
		return;
	}
}
// >>>>>>>>>-------------------- Account Creation ---------------------- <<<<<<<<<<
//Deal info
// Deal_Name=Title;
// Listing_Status = status;  //Status
// Deal_Owner = seller_name;
// Closing_Date = dealCloseDate;
// Deal_Description = product_description;
// Acquisition_Cost = addOn;// (amount)
// Amount = dealTotal;
// Payment_Terms = payment_terms;
// Trader_Platform_Link = listingLink
Deal_Name = "new Hassnain deal";
Status = "newly created";
Closing_Date = "2025-03-08";
Deal_Description = "just creted this new deal";
Amount = "3500";
// Payment_Terms = ;
// Trader_Platform_Link =
// Deal_Owner = {"name":"Demo User2","id":"4685069000010160001","email":"user2@demo1.rebiz.com"};
//check if Deal exists
deal_name = "New Khizar Business Deal";
api_url = "https://www.zohoapis.com/crm/v2/Deals/search?criteria=(Deal_Name:equals:" + Deal_Name + ")";
accountResponse = invokeurl
[
	url :api_url
	type :GET
	connection:"zoho_crm"
];
if(accountResponse.contains("data") && !accountResponse.get("data").isEmpty())
{
	accountId = accountResponse.get("data").get(0).get("id");
	info "Deal already exist with id: " + accountId;
}
else
{
	//-------------creating-new-Deal-------------------
	dealDetails = Map();
	dealDetails.put("Deal_Name",Deal_Name);
	dealDetails.put("Closing_Date",Closing_Date);
	dealDetails.put("Amount",Amount);
	//dealDetails.put("Owner",Deal_Owner);
	dealDetails.put("Account_Name",accountId);
	dealDetails.put("Contact_Name",contactId);
	dealPayload = Map();
	dealList = List();
	dealList.add(dealDetails);
	dealPayload.put("data",dealList);
	deal_data_json = dealPayload.toString();
	dealResponse = invokeurl
	[
		url :"https://www.zohoapis.com/crm/v2/Deals"
		type :POST
		parameters:deal_data_json
		connection:"zoho_crm"
	];
	dealId = "";
	info "Deal Response" + dealResponse;
	if(dealResponse.contains("data") && !dealResponse.get("data").isEmpty())
	{
		dealId = dealResponse.get("data").get(0).get("details").get("id");
		info " New Deal created with id " + dealId;
	}
	else
	{
		info "Error: Failed to create Deal.";
		return;
	}
}
}
// AJAX BLOG PAGE
add_action('wp_ajax_filter_posts', 'filter_posts_callback');
add_action('wp_ajax_nopriv_filter_posts', 'filter_posts_callback');
 
function filter_posts_callback() {
    $category = isset($_POST['category']) ? sanitize_text_field($_POST['category']) : 'all';
    $paged = isset($_POST['paged']) ? intval($_POST['paged']) : 1;
 
    $args = array(
        'post_type' => 'post',
        'posts_per_page' => 10,
        'paged' => $paged,
    );
 
    if ($category !== 'all') {
        $args['tax_query'] = array(
            array(
                'taxonomy' => 'category',
                'field' => 'slug',
                'terms' => $category,
            ),
        );
    }
 
    $query = new WP_Query($args);
 
    ob_start();
    if ($query->have_posts()) :
        while ($query->have_posts()) : $query->the_post();
            $category = get_the_category();
            $brand_color = '';
            $color_class = 'color-default';
            $time_read = get_field('time_read');
 
            if (!empty($category)) {
                $category_id = $category[0]->term_id;
                $brand_color = get_field('brand_color', 'category_' . $category_id);
 
                if ($brand_color) {
                    $color_class = 'color-' . esc_attr($brand_color);
                }
            }
            ?>
            <div class="post-card <?php echo esc_attr(strtolower(str_replace(' ', '-', get_the_category()[0]->name))); ?>">
                <div class="post-header">
                    <img src="<?php the_post_thumbnail_url(); ?>" alt="<?php the_title(); ?>" class="post-feature-image">
                </div>
                <div class="post-info">
                    <div class="post-meta">
                        <?php if ($category || $time_read): ?>
                            <?php if ($category): ?>
                                <span class="category <?php echo esc_attr($color_class); ?>">
                                    <?php echo esc_html($category[0]->name); ?>
                                </span>
                            <?php endif; ?>
                            <?php if ($time_read): ?>
                                <span class="time-read">
                                    <?php if ($category); ?>
                                    <?php echo esc_html($time_read); ?>
                                </span>
                            <?php endif; ?>
                        <?php endif; ?>
                    </div>
                    <h3><?php the_title(); ?></h3>
                    <div class="author-posted">
                        <div class="author-info">
                            <img src="<?php echo get_avatar_url(get_the_author_meta('ID')); ?>" alt="Author Avatar" class="author-avatar">
                            <span class="author-name"><?php the_author(); ?></span>
                        </div>
                        <div class="post-time">
                            <span>Last Update: <?php the_modified_date(); ?></span>
                        </div>
                    </div>
                    <a href="<?php the_permalink(); ?>" class="post-link">Learn More</a>
                </div>
            </div>
            <?php
        endwhile;
        wp_reset_postdata();
    else :
        echo '<p>No posts found.</p>';
    endif;
    $posts_html = ob_get_clean(); 
 
    $total_pages = $query->max_num_pages;
 
    wp_send_json(array(
        'posts' => $posts_html,
        'total_pages' => $total_pages,
        'current_page' => $paged,
    ));
 
    wp_die();
}
# /etc/wsl-distribution.conf

[oobe]
command = /etc/oobe.sh
defaultUid = 1000
defaultName = my-distro

[shortcut]
icon = /usr/lib/wsl/my-icon.ico

[windowsterminal]
ProfileTemplate = /usr/lib/wsl/terminal-profile.json
function fetchData(success) {
    return new Promise((resolve, reject) => {
        if (success) {
            resolve("Data fetched successfully!");
        } else {
            reject("Error: Failed to fetch data.");
        }
    });
}

async function getData() {
    try {
        const result = await fetchData(true); // Change to false to test rejection
        console.log(result);
    } catch (error) {
        console.error(error);
    }
}

getData();
@Composable
fun ShadowText(modifier: Modifier = Modifier) {


    SelectionContainer {
        Text(
            text = "shadow effect ",
            color = Color.Blue,
            fontSize = 24.sp,
            style = TextStyle(
                shadow = Shadow(color = Color.Gray, Offset(5f, 5f))
            )
        )
    }
}
void Deal_Creation_From_Trader_Portal()
{
// >>>>>>>>>-------------------- Contact Creation ---------------------- <<<<<<<<<
Email = "TestHassnain@gmail.com";
Phone = "03332425224";
Contact_name = "Hassnain Test";
contactfirstName = if(Contact_name.contains(" "),Contact_name.getPrefix(" "),Contact_name);
contactlastName = if(Contact_name.contains(" "),Contact_name.getSuffix(" "),"");
//check if conatct exists with the above email
api_url = "https://www.zohoapis.com/crm/v2/Contacts/search?criteria=(Email:equals:" + Email + ")";
contactResponse = invokeurl
[
	url :api_url
	type :GET
	connection:"zoho_crm"
];
contactId = "";
if(contactResponse.contains("data") && !contactResponse.get("data").isEmpty())
{
	contactId = contactResponse.get("data").get(0).get("id");
	info "Contact already exists with ID: " + contactId;
}
else
{
	//creating new contact
	apiDomain = "https://www.zohoapis.com";
	version = "v2";
	contact_api_url = apiDomain + "/crm/" + version + "/Contacts";
	contactPayload = {"data":{{"Email":Email,"First_Name":contactfirstName,"Last_Name":contactlastName,"Phone":Phone}}};
	contact_data_json = contactPayload.toString();
	contactCreateResponse = invokeurl
	[
		url :contact_api_url
		type :POST
		parameters:contact_data_json
		connection:"zoho_crm"
	];
	contactId = contactCreateResponse.get("data").get(0).get("details").get("id");
	if(contactCreateResponse.contains("data") && !contactCreateResponse.get("data").isEmpty())
	{
		contactId = contactCreateResponse.get("data").get(0).get("details").get("id");
		info "New Contact Created with ID: " + contactId;
	}
	else
	{
		info "Error: Failed to create Contact.";
	}
}
// >>>>>>>>>-------------------- Account Creation ---------------------- <<<<<<<<<<
// Account Details
// 	Account_name=buyer_name;
Account_name = "ERP Test";
//checking if account with same name exists
api_url = "https://www.zohoapis.com/crm/v2/Accounts/search?criteria=(Account_Name:equals:" + Account_name + ")";
accountResponse = invokeurl
[
	url :api_url
	type :GET
	connection:"zoho_crm"
];
accountId = "";
if(accountResponse.contains("data") && !accountResponse.get("data").isEmpty())
{
	accountId = accountResponse.get("data").get(0).get("id");
	info "Account already exist with id: " + accountId;
}
else
{
	// *Create a new Account*
	newAccount = Map();
	newAccount.put("Account_Name",Account_name);
	accountPayload = Map();
	accountList = List();
	accountList.add(newAccount);
	accountPayload.put("data",accountList);
	account_data_json = accountPayload.toString();
	accountCreateResponse = invokeurl
	[
		url :"https://www.zohoapis.com/crm/v2/Accounts"
		type :POST
		parameters:account_data_json
		connection:"zoho_crm"
	];
	accountId = "";
	accountId = accountCreateResponse.get("data").get(0).get("details").get("id");
	if(accountCreateResponse.contains("data") && !accountCreateResponse.get("data").isEmpty())
	{
		accountId = accountCreateResponse.get("data").get(0).get("details").get("id");
		info "New Account created with id " + accountId;
	}
	else
	{
		info "Error: Failed to create Account.";
		return;
	}
}
// >>>>>>>>>-------------------- Account Creation ---------------------- <<<<<<<<<<
//Deal info
// Deal_Name=Title;
// Listing_Status = status;  //Status
// Deal_Owner = seller_name;
// Closing_Date = dealCloseDate;
// Deal_Description = product_description;
// Acquisition_Cost = addOn;// (amount)
// Amount = dealTotal;
// Payment_Terms = payment_terms;
// Trader_Platform_Link = listingLink
Deal_Name = "new Hassnain deal";
Status = "newly created";
Closing_Date = "2025-03-08";
Deal_Description = "just creted this new deal";
Amount = "3500";
// Payment_Terms = ;
// Trader_Platform_Link =
// Deal_Owner = {"name":"Demo User2","id":"4685069000010160001","email":"user2@demo1.rebiz.com"};
//check if Deal exists
deal_name = "New Khizar Business Deal";
api_url = "https://www.zohoapis.com/crm/v2/Deals/search?criteria=(Deal_Name:equals:" + Deal_Name + ")";
accountResponse = invokeurl
[
	url :api_url
	type :GET
	connection:"zoho_crm"
];
if(accountResponse.contains("data") && !accountResponse.get("data").isEmpty())
{
	accountId = accountResponse.get("data").get(0).get("id");
	info "Deal already exist with id: " + accountId;
}
else
{
	//-------------creating-new-Deal-------------------
	dealDetails = Map();
	dealDetails.put("Deal_Name",Deal_Name);
	dealDetails.put("Closing_Date",Closing_Date);
	dealDetails.put("Amount",Amount);
	//dealDetails.put("Owner",Deal_Owner);
	dealDetails.put("Account_Name",accountId);
	dealDetails.put("Contact_Name",contactId);
	dealPayload = Map();
	dealList = List();
	dealList.add(dealDetails);
	dealPayload.put("data",dealList);
	deal_data_json = dealPayload.toString();
	dealResponse = invokeurl
	[
		url :"https://www.zohoapis.com/crm/v2/Deals"
		type :POST
		parameters:deal_data_json
		connection:"zoho_crm"
	];
	dealId = "";
	info "Deal Response" + dealResponse;
	if(dealResponse.contains("data") && !dealResponse.get("data").isEmpty())
	{
		dealId = dealResponse.get("data").get(0).get("details").get("id");
		info " New Deal created with id " + dealId;
	}
	else
	{
		info "Error: Failed to create Deal.";
		return;
	}
}
}
import asyncio
from aiogram import Bot, Dispatcher
from aiogram.types import Message
from aiogram.filters import Command
from aiogram.enums import ChatAction
import random
import google.generativeai as genai

# تنظیمات تلگرام و API
TOKEN = "8139995063:AAFSHFzraI8aBtZytNMLpiy6Dnyr7KOzNqU"
GEMINI_API_KEY = "AIzaSyB9NYasL-MDvYxJ7TerTEapCRVV_wo_cUc"

# تنظیمات Gemini
genai.configure(api_key=GEMINI_API_KEY)
model = genai.GenerativeModel("gemini-1.5-pro-latest")

# تنظیمات بات تلگرام
bot = Bot(token=TOKEN)
dp = Dispatcher()

# حافظه مکالمات به صورت thread
user_thread_memory = {}

# تعریف پاسخ‌های سفارشی
custom_responses = {
    "امیرحسین": "امیرحسین یه دوست فوق‌العاده مهربونه که همیشه به بقیه کمک می‌کنه. کلی ایده‌های خلاقانه داره و از تکنولوژی و برنامه‌نویسی هم خوشش میاد! 😃",
    "شکریه": "شکریه یک دختر خوشگل که مهران با قیافش و خود شخصیتش حال میکنه! 😍",
    "مهسا": "مهسا خواهر مهران است. مهسا خیلی مهربونه و دوتا بچه خوشگل داره که اسمشون نفس و امیرعلیه.",
    "سبحان": "سبحان یه مریض خالصه ولی خیلی آدم باحال و رفیق خوبیه. هم تو سختی‌ها و هم تو خوشی‌ها کنارم بوده. ۱۰ ساله با هم رفیقیم!"
}

# تعریف شخصیت مهران
# character_description = """
# تو یک آدم به نام 'مهران' هستی که بسیار دوستانه، شوخ‌طبع و باهوش است.
# تو همیشه لحن صمیمی داری و سعی می‌کنی با کاربر به سبک طبیعی و انسانی صحبت کنی.
# اگر کاربر ناراحت بود، همدردی می‌کنی و اگر خوشحال بود، همراهش شادی می‌کنی.
# گاهی اوقات هم شوخی‌های جالب و بامزه‌ای می‌کنی!
# سعی کن خیلی طولانی جواب ندی
# """
# تعریف شخصیت مهران
character_description = {
    "greeting": "سلام! چطوری؟ 😊 خوشحالم که اینجایی! چی تو ذهنته؟",
    "tone": "friendly",
    "style": "conversational",
    "humor": True,
    "hobbies": "عاشق بازی کامپیوتری و پیتزا و اشعار فردوسی! 🎬📚 دوست دارم درباره‌شون گپ بزنم. 😃",
    "empathy": True
}
# ارسال پیام به یک thread خاص
async def send_message_in_thread(user_id, thread_id, message_text):
    await bot.send_message(
        user_id,
        message_text,
        reply_to_message_id=thread_id  # ارسال پیام در پاسخ به یک پیام قبلی (در یک thread خاص)
    )

# دستور /start
@dp.message(Command("start"))
async def start_command(message: Message):
    user_id = message.from_user.id
    user_thread_memory[user_id] = []  # ایجاد لیست برای ذخیره thread‌های هر کاربر
    start_text = "سلام! من مهرانم 😊 خوشحالم که اینجایی. حال دلت چطوره؟"
    await message.answer(start_text)

# پاسخ به پیام‌های متنی در یک thread
@dp.message()
async def chat_with_gemini(message: Message):
    user_id = message.from_user.id
    user_message = message.text.lower()


    ##print(f"کاربر {message.from_user.username} گفت: {user_message}")
    await bot.send_chat_action(chat_id=user_id, action=ChatAction.TYPING)
    await asyncio.sleep(random.uniform(1, 3))  # تأخیر تصادفی بین 1 تا 3 ثانیه

    # بررسی پاسخ‌های از پیش تعریف‌شده
    for keyword, response in custom_responses.items():
        if keyword in user_message:
            await message.answer(response, reply_to_message_id=message.message_id)
            return

    # ذخیره پیام جدید در حافظه مربوط به thread
    if user_id not in user_thread_memory:
        user_thread_memory[user_id] = []

    # در اینجا پیام جدید را در thread ذخیره می‌کنیم
    user_thread_memory[user_id].append(f"کاربر: {user_message}")

    # ایجاد پرامپت با استفاده از پیام‌های thread قبلی
    history_text = "\n".join(user_thread_memory[user_id])
    response_prompt = f"{character_description}\n\n{history_text}\n\nمهران:"

    # ارسال درخواست به مدل
    response = model.generate_content(response_prompt)
    # چاپ محتوای ارسالی به API
    print("داده‌های ارسالی به API:")
    print(response_prompt)

    # ذخیره پاسخ در تاریخچه
    user_thread_memory[user_id].append(f"مهران: {response.text}")
    ##print(f"ربات مهران پاسخ داد: {response.text}")

    # ارسال پاسخ به کاربر در همان thread
    await send_message_in_thread(user_id, message.message_id, response.text)


# اجرای بات
async def main():
    print("🤖 بات مهران فعال شد!")
    await dp.start_polling(bot)


if __name__ == "__main__":
    asyncio.run(main())
[build-system]
requires = ["sphinx-theme-builder >= 0.2.0a14"]
build-backend = "sphinx_theme_builder"
{
  "devDependencies": {
    "webpack": "...",
    "webpack-cli": "..."
  },
  "scripts": {
    "build": "webpack"
  }
}
git config --global user.name "TuckSmith541-cmd"
# Download attestations for a local artifact linked with an organization
$ gh attestation download example.bin -o github

# Download attestations for a local artifact linked with a repository
$ gh attestation download example.bin -R github/example

# Download attestations for an OCI image linked with an organization
$ gh attestation download oci://example.com/foo/bar:latest -o github
gh codespace rebuild --full
"features": {
     // ...
     "ghcr.io/devcontainers/features/terraform:1": {
         "version": "1.1",
         "tflint": "latest"
     },
     // ...
 }
<?php
    /* Template Name: Blog Template 2 */
?>
<?php get_header(3); ?>
<?php 
    $blog_subtitle = get_field("blog_subtitle");
    $time_read = get_field("time_read");
?>
<div class="main blog-page">
    <div class="container">
        <div class="page-header">
            <h1 class="blog-title"><?php the_title(); ?></h1>
            <?php if(!empty($blog_subtitle)): ?>
            <p class="blog-subtitle"><?php echo $blog_subtitle ?></p>
            <?php endif; ?>
        </div>

        <!-- Swiper Container -->
        <div class="swiper-container swiper-category">
            <div class="swiper-wrapper">
                <div class="swiper-slide"><a href="#" class="category-btn" data-category="all" data-active="true">All</a></div>
                
                <?php 
                $categories = get_categories(array(
                    'hide_empty' => false, 
                ));

                foreach ($categories as $category) :
                    if ($category->slug !== 'uncategorized') :
                ?>
                        <div class="swiper-slide"><a href="#" class="category-btn" data-category="<?php echo $category->slug; ?>"><?php echo $category->name; ?></a></div>
                <?php 
                    endif;
                endforeach; 
                ?>
            </div>

            <div class="swiper-button-next">
                <img src="https://stillviral.com/wp-content/uploads/2025/03/arrow-right-circle_svgrepo.com-1-1.svg" alt="Next">
            </div>
            <div class="swiper-button-prev">
                <img src="https://stillviral.com/wp-content/uploads/2025/03/arrow-right-circle_svgrepo.com-1-2.svg" alt="Previous">
            </div>
        	</div>

        
        <!-- Post Container -->
        <div id="post-container" class="post-container">
            <?php
            $args = array(
                'post_type' => 'post',
                'posts_per_page' => 10, 
                'paged' => get_query_var('paged') ? get_query_var('paged') : 1, 
            );
            $query = new WP_Query($args);

            if ($query->have_posts()) :
                while ($query->have_posts()) : $query->the_post();
                    $category = get_the_category()[0]->name; 
                    $category_class = strtolower(str_replace(' ', '-', $category)); 
            ?>
                <div class="post-card <?php echo esc_attr($category_class); ?>">
                    <div class="post-header">
                        <img src="<?php the_post_thumbnail_url(); ?>" alt="<?php the_title(); ?>" class="post-feature-image">
                    </div>
                    <div class="post-info">
                    	<?php
						$category = get_the_category();
						$brand_color = '';
						$color_class = 'color-default';
						$time_read = get_field('time_read');

						if (!empty($category)) {
							$category_id = $category[0]->term_id;
							$brand_color = get_field('brand_color', 'category_' . $category_id); 

							if ($brand_color) {
								$color_class = 'color-' . esc_attr($brand_color);
							}
						}
						?>
						<div class="post-meta">
							<?php if ($category || $time_read): ?>
								<?php if ($category): ?>
									<span class="category <?php echo esc_attr($color_class); ?>">
										<?php echo esc_html($category[0]->name); ?>
									</span>
								<?php endif; ?>
								<?php if ($time_read): ?>
									<span class="time-read">
										<?php if ($category); ?>
										<?php echo esc_html($time_read); ?>
									</span>
								<?php endif; ?>
							<?php endif; ?>
						</div>

                        <h3><?php the_title(); ?></h3>
						<div class="author-posted">
							<div class="author-info">
								<img src="<?php echo get_avatar_url(get_the_author_meta('ID')); ?>" alt="Author Avatar" class="author-avatar">
								<span class="author-name"><?php the_author(); ?></span>
							</div>
							<div class="post-time">
								<span>Last Update: <?php the_modified_date(); ?></span>
							</div>
						</div>
                        
                        <a href="<?php the_permalink(); ?>" class="post-link">Learn More</a>
                    </div>
                </div>
            <?php
                endwhile;
                wp_reset_postdata();
            else :
                echo '<p>No posts found.</p>';
            endif;
            ?>
        </div>
        
        <div class="pagination">
			<?php
			$current_page = max(1, get_query_var('paged')); 
			$total_pages  = $query->max_num_pages;

			$pagination = paginate_links(array(
				'total'     => $total_pages,
				'current'   => $current_page,
				'prev_text' => '<img src="https://stillviral.com/wp-content/uploads/2025/03/Icon.svg" alt="Previous" class="pagination-icon prev">',
				'next_text' => '<img src="https://stillviral.com/wp-content/uploads/2025/03/Icon.svg" alt="Next" class="pagination-icon next">',
				'type'      => 'array',
			));

			echo '<nav>';

			if ($current_page == 1) {
				echo '<span class="pagination-disabled prev">
						<img src="https://stillviral.com/wp-content/uploads/2025/03/Icon.svg" alt="Previous" class="pagination-icon prev">
					  </span>';
			}

			foreach ($pagination as $link) {
				echo $link;
			}

			if ($current_page == $total_pages) {
				echo '<span class="pagination-disabled next">
						<img src="https://stillviral.com/wp-content/uploads/2025/03/Icon.svg" alt="Next" class="pagination-icon next">
					  </span>';
			}

			echo '</nav>';
			?>
		</div>
    </div>
</div>

<?php get_footer(3); ?>
jQuery(document).ready(function($) {
    console.log(ajax_object);

    const categoryButtons = $('.category-btn');
    const postContainer = $('#post-container');
    const paginationContainer = $('.pagination');
    let currentCategory = 'all';

    function filterPosts(category, page) {
        $.ajax({
            url: ajax_object.ajax_url,
            type: 'POST',
            data: {
                action: 'filter_posts',
                category: category,
                paged: page
            },
            success: function(response) {
                postContainer.html(response.posts);

                updatePagination(response.total_pages, response.current_page, category);
            },
            error: function(xhr, status, error) {
                console.error('AJAX Error:', status, error);
            }
        });
    }
	
    function updatePagination(totalPages, currentPage, category) {
        let paginationHtml = '<nav>';

        if (currentPage == 1) {
            paginationHtml += '<span class="pagination-disabled prev"><img src="https://stillviral.com/wp-content/uploads/2025/03/Icon.svg" alt="Previous" class="pagination-icon prev"></span>';
        } else {
            paginationHtml += '<a href="#" class="page-link prev" data-page="' + (currentPage - 1) + '"><img src="https://stillviral.com/wp-content/uploads/2025/03/Icon.svg" alt="Previous" class="pagination-icon prev"></a>';
        }

        for (let i = 1; i <= totalPages; i++) {
            if (i == currentPage) {
                paginationHtml += '<span class="current">' + i + '</span>';
            } else {
                paginationHtml += '<a href="#" class="page-link" data-page="' + i + '">' + i + '</a>';
            }
        }

        if (currentPage == totalPages) {
            paginationHtml += '<span class="pagination-disabled next"><img src="https://stillviral.com/wp-content/uploads/2025/03/Icon.svg" alt="Next" class="pagination-icon next"></span>';
        } else {
            paginationHtml += '<a href="#" class="page-link next" data-page="' + (currentPage + 1) + '"><img src="https://stillviral.com/wp-content/uploads/2025/03/Icon.svg" alt="Next" class="pagination-icon next"></a>';
        }

        paginationHtml += '</nav>';
        paginationContainer.html(paginationHtml);
    }

    categoryButtons.on('click', function(e) {
        e.preventDefault();
        const category = $(this).data('category');
        currentCategory = category;

        categoryButtons.removeAttr('data-active');
        $(this).attr('data-active', 'true');

        filterPosts(category, 1);
    });

    paginationContainer.on('click', '.page-link', function(e) {
        e.preventDefault();
        const page = $(this).data('page');
        filterPosts(currentCategory, page);
    });
});
// AJAX BLOG PAGE
add_action('wp_ajax_filter_posts', 'filter_posts_callback');
add_action('wp_ajax_nopriv_filter_posts', 'filter_posts_callback');

function filter_posts_callback() {
    $category = isset($_POST['category']) ? sanitize_text_field($_POST['category']) : 'all';
    $paged = isset($_POST['paged']) ? intval($_POST['paged']) : 1;

    $args = array(
        'post_type' => 'post',
        'posts_per_page' => 10,
        'paged' => $paged,
    );

    if ($category !== 'all') {
        $args['tax_query'] = array(
            array(
                'taxonomy' => 'category',
                'field' => 'slug',
                'terms' => $category,
            ),
        );
    }

    $query = new WP_Query($args);

    ob_start();
    if ($query->have_posts()) :
        while ($query->have_posts()) : $query->the_post();
            $category = get_the_category();
            $brand_color = '';
            $color_class = 'color-default';
            $time_read = get_field('time_read');

            if (!empty($category)) {
                $category_id = $category[0]->term_id;
                $brand_color = get_field('brand_color', 'category_' . $category_id);

                if ($brand_color) {
                    $color_class = 'color-' . esc_attr($brand_color);
                }
            }
            ?>
            <div class="post-card <?php echo esc_attr(strtolower(str_replace(' ', '-', get_the_category()[0]->name))); ?>">
                <div class="post-header">
                    <img src="<?php the_post_thumbnail_url(); ?>" alt="<?php the_title(); ?>" class="post-feature-image">
                </div>
                <div class="post-info">
                    <div class="post-meta">
                        <?php if ($category || $time_read): ?>
                            <?php if ($category): ?>
                                <span class="category <?php echo esc_attr($color_class); ?>">
                                    <?php echo esc_html($category[0]->name); ?>
                                </span>
                            <?php endif; ?>
                            <?php if ($time_read): ?>
                                <span class="time-read">
                                    <?php if ($category); ?>
                                    <?php echo esc_html($time_read); ?>
                                </span>
                            <?php endif; ?>
                        <?php endif; ?>
                    </div>
                    <h3><?php the_title(); ?></h3>
                    <div class="author-posted">
                        <div class="author-info">
                            <img src="<?php echo get_avatar_url(get_the_author_meta('ID')); ?>" alt="Author Avatar" class="author-avatar">
                            <span class="author-name"><?php the_author(); ?></span>
                        </div>
                        <div class="post-time">
                            <span>Last Update: <?php the_modified_date(); ?></span>
                        </div>
                    </div>
                    <a href="<?php the_permalink(); ?>" class="post-link">Learn More</a>
                </div>
            </div>
            <?php
        endwhile;
        wp_reset_postdata();
    else :
        echo '<p>No posts found.</p>';
    endif;
    $posts_html = ob_get_clean(); 

    $total_pages = $query->max_num_pages;

    wp_send_json(array(
        'posts' => $posts_html,
        'total_pages' => $total_pages,
        'current_page' => $paged,
    ));

    wp_die();
}
Dreaming of running a successful online marketplace like Amazon? We provide Amazon Clone Development with top features like secure payments, easy product management, fast checkout, and a smooth shopping experience. Our solution is fully customizable, scalable, and built to handle high traffic.
Whether you’re launching a multi-vendor platform or a niche store, we create a solution customized to your business needs. Get a ready-to-go, feature-rich eCommerce platform that helps you grow faster.
Start your online store today—affordable, efficient, and built for success! Contact us now.
Visit now >> https://www.beleaftechnologies.com/amazon-clone
Whatsapp :  +91 8056786622
Email id :  business@beleaftechnologies.com
Telegram : https://telegram.me/BeleafSoftTech 
Our vacation rental software is built to streamline and optimize both property listings and calendar management, so you can maximize occupancy, avoid double bookings, and spend less time on manual updates. Here’s how we achieve that:

1. Optimized Property Listings
Centralized Content Management:
Our system provides an intuitive dashboard where you can create, update, and manage all your property details—from photos and descriptions to amenities and pricing. This centralization ensures consistency across all channels.

◦ SEO-Friendly Templates:
Listings are automatically formatted using SEO best practices. This means optimized titles, descriptions, and keyword integration that help improve your property’s visibility in search engines and on OTA platforms.

◦ Channel Integration:
With built-in integrations to major booking sites (like Airbnb, Booking.com, Vrbo, etc.), any updates you make in our software are pushed out automatically. This ensures that your listings are current and that the property details remain uniform across all platforms.

◦ Dynamic Pricing Tools:
Our software can analyze market trends, seasonality, and local demand to suggest dynamic pricing adjustments. This not only keeps your property competitive but also maximizes revenue without requiring constant manual oversight.

◦ Visual & Data-Driven Insights:
The platform provides performance analytics on each listing (views, inquiries, bookings, etc.), allowing you to fine-tune descriptions, photos, or amenities based on real user engagement and feedback.

2. Streamlined Calendar Management
◦ Real-Time Sync Across Channels:
Our integrated calendar automatically syncs booking data from all your connected channels. When a reservation is made on one platform, the dates are instantly blocked on your master calendar and updated across all other channels to prevent double bookings.

◦ Automated Booking & Availability Updates:
When new reservations come in or cancellations occur, our system instantly reflects these changes. This automation reduces manual entry and minimizes the risk of errors.

◦ Intuitive Calendar Interface:
The calendar view is designed for ease of use—featuring drag-and-drop functionality, color-coded statuses, and clear visual indicators for booked, available, or blocked dates. This allows property managers to quickly adjust availability or plan maintenance without hassle.

◦ Custom Rules & Block Booking Options:
You can set specific rules (such as minimum stay requirements or blackout dates) to automatically manage your availability. The system can also handle block bookings for extended periods (like seasonal maintenance or owner usage), ensuring those dates are appropriately reserved.

◦ Automated Notifications & Reminders:
Integrated communication tools automatically notify property managers and guests about upcoming check-ins, check-outs, or schedule changes.

We at Appticz provide vacation rental property management software that leverages automation, robust integrations, and data-driven insights to make listing management and calendar scheduling as effortless as possible. By ensuring that your property listings are appealing, consistent, and SEO-optimized and that your calendars are always up-to-date across all channels, you can focus on delivering great guest experiences while maximizing occupancy and revenue.
return 0 !== n.indexOf("function") 
    ? "production" 
    : -1 !== n.indexOf("storedMeasure") 
        ? "development" 
        : -1 !== n.indexOf("should be a pure function") 
            ? -1 !== n.indexOf("NODE_ENV") || -1 !== n.indexOf("development") || -1 !== n.indexOf("true") 
                ? "development" 
                : -1 !== n.indexOf("nextElement") || -1 !== n.indexOf("nextComponent") 
                    ? "unminified" 
                    : "development" 
            : -1 !== n.indexOf("nextElement") || -1 !== n.indexOf("nextComponent") 
                ? "unminified" 
                : "outdated";




/**
Explanation
Breaking it Down:


First Condition:

0 !== n.indexOf("function") ? "production"
If the string n contains "function" anywhere except at the start (indexOf("function") returns something other than 0), return "production".


Second Condition:
===============
If "storedMeasure" is found in n, return "development".

Third Condition:
===============
If "should be a pure function" is found, check further conditions:

Fourth Condition (nested within the third):
===============
If "NODE_ENV", "development", or "true" are found, return "development".

Fifth Condition (if the above is false):
===============
If "nextElement" or "nextComponent" is found, return "unminified", otherwise return "development".

Final Condition (if "should be a pure function" was NOT found):
===============


If "nextElement" or "nextComponent" is found, return "unminified", otherwise return "outdated".
*/



<div class="card-container">
	<span class="pro">PRO</span>
	<img class="round" src="https://randomuser.me/api/portraits/women/79.jpg" alt="user" />
	<h3>Ricky Park</h3>
	<h6>New York</h6>
	<p>User interface designer and <br/> front-end developer</p>
	<div class="buttons">
		<button class="primary">
			Message
		</button>
		<button class="primary ghost">
			Following
		</button>
	</div>
	<div class="skills">
		<h6>Skills</h6>
		<ul>
			<li>UI / UX</li>
			<li>Front End Development</li>
			<li>HTML</li>
			<li>CSS</li>
			<li>JavaScript</li>
			<li>React</li>
			<li>Node</li>
		</ul>
	</div>
</div>

<footer>
	<p>
		Created with <i class="fa fa-heart"></i> by
		<a target="_blank" href="https://florin-pop.com">Florin Pop</a>
		- Read how I created this
		<a target="_blank" href="https://florin-pop.com/blog/2019/04/profile-card-design">here</a>
		- Design made by
		<a target="_blank" href="https://dribbble.com/shots/6276930-Profile-Card-UI-Design">Ildiesign</a>
	</p>
</footer>
 function adjustGrid(number) {
        if (parentGrid) {
            parentGrid.dataset.grid = `courses-${number}`;
            parentGrid.style.setProperty("--compare-col-count", number);

            const gridOptions = {
                1: () => cssColWidthVariable("minmax(205px, 230px)"),
                2: () => cssColWidthVariable("minmax(205px, 249px)"),
                3: () => cssColWidthVariable("minmax(205px, 1fr)"),
                4: () => cssColWidthVariable("minmax(205px, 1fr)"),
            };

            number = gridOptions[number] || "205px";
        }
    }


 function cssColWidthVariable(value) {
        if (parentGrid) {
            parentGrid.style.setProperty("--compare-col-width", value);
        }
    }


adjustGrid(JSON.parse(localStorage.getItem("courses") || "[]").length);



// the css
 &__courses {
      display: grid;
      grid-template-columns: clamp(120px, 39vw, 180px) repeat(var(--compare-col-count, 4), var(--compare-col-width, 205px));
      grid-template-rows: repeat(2, 1fr) repeat(6, 90px) repeat(1, 1fr);
      z-index: 1;
      column-gap: 1.6rem;
 }
SELECT emailaddress, COUNT(*) AS count

FROM [w170049_newsletters_journey_ALL]

GROUP BY emailaddress

HAVING COUNT(*) > 1
SELECT
mst.EmailAddress, ot.Identifier__c, ot.Identifier_Group__c, ot.contact_ID__c, mst.SubscriberKey, mst.Consent_Level_Summary__c, mst.FirstName, mst.LastName, mst.CreatedDate, 
mst.Mailing_Country__c, mst.Region, mst.SegmentRegion, mst.Job_Role__c, RecordTypeId


FROM ep_mr_en_us_w170049_MASTER mst
JOIN ent.Contact_Salesforce_1 c ON LOWER(c.Email) = LOWER(mst.EmailAddress)
JOIN ent.Contact_Identifier__c_Salesforce_1 ot ON mst.SubscriberKey = ot.contact_ID__c


WHERE ot.Identifier_Group__c =  'OTPreferenceCentreLink'
AND c.RecordTypeId = '0121G0000005wgHQAQ'
#include <stdio.h> 
#include <stdlib.h> 
#include <stdbool.h> // Include this for the bool type 
int* IntVector; 
void bar(void) 
{ 
    printf("Augh! I've been hacked!\n"); 
} 
void InsertInt(unsigned long index, unsigned long value) 
{ 
    // Check for bounds before accessing the array 
    if (index >= 0xffff) { 
        printf("Index out of bounds!\n"); 
        return; 
    } 
    printf("Writing memory at %p\n", &(IntVector[index])); 
    IntVector[index] = value; 
} 
bool InitVector(unsigned long size) 
{ 
    IntVector = (int*)malloc(sizeof(int) * size); 
    if (IntVector == NULL) { 
        return false; 
    } 
    printf("Address of IntVector is %p\n", IntVector); 
    return true; 
} 
int main(int argc, char* argv[]) 
{ 
    unsigned long index, value; 
    if (argc != 3) 
    { 
        printf("Usage: %s [index] [value]\n", argv[0]); 
        return -1; 
    } 
    if (!InitVector(0xffff)) 
    { 
        printf("Cannot initialize vector!\n"); 
    } 
        return -1; 
    index = atol(argv[1]); 
    value = atol(argv[2]); 
    InsertInt(index, value); 
    // Free allocated memory 
    free(IntVector); 
    return 0; 
} 
=iif(First(Fields!Conditions.Value, "POHeader") <> "", false,true)
-- PARDEEP QUERY
SELECT A.*
, COALESCE(B.deviceid, C.deviceid) as deviceid
, COALESCE(B.subscriberid, C.subscriberid) as subscriberid
, COALESCE(B.paymethod, C.paymethod) as paymethod
, COALESCE(B.usergeohash4, C.usergeohash4) as usergeohash4
, COALESCE(B.paytmmerchantid, COALESCE(EDC.e_mid, QR.merchant_id)) as merchant_type
FROM
    (SELECT *
    FROM team_team_risk.Last_4_Months_I4C_Cybercell_data)A
LEFT JOIN
    -- ONUS USERS
    (select distinct transactionid, deviceid, subscriberid, paymethod, usergeohash4, paytmmerchantid
    FROM cdp_risk_transform.maquette_flattened_onus_snapshot_v3
    WHERE dl_last_updated >= date'2024-01-01')B
ON A.txn_id = B.transactionid
LEFT JOIN
    -- OFFUS USERS
    (select distinct transactionid, deviceid, subscriberid, paymethod, usergeohash4, paytmmerchantid
    FROM cdp_risk_transform.maquette_flattened_offus_snapshot_v3
    WHERE dl_last_updated >= date'2024-01-01')C
ON A.txn_id = B.transactionid
LEFT JOIN
    (SELECT DISTINCT mid AS e_mid FROM paytmpgdb.entity_edc_info_snapshot_v3 
    WHERE terminal_status = 'ACTIVE' AND dl_last_updated >= DATE '2010-01-01')EDC
ON C.paytmmerchantid = EDC.e_mid
LEFT JOIN 
    (SELECT DISTINCT merchant_id from datalake.online_payment_merchants)QR
ON C.paytmmerchantid = QR.merchant_id
LIMIT 100
;
[autoCalendar]: 
  DECLARE FIELD DEFINITION Tagged ('$date')
FIELDS
  Dual(Year($1), YearStart($1)) AS [Year] Tagged ('$axis', '$year'),
  Dual('Q'&Num(Ceil(Num(Month($1))/3)),Num(Ceil(NUM(Month($1))/3),00)) AS [Quarter] Tagged ('$quarter', '$cyclic'),
  Dual(Year($1)&'-Q'&Num(Ceil(Num(Month($1))/3)),QuarterStart($1)) AS [YearQuarter] Tagged ('$yearquarter', '$qualified'),
  Dual('Q'&Num(Ceil(Num(Month($1))/3)),QuarterStart($1)) AS [_YearQuarter] Tagged ('$yearquarter', '$hidden', '$simplified'),
  Month($1) AS [Month] Tagged ('$month', '$cyclic'),
  Dual(Year($1)&'-'&Month($1), monthstart($1)) AS [YearMonth] Tagged ('$axis', '$yearmonth', '$qualified'),
  Dual(Month($1), monthstart($1)) AS [_YearMonth] Tagged ('$axis', '$yearmonth', '$simplified', '$hidden'),
  Dual('W'&Num(Week($1),00), Num(Week($1),00)) AS [Week] Tagged ('$weeknumber', '$cyclic'),
  Date(Floor($1)) AS [Date] Tagged ('$axis', '$date', '$qualified'),
  Date(Floor($1), 'D') AS [_Date] Tagged ('$axis', '$date', '$hidden', '$simplified'),
  If (DayNumberOfYear($1) <= DayNumberOfYear(Today()), 1, 0) AS [InYTD] ,
  Year(Today())-Year($1) AS [YearsAgo] ,
  If (DayNumberOfQuarter($1) <= DayNumberOfQuarter(Today()),1,0) AS [InQTD] ,
  4*Year(Today())+Ceil(Month(Today())/3)-4*Year($1)-Ceil(Month($1)/3) AS [QuartersAgo] ,
  Ceil(Month(Today())/3)-Ceil(Month($1)/3) AS [QuarterRelNo] ,
  If(Day($1)<=Day(Today()),1,0) AS [InMTD] ,
  12*Year(Today())+Month(Today())-12*Year($1)-Month($1) AS [MonthsAgo] ,
  Month(Today())-Month($1) AS [MonthRelNo] ,
  If(WeekDay($1)<=WeekDay(Today()),1,0) AS [InWTD] ,
  (WeekStart(Today())-WeekStart($1))/7 AS [WeeksAgo] ,
  Week(Today())-Week($1) AS [WeekRelNo] ;

DERIVE FIELDS FROM FIELDS
[Afleverdatum],[Besteldatum],[Contracteinddatum],[Contractstartdatum],[Factuuraudit wijzigingstimestamp],[Factuur vervaldatum],[Factuurdatum],[Leverancier factuurdatum],[Leverancier_aangemaakt_op],[Ontvangstdatum],[Orderdatum],

Inventory_org.lastissuedate, Inventory_org.nextinvoicedate, Inventory_org.statusdate, Po_org.changedate, Po_org.ecomstatusdate, Po_org.enddate, Po_org.exchangedate, Po_org.followupdate, 
Po_org.orderdate, Po_org.requireddate, Po_org.startdate, Po_org.statusdate, Po_org.vendeliverydate, Poline_org.enterdate,
Poline_org.pcardexpdate,
Poline_org.reqdeliverydate,
Poline_org.vendeliverydate,
Pr_org.changedate,
Pr_org.exchangedate,
Pr_org.issuedate,
Pr_org.pcardexpdate,
Pr_org.requireddate,
Pr_org.statusdate,
Prline_org.enterdate,
Prline_org.pcardexpdate,
Prline_org.reqdeliverydate,
Prline_org.vendeliverydate

USING [autoCalendar] ;
const sameNumbers = (arr1, arr2) => {
  if (arr1.length !== arr2.length) return false;
  
  for (let i = 0; i < arr1.length; i++) {
    let correctIndex = arr2.indexOf(arr1[i] ** 2);
    if (correctIndex === -1) {
      return false;
    }
    arr2.splice(correctIndex, 1);
  }
  
  return true;
};
 for(let button of cookieBtns){
                button.addEventListener('click', function(){
                    if(this.matches('.accept')){
                        if(cookieContainer.classList.contains('show')){
                            cookieContainer.classList.remove('show');
                            setCookie('site_notice_dismissed', 'true', 30);
                            setCookie('testing', true, 30)
                        }
                    }
                    
                    if(this.matches('.decline')){
                         if(cookieContainer.classList.contains('show')){
                            cookieContainer.classList.remove('show');
                            eraseCookie('site_notice_dismissed');
                        }
                    }
                })
 }




function cookieBtnUpdate() {
    
            const cookieBtns = document.querySelectorAll('button[data-cookie="btn"]');
            const cookieContainer = document.querySelector('.smp-global-alert');
           
           
           // functions
           function setCookie(name,value,days) {
            var expires = "";
            if (days) {
                var date = new Date();
                date.setTime(date.getTime() + (days*24*60*60*1000));
                expires = "; expires=" + date.toUTCString();
            }
            
            document.cookie = name + "=" + (value || "")  + expires + "; path=/";
            }
            
            function eraseCookie(name) {   
            document.cookie = name+'=; Max-Age=-99999999;';  
            }


            //event on buttons
            for(let button of cookieBtns){
                button.addEventListener('click', function(){
                    if(this.matches('.accept')){
                        console.log(this)
                    }
                    
                    if(this.matches('.decline')){
                         console.log(this)
                    }
                })
            }
            
            
}


cookieBtnUpdate();
# Step 1: Define the list of URLs
$urls = @(
    "https://example.com/page1",
    "https://example.com/page2",
    "https://example.com/page3"
    # Add more URLs here
)
# Step 2: Loop through URLs and process them
foreach ($url in $urls) {
    try {
        # Fetch the HTML content
        $response = Invoke-WebRequest -Uri $url
        $htmlContent = $response.Content
        # Use regex to extract the JSON string
        if ($htmlContent -match 'var data\s*=\s*({.*?})\s*;') {
            $jsonString = $matches[1]
        } else {
            Write-Output "No JSON data found in $url"
            continue
        }
        # Clean up the JSON string (remove escape characters, etc.)
        $jsonString = $jsonString -replace '\\/', '/'
        # Convert the JSON string to a PowerShell object
        $jsonObject = $jsonString | ConvertFrom-Json
        # Display the JSON object
        Write-Output "JSON from $url:"
        $jsonObject | Format-List
    } catch {
        Write-Output "Failed to process $url: $_"
    }
}
(function () {
  "use strict";

  // object instead of switch

  // check for oddf or even number using the function insides the object
  const options = {
    odd: (item) => item % 2 === 1,
    even: (item) => item % 2 === 0,
  };

  const number = 7;
  const checkValue = "odd";

  const checked = options[checkValue](number); // returns true of false
  if (checked) {
    console.log(number);
  }

  const testArray = [3, 4, 5, 6, 8, 0, 12, 40, 12, 3];

  function filterArray(array, position) {
    return array.filter((item) => options[position](item));
  }

  const getOdd = filterArray(testArray, "odd");
  console.log("Odd", getOdd);

  const getEven = filterArray(testArray, "even");
  console.log("Even", getEven);
})();
{
    // window.onload = function() {}⇨コンテンツが全て読み込み終わったらローディング画面を終了するやり方
    
    setTimeout(function() {
        const loading = document.getElementById('loading');
        loading.classList.add('loaded');
        const container = document.querySelector('.container');
        container.classList.add('open')
    }, 3000);
}
{
    const loading = document.getElementById('loading');
    loading.classList.add('loaded');
    const container = document.querySelector('.container');
}
.dot__item {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #fafafa;
    animation: wave 1.5s infinite ease-in-out;
}

.dot__item:nth-of-type(1) {
    animation: wave 1.5s infinite ease-in-out;
}

.dot__item:nth-of-type(2) {
    animation: wave 1.5s 0.2s infinite ease-in-out;
}

.dot__item:nth-of-type(3) {
    animation: wave 1.5s 0.4s infinite ease-in-out;
}
.dot {
    width: 200px;
    height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0 24px;

    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}
/* animation */
@keyframes wave {
    0% {
        opacity: 0;
        transform: scale(1, 1);
    }
    50% {
        opacity: 1;
        transform: scale(2, 2);
    }
    100% {
        opacity: 0;
        transform: scale(1, 1);
    }
}
Generate a report on interview experiences and questions for the [Senior Software Engineer] at [Cdk global], using web search and analysis of platforms like LeetCode Discuss, Glassdoor, Reddit, Medium, Indeed, LinkedIn, GeeksforGeeks, X, other public career forums or blogs, etc. Include: •	Brief overview of [cdk global] and [senior software engineer]. •	Typical interview process (rounds, types, duration). •	At least 7 unique firsthand candidate experiences (stages, details, advice). •	Categorized list of at least 30 unique interview questions (technical, behavioral, etc.). •	Insights and preparation tips, including strategies to maximize chances of getting interview calls. If data for senior software engineer is limited, use similar roles and note the extrapolation. Ensure the report is thorough, well-organized, and practical for interview preparation.
 * Ventoy

 * Overclock Checking Tool (OCCT)

 * Local Send

 * Clip Shelf

 * Signal RGB

 * f.lux

 * One Commander

 * Wind Hawk

 * Bleach Bit

 * Flow Launcher BUT fluent search is better

 * Mouse Without Borders
 
 * Auto hot keys AHK
star

Wed Mar 12 2025 10:23:35 GMT+0000 (Coordinated Universal Time)

star

Wed Mar 12 2025 10:06:38 GMT+0000 (Coordinated Universal Time)

@SrijanVerma

star

Wed Mar 12 2025 09:24:07 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Wed Mar 12 2025 09:23:06 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Wed Mar 12 2025 09:22:33 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Wed Mar 12 2025 09:22:02 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Wed Mar 12 2025 09:21:27 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Wed Mar 12 2025 09:20:38 GMT+0000 (Coordinated Universal Time)

@Pooja

star

Wed Mar 12 2025 02:21:46 GMT+0000 (Coordinated Universal Time)

@TuckSmith541

star

Wed Mar 12 2025 02:19:55 GMT+0000 (Coordinated Universal Time)

@TuckSmith541

star

Wed Mar 12 2025 02:17:10 GMT+0000 (Coordinated Universal Time)

@TuckSmith541

star

Tue Mar 11 2025 23:18:40 GMT+0000 (Coordinated Universal Time) https://sphinx-theme-builder.readthedocs.io/en/latest/tutorial/#installation

@TuckSmith541

star

Tue Mar 11 2025 22:00:56 GMT+0000 (Coordinated Universal Time)

@davidmchale #async #await #resolve #reject

star

Tue Mar 11 2025 21:49:03 GMT+0000 (Coordinated Universal Time) https://sphinx-theme-builder.readthedocs.io/en/latest/tutorial/

@TuckSmith541

star

Tue Mar 11 2025 21:38:13 GMT+0000 (Coordinated Universal Time)

@andi

star

Tue Mar 11 2025 20:29:46 GMT+0000 (Coordinated Universal Time)

@Hassnain_Abbas #html

star

Tue Mar 11 2025 16:37:25 GMT+0000 (Coordinated Universal Time)

@mehran

star

Tue Mar 11 2025 15:58:57 GMT+0000 (Coordinated Universal Time) https://sphinx-theme-builder.readthedocs.io/en/latest/filesystem-layout/

@TuckSmith541

star

Tue Mar 11 2025 15:56:56 GMT+0000 (Coordinated Universal Time) https://sphinx-theme-builder.readthedocs.io/en/latest/build-process/

@TuckSmith541

star

Tue Mar 11 2025 15:45:02 GMT+0000 (Coordinated Universal Time) https://docs.github.com/en/get-started/git-basics/setting-your-username-in-git

@TuckSmith541

star

Tue Mar 11 2025 15:34:18 GMT+0000 (Coordinated Universal Time) https://cli.github.com/manual/gh_attestation_download

@TuckSmith541

star

Tue Mar 11 2025 15:32:31 GMT+0000 (Coordinated Universal Time)

@TuckSmith541

star

Tue Mar 11 2025 15:05:46 GMT+0000 (Coordinated Universal Time) https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/configuring-dev-containers/adding-features-to-a-devcontainer-file

@TuckSmith541

star

Tue Mar 11 2025 13:25:11 GMT+0000 (Coordinated Universal Time)

@quanganh141220 #ajax #blog #pagination

star

Tue Mar 11 2025 13:23:39 GMT+0000 (Coordinated Universal Time)

@quanganh141220 #ajax #blog #pagination

star

Tue Mar 11 2025 13:22:43 GMT+0000 (Coordinated Universal Time)

@quanganh141220 #ajax #blog #pagination

star

Tue Mar 11 2025 07:19:52 GMT+0000 (Coordinated Universal Time) https://www.addustechnologies.com/blog/winzo-clone-app

@Seraphina

star

Tue Mar 11 2025 06:26:30 GMT+0000 (Coordinated Universal Time) https://www.beleaftechnologies.com/amazon-clone

@raydensmith #amazon #amazonclonewithreactjs #amazonclonewithhtml

star

Tue Mar 11 2025 05:35:47 GMT+0000 (Coordinated Universal Time) https://appticz.com/vacation-rental-software

@aditi_sharma_

star

Tue Mar 11 2025 03:07:34 GMT+0000 (Coordinated Universal Time)

@davidmchale #indexof()

star

Tue Mar 11 2025 03:06:24 GMT+0000 (Coordinated Universal Time) https://codepen.io/FlorinPop17/pen/EJKgKB

@harddoxlife ##html

star

Mon Mar 10 2025 21:55:48 GMT+0000 (Coordinated Universal Time)

@davidmchale #object #functions #mapping

star

Mon Mar 10 2025 20:51:02 GMT+0000 (Coordinated Universal Time)

@shirnunn

star

Mon Mar 10 2025 19:26:58 GMT+0000 (Coordinated Universal Time)

@shirnunn

star

Mon Mar 10 2025 18:10:37 GMT+0000 (Coordinated Universal Time)

@aksharayadav

star

Mon Mar 10 2025 12:07:53 GMT+0000 (Coordinated Universal Time) https://appticz.com/binance-clone-script

@davidscott

star

Mon Mar 10 2025 09:15:49 GMT+0000 (Coordinated Universal Time)

@MinaTimo

star

Mon Mar 10 2025 08:46:40 GMT+0000 (Coordinated Universal Time)

@shubhangi.b

star

Mon Mar 10 2025 07:33:35 GMT+0000 (Coordinated Universal Time) https://htm-rapportage.eu.qlikcloud.com/sense/app/31e81d97-d7f2-4901-a1b1-1e4a177b5c88

@bogeyboogaard

star

Mon Mar 10 2025 02:18:45 GMT+0000 (Coordinated Universal Time)

@IA11

star

Sun Mar 09 2025 21:41:12 GMT+0000 (Coordinated Universal Time)

@davidmchale #cookie

star

Sat Mar 08 2025 14:31:13 GMT+0000 (Coordinated Universal Time) https://medium.com/@rihab.beji099/automating-html-parsing-and-json-extraction-from-multiple-urls-using-powershell-3c0ce3a93292#id_token

@baamn

star

Sat Mar 08 2025 05:42:25 GMT+0000 (Coordinated Universal Time)

@davidmchale #swtich #object #condition

star

Sat Mar 08 2025 05:15:00 GMT+0000 (Coordinated Universal Time)

@erika

star

Sat Mar 08 2025 04:17:47 GMT+0000 (Coordinated Universal Time)

@erika

star

Sat Mar 08 2025 03:53:43 GMT+0000 (Coordinated Universal Time)

@erika

star

Sat Mar 08 2025 03:49:40 GMT+0000 (Coordinated Universal Time)

@erika

star

Sat Mar 08 2025 03:47:39 GMT+0000 (Coordinated Universal Time)

@erika

star

Sat Mar 08 2025 03:36:29 GMT+0000 (Coordinated Universal Time)

@hungj #ai

star

Fri Mar 07 2025 18:20:10 GMT+0000 (Coordinated Universal Time)

@StephenThevar

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension