1html
2        <!-- Calculator -->
3        <div id="calculatorContainer" class="calculator-container bg-white rounded-xl overflow-hidden">
4            <!-- Input Section -->
5            <div class="bg-gradient-to-r from-navy to-teal p-6 text-white">
6                <h2 class="text-xl font-bold mb-4 font-quicksand">Enter Employee Details</h2>
7                <div class="flex flex-col sm:flex-row gap-4">
8                    <div class="flex-1">
9                        <label for="baseSalary" class="block text-sm font-medium mb-1 font-montserrat">Base Monthly Salary (USD)</label>
10                        <div class="relative">
11                            <span class="absolute inset-y-0 left-0 pl-3 flex items-center text-white/80">$</span>
12                            <input type="number" id="baseSalary" class="w-full bg-white/20 border border-white/30 rounded-lg py-2 pl-8 pr-3 text-white placeholder-white/60 focus:border-white font-montserrat" placeholder="Enter amount" value="1500">
13                        </div>
14                    </div>
15                </div>
16            </div>
17            
18            <!-- Results Section -->
19            <div class="p-6 font-montserrat">
20                <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
21                    <!-- Left Column -->
22                    <div>
23                        <h3 class="text-lg font-bold text-navy mb-4 font-quicksand">Monthly EOR Contributions</h3>
24                        <div class="space-y-3">
25                            <div class="result-row flex justify-between p-2 border-b border-gray-100">
26                                <span class="text-gray-600 flex items-center">
27                                    IHSS (Health) - 5% 
28                                    <div class="tooltip ml-1">
29                                        <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
30                                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
31                                        </svg>
32                                        <span class="tooltiptext">Capped at $480</span>
33                                    </div>
34                                </span>
35                                <span id="ihssHealth" class="font-medium">$24.00</span>
36                            </div>
37                            <div class="result-row flex justify-between p-2 border-b border-gray-100">
38                                <span class="text-gray-600 flex items-center">
39                                    IHSS (Disability/Old Age) - 4% 
40                                    <div class="tooltip ml-1">
41                                        <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
42                                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
43                                        </svg>
44                                        <span class="tooltiptext">Capped at $480</span>
45                                    </div>
46                                </span>
47                                <span id="ihssDisability" class="font-medium">$19.20</span>
48                            </div>
49                            <div class="result-row flex justify-between p-2 border-b border-gray-100">
50                                <span class="text-gray-600">RAP - Severance Reserve - 4%</span>
51                                <span id="rapSeverance" class="font-medium">$60.00</span>
52                            </div>
53                            <div class="result-row flex justify-between p-2 border-b border-gray-100">
54                                <span class="text-gray-600">RAP - Pension - 1.5%</span>
55                                <span id="rapPension" class="font-medium">$22.50</span>
56                            </div>
57                            <div class="result-row flex justify-between p-2 border-b border-gray-100">
58                                <span class="text-gray-600">INFOP - 1%</span>
59                                <span id="infop" class="font-medium">$15.00</span>
60                            </div>
61                            <div class="result-row flex justify-between p-2 border-b border-gray-100">
62                                <span class="text-gray-600">13th & 14th Month Bonus - 16.67%</span>
63                                <span id="bonuses" class="font-medium">$250.05</span>
64                            </div>
65                            <div class="bg-navy/5 p-3 rounded-lg mt-2">
66                                <div class="flex justify-between font-semibold">
67                                    <span class="text-navy font-quicksand">EOR Contributions Subtotal</span>
68                                    <span id="contributionsSubtotal" class="text-navy">$390.75</span>
69                                </div>
70                            </div>
71                        </div>
72                    </div>
73                    
74                    <!-- Right Column -->
75                    <div>
76                        <h3 class="text-lg font-bold text-navy mb-4 font-quicksand">Monthly Escrow Reserves</h3>
77                        <div class="space-y-3">
78                            <div class="result-row flex justify-between p-2 border-b border-gray-100">
79                                <span class="text-gray-600 flex items-center">
80                                    Vacation Accrual
81                                    <div class="tooltip ml-1">
82                                        <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
83                                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
84                                        </svg>
85                                        <span class="tooltiptext">10 days per year (Daily salary = Base salary ÷ 30)</span>
86                                    </div>
87                                </span>
88                                <span id="vacationEscrow" class="font-medium">$41.67</span>
89                            </div>
90                            <div class="result-row flex justify-between p-2 border-b border-gray-100">
91                                <span class="text-gray-600 flex items-center">
92                                    Notice Provision
93                                    <div class="tooltip ml-1">
94                                        <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
95                                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" />
96                                        </svg>
97                                        <span class="tooltiptext">14 days per year (Daily salary = Base salary ÷ 30)</span>
98                                    </div>
99                                </span>
100                                <span id="noticeEscrow" class="font-medium">$58.33</span>
101                            </div>
102                            <div class="bg-navy/5 p-3 rounded-lg mt-2">
103                                <div class="flex justify-between font-semibold">
104                                    <span class="text-navy font-quicksand">Monthly Escrow Subtotal</span>
105                                    <span id="escrowSubtotal" class="text-navy">$100.00</span>
106                                </div>
107                            </div>
108                            
109                            <div class="result-row flex justify-between p-2 border-b border-gray-100 mt-4">
110                                <span class="text-gray-600">Base Salary</span>
111                                <span id="baseSalaryDisplay" class="font-medium">$1,500.00</span>
112                            </div>
113                            <div class="result-row flex justify-between p-2 border-b border-gray-100">
114                                <span class="text-gray-600">WIND HR Monthly Service Fee</span>
115                                <span id="serviceFee" class="font-medium">$300.00</span>
116                            </div>
117                        </div>
118                    </div>
119                </div>
120                
121                <!-- Total Section -->
122                <div class="mt-8 bg-gradient-to-r from-teal/10 to-coral/10 p-4 rounded-lg border border-teal/20">
123                    <div class="flex flex-col sm:flex-row justify-between items-center">
124                        <span class="text-lg font-bold text-navy mb-2 sm:mb-0 font-quicksand">Final Total Monthly Cost</span>
125                        <div class="text-right">
126                            <div id="totalCost" class="text-2xl font-bold text-teal font-quicksand">$2,290.75</div>
127                        </div>
128                    </div>
129                </div>
130                
131                <!-- Action Buttons -->
132                <div class="mt-6 flex flex-col sm:flex-row gap-3 justify-end">
133                    <button id="downloadPdf" class="px-4 py-2 bg-white border border-gray-300 rounded-lg text-navy font-medium hover:bg-gray-50 transition-colors flex items-center justify-center font-quicksand">
134                        <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2 text-navy" fill="none" viewBox="0 0 24 24" stroke="currentColor">
135                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 10v6m0 0l-3-3m3 3l3-3m2 8H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" />
136                        </svg>
137                        Download as PDF
138                    </button>
139                    <button id="requestQuote" class="px-4 py-2 bg-coral rounded-lg text-white font-medium hover:bg-coral/90 transition-colors flex items-center justify-center font-quicksand">
140                        <svg xmlns="http://www.w3.org/2000/svg" class="h-5 w-5 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
141                            <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2" />
142                        </svg>
143                        Request Formal Quote
144                    </button>
145                </div>
146            </div>
147        </div>
148        
149        <!-- Footer -->
150        <div class="mt-8 text-center">
151            <div class="flex justify-center items-center mb-3">
152                <div class="h-8 w-8 rounded-full bg-navy flex items-center justify-center text-white font-bold mr-2 font-quicksand">W</div>
153                <span class="text-navy font-bold font-quicksand">WIND HR</span>
154            </div>
155            <p class="text-sm text-gray-500 font-montserrat">© 2025 WIND HR. All calculations are estimates and may vary based on specific circumstances.</p>
156        </div>
157    </div>
158</div>
159
160<!-- Email Request Modal -->
161<div id="emailModal" class="modal">
162    <div class="modal-content">
163        <span class="close-modal">&times;</span>
164        <h2 class="text-xl font-bold text-navy mb-4 font-quicksand">Request Formal Quote</h2>
165        <form id="quoteForm" class="space-y-4">
166            <div>
167                <label for="name" class="block text-sm font-medium mb-1 font-montserrat">Your Name</label>
168                <input type="text" id="name" class="w-full border border-gray-300 rounded-lg py-2 px-3 focus:outline-none focus:ring-2 focus:ring-teal/50" required>
169            </div>
170            <div>
171                <label for="email" class="block text-sm font-medium mb-1 font-montserrat">Your Email</label>
172                <input type="email" id="email" class="w-full border border-gray-300 rounded-lg py-2 px-3 focus:outline-none focus:ring-2 focus:ring-teal/50" required>
173            </div>
174            <div>
175                <label for="company" class="block text-sm font-medium mb-1 font-montserrat">Company Name</label>
176                <input type="text" id="company" class="w-full border border-gray-300 rounded-lg py-2 px-3 focus:outline-none focus:ring-2 focus:ring-teal/50" required>
177            </div>
178            <div>
179                <label for="message" class="block text-sm font-medium mb-1 font-montserrat">Additional Information</label>
180                <textarea id="message" rows="3" class="w-full border border-gray-300 rounded-lg py-2 px-3 focus:outline-none focus:ring-2 focus:ring-teal/50"></textarea>
181            </div>
182            <div class="flex justify-end">
183                <button type="submit" class="px-4 py-2 bg-coral rounded-lg text-white font-medium hover:bg-coral/90 transition-colors font-quicksand">Send Request</button>
184            </div>
185        </form>
186    </div>
187</div>
188
189<!-- Hidden div for PDF generation -->
190<div id="pdfContent">
191    <!-- This will be populated with content for PDF generation -->
192</div>
193
194<script>
195    // Make jsPDF available in the global scope
196    window.jspdf = window.jspdf || {};
197    
198    // Get DOM elements
199    const baseSalaryInput = document.getElementById('baseSalary');
200    const baseSalaryDisplay = document.getElementById('baseSalaryDisplay');
201    const ihssHealth = document.getElementById('ihssHealth');
202    const ihssDisability = document.getElementById('ihssDisability');
203    const rapSeverance = document.getElementById('rapSeverance');
204    const rapPension = document.getElementById('rapPension');
205    const infop = document.getElementById('infop');
206    const bonuses = document.getElementById('bonuses');
207    const vacationEscrow = document.getElementById('vacationEscrow');
208    const noticeEscrow = document.getElementById('noticeEscrow');
209    const contributionsSubtotal = document.getElementById('contributionsSubtotal');
210    const escrowSubtotal = document.getElementById('escrowSubtotal');
211    const totalCost = document.getElementById('totalCost');
212    const serviceFee = document.getElementById('serviceFee');
213    const downloadPdfBtn = document.getElementById('downloadPdf');
214    const requestQuoteBtn = document.getElementById('requestQuote');
215    const emailModal = document.getElementById('emailModal');
216    const closeModal = document.querySelector('.close-modal');
217    const quoteForm = document.getElementById('quoteForm');
218    const pdfContent = document.getElementById('pdfContent');
219    
220    // Format currency function
221    function formatCurrency(amount) {
222        return `$${amount.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, ',')}`;
223    }
224    
225    // Calculate all values
226    function calculateValues() {
227        const baseSalary = parseFloat(baseSalaryInput.value) || 0;
228        
229        // Calculate contributions with caps
230        const healthContributionUncapped = baseSalary * 0.05;
231        const healthContribution = Math.min(healthContributionUncapped, 24); // 5% of $480 cap = $24
232        
233        const disabilityContributionUncapped = baseSalary * 0.04;
234        const disabilityContribution = Math.min(disabilityContributionUncapped, 19.2); // 4% of $480 cap = $19.20
235        
236        const severanceReserve = baseSalary * 0.04;
237        const pensionContribution = baseSalary * 0.015;
238        const infopContribution = baseSalary * 0.01;
239        const monthlyBonuses = baseSalary * 0.1667;
240        
241        // Calculate monthly escrow amounts using the correct formula
242        const dailySalary = baseSalary / 30;
243        
244        // Vacation: 10 days per year, divided by 12 for monthly amount
245        const annualVacationEscrow = dailySalary * 10;
246        const monthlyVacationEscrow = annualVacationEscrow / 12;
247        
248        // Notice: 14 days per year, divided by 12 for monthly amount
249        const annualNoticeEscrow = dailySalary * 14;
250        const monthlyNoticeEscrow = annualNoticeEscrow / 12;
251        
252        const monthlyEscrowTotal = monthlyVacationEscrow + monthlyNoticeEscrow;
253        
254        // Calculate subtotals
255        const contributionsTotal = healthContribution + disabilityContribution + severanceReserve + 
256                                  pensionContribution + infopContribution + monthlyBonuses;
257        
258        // Service fee
259        const serviceFeeAmount = 300;
260        
261        // Calculate final total (monthly)
262        const total = baseSalary + contributionsTotal + monthlyEscrowTotal + serviceFeeAmount;
263        
264        // Update DOM
265        baseSalaryDisplay.textContent = formatCurrency(baseSalary);
266        ihssHealth.textContent = formatCurrency(healthContribution);
267        ihssDisability.textContent = formatCurrency(disabilityContribution);
268        rapSeverance.textContent = formatCurrency(severanceReserve);
269        rapPension.textContent = formatCurrency(pensionContribution);
270        infop.textContent = formatCurrency(infopContribution);
271        bonuses.textContent = formatCurrency(monthlyBonuses);
272        vacationEscrow.textContent = formatCurrency(monthlyVacationEscrow);
273        noticeEscrow.textContent = formatCurrency(monthlyNoticeEscrow);
274        contributionsSubtotal.textContent = formatCurrency(contributionsTotal);
275        escrowSubtotal.textContent = formatCurrency(monthlyEscrowTotal);
276        serviceFee.textContent = formatCurrency(serviceFeeAmount);
277        totalCost.textContent = formatCurrency(total);
278        
279        return {
280            baseSalary,
281            healthContribution,
282            disabilityContribution,
283            severanceReserve,
284            pensionContribution,
285            infopContribution,
286            monthlyBonuses,
287            monthlyVacationEscrow,
288            monthlyNoticeEscrow,
289            contributionsTotal,
290            monthlyEscrowTotal,
291            serviceFeeAmount,
292            total
293        };
294    }
295    
296    // Generate PDF content
297    function generatePdfContent(data) {
298        const date = new Date().toLocaleDateString();
299        
300        return `
301            <div style="font-family: Arial, sans-serif; max-width: 800px; margin: 0 auto; padding: 20px;">
302                <div style="text-align: center; margin-bottom: 20px;">
303                    <h1 style="color: #033E54; margin-bottom: 5px;">WIND HR EOR Pricing Estimate</h1>
304                    <p style="color: #666;">Generated on ${date}</p>
305                </div>
306                
307                <div style="margin-bottom: 20px;">
308                    <h2 style="color: #033E54; border-bottom: 1px solid #eee; padding-bottom: 10px;">Employee Cost Summary</h2>
309                    <p><strong>Base Monthly Salary:</strong> ${formatCurrency(data.baseSalary)}</p>
310                </div>
311                
312                <div style="display: flex; margin-bottom: 20px;">
313                    <div style="flex: 1; margin-right: 20px;">
314                        <h3 style="color: #033E54;">Monthly EOR Contributions</h3>
315                        <table style="width: 100%; border-collapse: collapse;">
316                            <tr style="border-bottom: 1px solid #eee;">
317                                <td style="padding: 8px 0;">IHSS (Health) - 5%</td>
318                                <td style="text-align: right; padding: 8px 0;">${formatCurrency(data.healthContribution)}</td>
319                            </tr>
320                            <tr style="border-bottom: 1px solid #eee;">
321                                <td style="padding: 8px 0;">IHSS (Disability/Old Age) - 4%</td>
322                                <td style="text-align: right; padding: 8px 0;">${formatCurrency(data.disabilityContribution)}</td>
323                            </tr>
324                            <tr style="border-bottom: 1px solid #eee;">
325                                <td style="padding: 8px 0;">RAP - Severance Reserve - 4%</td>
326                                <td style="text-align: right; padding: 8px 0;">${formatCurrency(data.severanceReserve)}</td>
327                            </tr>
328                            <tr style="border-bottom: 1px solid #eee;">
329                                <td style="padding: 8px 0;">RAP - Pension - 1.5%</td>
330                                <td style="text-align: right; padding: 8px 0;">${formatCurrency(data.pensionContribution)}</td>
331                            </tr>
332                            <tr style="border-bottom: 1px solid #eee;">
333                                <td style="padding: 8px 0;">INFOP - 1%</td>
334                                <td style="text-align: right; padding: 8px 0;">${formatCurrency(data.infopContribution)}</td>
335                            </tr>
336                            <tr style="border-bottom: 1px solid #eee;">
337                                <td style="padding: 8px 0;">13th & 14th Month Bonus - 16.67%</td>
338                                <td style="text-align: right; padding: 8px 0;">${formatCurrency(data.monthlyBonuses)}</td>
339                            </tr>
340                            <tr style="background-color: #f5f5f5;">
341                                <td style="padding: 8px 0;"><strong>EOR Contributions Subtotal</strong></td>
342                                <td style="text-align: right; padding: 8px 0;"><strong>${formatCurrency(data.contributionsTotal)}</strong></td>
343                            </tr>
344                        </table>
345                    </div>
346                    
347                    <div style="flex: 1;">
348                        <h3 style="color: #033E54;">Monthly Escrow Reserves</h3>
349                        <table style="width: 100%; border-collapse: collapse;">
350                            <tr style="border-bottom: 1px solid #eee;">
351                                <td style="padding: 8px 0;">Vacation Accrual</td>
352                                <td style="text-align: right; padding: 8px 0;">${formatCurrency(data.monthlyVacationEscrow)}</td>
353                            </tr>
354                            <tr style="border-bottom: 1px solid #eee;">
355                                <td style="padding: 8px 0;">Notice Provision</td>
356                                <td style="text-align: right; padding: 8px 0;">${formatCurrency(data.monthlyNoticeEscrow)}</td>
357                            </tr>
358                            <tr style="background-color: #f5f5f5;">
359                                <td style="padding: 8px 0;"><strong>Monthly Escrow Subtotal</strong></td>
360                                <td style="text-align: right; padding: 8px 0;"><strong>${formatCurrency(data.monthlyEscrowTotal)}</strong></td>
361                            </tr>
362                        </table>
363                        
364                        <div style="margin-top: 20px;">
365                            <table style="width: 100%; border-collapse: collapse;">
366                                <tr style="border-bottom: 1px solid #eee;">
367                                    <td style="padding: 8px 0;">Base Salary</td>
368                                    <td style="text-align: right; padding: 8px 0;">${formatCurrency(data.baseSalary)}</td>
369                                </tr>
370                                <tr style="border-bottom: 1px solid #eee;">
371                                    <td style="padding: 8px 0;">WIND HR Monthly Service Fee</td>
372                                    <td style="text-align: right; padding: 8px 0;">${formatCurrency(data.serviceFeeAmount)}</td>
373                                </tr>
374                            </table>
375                        </div>
376                    </div>
377                </div>
378                
379                <div style="background-color: #f5f5f5; padding: 15px; border-radius: 5px; margin-top: 20px;">
380                    <div style="display: flex; justify-content: space-between; align-items: center;">
381                        <span style="font-size: 18px; font-weight: bold; color: #033E54;">Final Total Monthly Cost</span>
382                        <span style="font-size: 24px; font-weight: bold; color: #00968A;">${formatCurrency(data.total)}</span>
383                    </div>
384                </div>
385                
386                <div style="margin-top: 30px; text-align: center; color: #666; font-size: 12px;">
387                    <p>This is an estimate provided by WIND HR's EOR Pricing Calculator.</p>
388                    <p>For a formal quote, please contact finance@wind-hr.com</p>
389                    <p>© 2025 WIND HR. All calculations are estimates and may vary based on specific circumstances.</p>
390                </div>
391            </div>
392        `;
393    }
394    
395    // Generate and download PDF
396    async function generatePDF() {
397        const data = calculateValues();
398        
399        // Set content for PDF generation
400        pdfContent.innerHTML = generatePdfContent(data);
401        
402        try {
403            // Use html2canvas to capture the content
404            const canvas = await html2canvas(pdfContent, {
405                scale: 2, // Higher scale for better quality
406                logging: false,
407                useCORS: true
408            });
409            
410            // Initialize jsPDF
411            const { jsPDF } = window.jspdf;
412            const pdf = new jsPDF('p', 'mm', 'a4');
413            
414            // Calculate dimensions
415            const imgWidth = 210; // A4 width in mm
416            const imgHeight = canvas.height * imgWidth / canvas.width;
417            
418            // Add the image to the PDF
419            const imgData = canvas.toDataURL('image/png');
420            pdf.addImage(imgData, 'PNG', 0, 0, imgWidth, imgHeight);
421            
422            // Download the PDF
423            pdf.save('WIND_HR_EOR_Pricing_Estimate.pdf');
424            
425            return pdf;
426        } catch (error) {
427            console.error('Error generating PDF:', error);
428            alert('There was an error generating the PDF. Please try again.');
429            return null;
430        }
431    }
432    
433    // Modal functions
434    function openModal() {
435        emailModal.style.display = 'block';
436    }
437    
438    function closeModalFunc() {
439        emailModal.style.display = 'none';
440    }
441    
442    // Event listeners
443    baseSalaryInput.addEventListener('input', calculateValues);
444    
445    downloadPdfBtn.addEventListener('click', function() {
446        generatePDF();
447    });
448    
449    requestQuoteBtn.addEventListener('click', function() {
450        openModal();
451    });
452    
453    closeModal.addEventListener('click', closeModalFunc);
454    
455    window.addEventListener('click', function(event) {
456        if (event.target === emailModal) {
457            closeModalFunc();
458        }
459    });
460    
461    quoteForm.addEventListener('submit', async function(e) {
462        e.preventDefault();
463        
464        const name = document.getElementById('name').value;
465        const email = document.getElementById('email').value;
466        const company = document.getElementById('company').value;
467        const message = document.getElementById('message').value;
468        
469        // Generate PDF
470        const pdf = await generatePDF();
471        
472        if (pdf) {
473            // In a real implementation, you would send the form data and PDF to a server
474            // Here we'll simulate the email being sent to finance@wind-hr.com
475            
476            alert(`Thank you, ${name}! Your quote request has been sent to finance@wind-hr.com.\n\nA PDF with your calculation has been generated and would be attached to the email in a real implementation.`);
477            
478            closeModalFunc();
479            quoteForm.reset();
480        }
481    });
482    
483    // Initial calculation
484    calculateValues();
485</script>