{"id":7095,"date":"2025-11-22T17:02:04","date_gmt":"2025-11-22T09:02:04","guid":{"rendered":"https:\/\/hobertek.com\/?page_id=7095"},"modified":"2025-11-24T10:00:49","modified_gmt":"2025-11-24T02:00:49","slug":"hober-quote","status":"publish","type":"page","link":"https:\/\/hobertek.com\/es\/hober-quote\/","title":{"rendered":"Cita de Hober"},"content":{"rendered":"<div data-elementor-type=\"wp-page\" data-elementor-id=\"7095\" class=\"elementor elementor-7095\">\n\t\t\t\t\t\t<section class=\"elementor-section elementor-top-section elementor-element elementor-element-d4f671f elementor-section-full_width elementor-section-height-default elementor-section-height-default\" data-id=\"d4f671f\" data-element_type=\"section\" data-e-type=\"section\">\n\t\t\t\t\t\t<div class=\"elementor-container elementor-column-gap-default\">\n\t\t\t\t\t<div class=\"elementor-column elementor-col-100 elementor-top-column elementor-element elementor-element-4177c14\" data-id=\"4177c14\" data-element_type=\"column\" data-e-type=\"column\">\n\t\t\t<div class=\"elementor-widget-wrap elementor-element-populated\">\n\t\t\t\t\t\t<div class=\"elementor-element elementor-element-6aa290c elementor-widget elementor-widget-html\" data-id=\"6aa290c\" data-element_type=\"widget\" data-e-type=\"widget\" data-widget_type=\"html.default\">\n\t\t\t\t<div class=\"elementor-widget-container\">\n\t\t\t\t\t<div id=\"hober-quote-wrapper\">\r\n    <!-- \u5f15\u5165\u5b57\u4f53\u548cPDF\u5e93 -->\r\n    <link href=\"https:\/\/fonts.googleapis.com\/css2?family=Inter:wght@400;600;700;800&display=swap\" rel=\"stylesheet\">\r\n    <script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/html2pdf.js\/0.10.1\/html2pdf.bundle.min.js\"><\/script>\r\n\r\n    <style>\r\n        \/* === \u6837\u5f0f\u9694\u79bb\u5bb9\u5668 === *\/\r\n        #hober-qute-wrapper {\r\n            font-family: 'Inter', sans-serif;\r\n            background: #f4f7f9;\r\n            color: #333;\r\n            height: 950px; \r\n            width: 100%;\r\n            border: 1px solid #e0e0e0;\r\n            border-radius: 12px;\r\n            overflow: hidden;\r\n            box-sizing: border-box;\r\n            position: relative;\r\n            --primary: #0056b3;\r\n            --primary-dark: #003d82;\r\n            --accent: #17a2b8;\r\n            --bg: #f4f7f9;\r\n            --text: #333;\r\n            --border: #dcdfe6;\r\n        }\r\n\r\n        \/* \u91cd\u7f6e\u8be5\u5bb9\u5668\u5185\u7684\u57fa\u7840\u6837\u5f0f *\/\r\n        #hober-quote-wrapper * { box-sizing: border-box; line-height: 1.4; }\r\n        #hober-quote-wrapper h2 { margin: 0; font-size: 16px; color: #333; line-height: 1.2; }\r\n\r\n        .app-container { display: flex; height: 100%; }\r\n\r\n        \/* Left Panel *\/\r\n        .left-panel { \r\n            width: 42%; \r\n            padding: 15px; \r\n            overflow-y: auto; \r\n            background: #fff; \r\n            border-right: 1px solid #ddd; \r\n            display: flex; \r\n            flex-direction: column; \r\n            gap: 12px; \r\n        }\r\n        \r\n        .panel-card { border: 1px solid #eee; border-radius: 6px; padding: 12px; background: #fafafa; margin-bottom: 5px; }\r\n        .panel-title { font-size: 13px; font-weight: 700; color: var(--primary); margin-bottom: 8px; border-bottom: 2px solid #eef; padding-bottom: 4px; }\r\n        \r\n        .form-row { display: flex; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }\r\n        .form-group { flex: 1; min-width: 100px; }\r\n        \r\n        #hober-quote-wrapper label { display: block; font-size: 11px; font-weight: 600; margin-bottom: 3px; color: #666; }\r\n        #hober-quote-wrapper input, \r\n        #hober-quote-wrapper select, \r\n        #hober-quote-wrapper textarea { \r\n            width: 100%; padding: 6px; border: 1px solid #ccc; border-radius: 4px; font-size: 11px; background: #fff; height: auto;\r\n        }\r\n        \r\n        .btn-calc { width: 100%; background: var(--primary); color: #fff; border: none; padding: 10px; border-radius: 4px; cursor: pointer; font-weight: 600; font-size: 12px; text-align: center;}\r\n        .btn-calc:hover { background: var(--primary-dark); }\r\n        \r\n        .btn-add { background: var(--accent); margin-top: 5px; }\r\n        .btn-add:hover { background: #138496; }\r\n\r\n        \/* Editor Table *\/\r\n        .editor-table { width: 100%; border-collapse: collapse; font-size: 10px; background: #fff; }\r\n        .editor-table th { background: #eef2f7; padding: 4px; text-align: left; border: 1px solid #ddd; color:#333; }\r\n        .editor-table td { border: 1px solid #ddd; padding: 0; color:#333; }\r\n        .editor-input { border: none; padding: 4px; width: 100%; height: 100%; font-family: inherit; font-size: 11px; background:transparent;}\r\n        .price-input { text-align: right; color: var(--primary); font-weight: bold; background: #fffdf0; }\r\n        .btn-del { color: red; cursor: pointer; font-weight: bold; border: none; background: none; width: 100%; }\r\n\r\n        \/* Right Panel *\/\r\n        .right-panel { \r\n            width: 58%; \r\n            background: #525659; \r\n            padding: 20px; \r\n            overflow-y: auto; \r\n            display: flex; \r\n            justify-content: center; \r\n            align-items: flex-start;\r\n        }\r\n        \r\n        \/* \u9884\u89c8\u65f6\u7684\u6837\u5f0f *\/\r\n        .a4-paper { \r\n            background: white; \r\n            \/* \u8fd9\u91cc\u7684\u5bbd\u5ea6\u4ec5\u7528\u4e8e\u5c4f\u5e55\u9884\u89c8 *\/\r\n            width: 210mm; \r\n            min-height: 297mm; \r\n            padding: 15mm; \r\n            box-shadow: 0 0 20px rgba(0,0,0,0.5); \r\n            position: relative; \r\n            margin-bottom: 20px;\r\n            color: #000; \r\n            \/* \u5173\u952e\uff1a\u786e\u4fdd padding \u4e0d\u4f1a\u6491\u5927\u5bbd\u5ea6\uff0c\u8fd9\u5bf9\u6253\u5370\u975e\u5e38\u91cd\u8981 *\/\r\n            box-sizing: border-box; \r\n            transform: scale(0.85); \r\n            transform-origin: top center;\r\n        }\r\n\r\n        .quote-header { display: flex; justify-content: space-between; margin-bottom: 15px; }\r\n        .logo-text { font-size: 24px; font-weight: 800; color: var(--primary); letter-spacing: -1px; line-height: 1;}\r\n        .company-intro { font-size: 9px; color: #666; margin-top: 5px; line-height: 1.3; font-style: italic; border-left: 3px solid var(--primary); padding-left: 6px; max-width: 320px; text-align: left;}\r\n        .quote-meta { text-align: right; }\r\n        .meta-title { font-size: 18px; font-weight: 800; color: #333; text-transform: uppercase; margin:0;}\r\n        .meta-row { font-size: 10px; color: #555; margin-top: 2px; }\r\n\r\n        .info-grid { display: flex; justify-content: space-between; margin: 15px 0; gap: 15px; }\r\n        .info-box { flex: 1; background: #f8fbff; padding: 8px; border-radius: 4px; border: 1px solid #eef; font-size: 10px; line-height: 1.5; text-align:left;}\r\n        .info-label { color: var(--primary); font-weight: 700; font-size: 9px; text-transform: uppercase; }\r\n\r\n        .preview-table { width: 100%; border-collapse: collapse; font-size: 10px; margin-top: 10px; }\r\n        .preview-table th { background: var(--primary); color: #fff; padding: 6px; text-align: left; }\r\n        .preview-table td { border-bottom: 1px solid #eee; padding: 6px; vertical-align: top; color: #333; }\r\n        \r\n        \/* \u9632\u6b62\u8868\u683c\u884c\u5728\u6253\u5370\u65f6\u88ab\u5207\u65ad *\/\r\n        .preview-table tr { page-break-inside: avoid; break-inside: avoid; }\r\n        \r\n        .preview-table .num { text-align: right; font-family: 'Inter', monospace; font-weight: 600; }\r\n        .preview-table .item-name { font-weight: 700; font-size: 11px; color: #222; }\r\n        .preview-table .item-desc { color: #666; font-size: 9px; margin-top: 2px; white-space: pre-line; }\r\n\r\n        .total-section { margin-top: 10px; display: flex; justify-content: flex-end; }\r\n        .total-table { width: 45%; border-collapse: collapse; font-size: 11px; }\r\n        .total-table td { padding: 4px 8px; text-align: right; color:#333; }\r\n        .total-final { background: #f0f0f0; font-weight: 700; color: var(--primary); border-top: 1px solid #ddd; font-size: 12px;}\r\n\r\n        .footer { position: absolute; bottom: 15mm; left: 0; width: 100%; text-align: center; font-size: 8px; color: #999; border-top: 1px solid #eee; padding-top: 8px; }\r\n    <\/style>\r\n\r\n    <div class=\"app-container\">\r\n        <!-- Left: Editor -->\r\n        <div class=\"left-panel\">\r\n            <h2>Editor de citas de HOBER<\/h2>\r\n            \r\n            <div class=\"panel-card\">\r\n                <div class=\"panel-title\">1. Clientes y ventas<\/div>\r\n                <div class=\"form-row\">\r\n                    <div class=\"form-group\"><label>Cotizaci\u00f3n No.<\/label><input id=\"in_no\" value=\"HOBER-2025-001\" oninput=\"updateTotals()\"><\/div>\r\n                    <div class=\"form-group\"><label>Fecha<\/label><input type=\"date\" id=\"in_date\" oninput=\"updateTotals()\"><\/div>\r\n                <\/div>\r\n                <div class=\"form-row\">\r\n                    <div class=\"form-group\"><label>Cliente<\/label><input id=\"in_customer\" placeholder=\"Nombre del cliente\" oninput=\"updateTotals()\"><\/div>\r\n                    <div class=\"form-group\"><label>Ventas<\/label>\r\n                        <select id=\"in_sales\" onchange=\"updateSales()\">\r\n                            <option value=\"Stella\">estela<\/option>\r\n                            <option value=\"Janice\">janice<\/option>\r\n                            <option value=\"Sue\">Demandar<\/option>\r\n                            <option value=\"Lily\">Lirio<\/option>\r\n                            <option value=\"Emma\">emma<\/option>\r\n                        <\/select>\r\n                    <\/div>\r\n                <\/div>\r\n            <\/div>\r\n\r\n            <div class=\"panel-card\">\r\n                <div class=\"panel-title\">2. Configuraci\u00f3n autom\u00e1tica del sistema<\/div>\r\n                <div class=\"form-row\">\r\n                    <div class=\"form-group\"><label>Agua (m\u00b3\/d\u00eda)<\/label><input type=\"number\" id=\"sys_flow\" value=\"60\"><\/div>\r\n                    <div class=\"form-group\"><label>Altura total (m)<\/label><input type=\"number\" id=\"sys_head\" value=\"80\"><\/div>\r\n                    <div class=\"form-group\"><label>Tipo<\/label>\r\n                        <select id=\"sys_source\">\r\n                            <option value=\"sub\">Pozo profundo<\/option>\r\n                            <option value=\"surf\">Superficie<\/option>\r\n                        <\/select>\r\n                    <\/div>\r\n                <\/div>\r\n                <div class=\"form-row\">\r\n                    <div class=\"form-group\"><label>Modelo de panel<\/label>\r\n                        <select id=\"sys_panel_model\">\r\n                            <option value=\"580\">Mono de 580 W (50,7 V)<\/option>\r\n                            <option value=\"550\">Mono de 550 W (49,9 V)<\/option>\r\n                            <option value=\"450\">Mono de 450 W (41,2 V)<\/option>\r\n                        <\/select>\r\n                    <\/div>\r\n                    <div class=\"form-group\"><label>Horas de sol<\/label><input type=\"number\" id=\"sys_sun\" value=\"5.5\"><\/div>\r\n                <\/div>\r\n                <div class=\"form-row\">\r\n                    <div class=\"form-group\"><label>Cable de bomba (m)<\/label><input type=\"number\" id=\"len_pump\" value=\"120\"><\/div>\r\n                    <div class=\"form-group\"><label>Cable de cuerda (m)<\/label><input type=\"number\" id=\"len_pv_s\" value=\"10\"><\/div>\r\n                    <div class=\"form-group\"><label>Cable principal (m)<\/label><input type=\"number\" id=\"len_pv_m\" value=\"20\"><\/div>\r\n                <\/div>\r\n                <div class=\"form-row\">\r\n                    <button class=\"btn-calc\" onclick=\"runCalculation()\">\u26a1 Sistema de configuraci\u00f3n autom\u00e1tica<\/button>\r\n                <\/div>\r\n            <\/div>\r\n\r\n            <div class=\"panel-card\" style=\"flex:1; display:flex; flex-direction:column; padding:0;\">\r\n                <div style=\"padding:8px 12px; background:#f1f3f5; border-bottom:1px solid #ddd; font-weight:bold; font-size:11px;\">\r\n                    3. Editor de listas (ajuste de precio y modelo)\r\n                <\/div>\r\n                <div style=\"overflow:auto; flex:1; min-height: 200px;\">\r\n                    <table class=\"editor-table\">\r\n                        <thead>\r\n                            <tr>\r\n                                <th width=\"5%\">#<\/th>\r\n                                <th width=\"45%\">Art\u00edculo\/Modelo<\/th>\r\n                                <th width=\"15%\">Cantidad<\/th>\r\n                                <th width=\"25%\">Precio($)<\/th>\r\n                                <th width=\"10%\"><\/th>\r\n                            <\/tr>\r\n                        <\/thead>\r\n                        <tbody id=\"editor_tbody\"><\/tbody>\r\n                    <\/table>\r\n                <\/div>\r\n                <div style=\"padding:5px; background:#fff; border-top:1px solid #ddd;\">\r\n                    <button class=\"btn-calc btn-add\" onclick=\"addCustomItem()\">+ Agregar art\u00edculo personalizado<\/button>\r\n                <\/div>\r\n                <div style=\"padding:8px; text-align:right; font-weight:bold; background:#f9f9f9; border-top:1px solid #ddd;\">\r\n                    Editor Total: $<span id=\"editor_total\">0.00<\/span>\r\n                <\/div>\r\n            <\/div>\r\n\r\n            <div class=\"panel-card\">\r\n                <div class=\"form-row\">\r\n                    <div class=\"form-group\"><label>Carga ($)<\/label><input type=\"number\" id=\"in_freight\" value=\"0\" oninput=\"updateTotals()\"><\/div>\r\n                    <div class=\"form-group\" style=\"flex:2\"><label>Observaciones<\/label><textarea id=\"in_remarks\" rows=\"2\" oninput=\"updateTotals()\">EXW Price. Warranty: 24 months.<\/textarea><\/div>\r\n                <\/div>\r\n                <button class=\"btn-calc\" style=\"background:#28a745; margin-top:5px;\" onclick=\"downloadPDF()\">\ud83d\udcc4 Descargar PDF final<\/button>\r\n            <\/div>\r\n        <\/div>\r\n\r\n        <!-- Right: Preview -->\r\n        <div class=\"right-panel\">\r\n            <div id=\"pdf_content\" class=\"a4-paper\">\r\n                <div class=\"quote-header\">\r\n                    <div class=\"logo-area\">\r\n                        <div class=\"logo-text\">HOBER<span style=\"color:#f39c12\">.<\/span><\/div>\r\n                        <div class=\"company-intro\">\r\n                            HOBER es un fabricante chino profesional de inversores de bombas solares y sistemas de bombas de agua solares, que presta servicios a distribuidores e instaladores globales con 15 a\u00f1os de experiencia en I+D y producci\u00f3n.\r\n                        <\/div>\r\n                    <\/div>\r\n                    <div class=\"quote-meta\">\r\n                        <div class=\"meta-title\">Cotizaci\u00f3n<\/div>\r\n                        <div class=\"meta-row\"><strong>No:<\/strong> <span id=\"out_no\"><\/span><\/div>\r\n                        <div class=\"meta-row\"><strong>Fecha:<\/strong> <span id=\"out_date\"><\/span><\/div>\r\n                    <\/div>\r\n                <\/div>\r\n\r\n                <div class=\"info-grid\">\r\n                    <div class=\"info-box\">\r\n                        <div class=\"info-label\">Cliente<\/div>\r\n                        <div id=\"out_customer\" style=\"font-weight:bold; font-size:11px; margin:3px 0;\"><\/div>\r\n                        <div>Proyecto: Sistema de bombeo de agua solar<\/div>\r\n                    <\/div>\r\n                    <div class=\"info-box\">\r\n                        <div class=\"info-label\">Representante de HOBER<\/div>\r\n                        <div style=\"font-weight:bold; font-size:11px; margin:3px 0;\" id=\"out_sales\"><\/div>\r\n                        <div>Correo electr\u00f3nico: <span id=\"out_email\"><\/span><\/div>\r\n                        <div>WhatsApp: <span id=\"out_wa\"><\/span><\/div>\r\n                    <\/div>\r\n                <\/div>\r\n\r\n                <table class=\"preview-table\">\r\n                    <thead>\r\n                        <tr>\r\n                            <th width=\"5%\">No.<\/th>\r\n                            <th width=\"55%\">Art\u00edculo y descripci\u00f3n<\/th>\r\n                            <th width=\"10%\">Unidad<\/th>\r\n                            <th width=\"10%\" style=\"text-align:center\">Cantidad<\/th>\r\n                            <th width=\"20%\" class=\"num\">Total (USD)<\/th>\r\n                        <\/tr>\r\n                    <\/thead>\r\n                    <tbody id=\"preview_tbody\"><\/tbody>\r\n                <\/table>\r\n\r\n                <div class=\"total-section\">\r\n                    <table class=\"total-table\">\r\n                        <tr><td>Total parcial:<\/td><td id=\"out_subtotal\">0.00<\/td><\/tr>\r\n                        <tr><td>Carga \/ Otros:<\/td><td id=\"out_freight\">0.00<\/td><\/tr>\r\n                        <tr class=\"total-final\"><td>Gran total:<\/td><td id=\"out_grand_total\">0.00<\/td><\/tr>\r\n                    <\/table>\r\n                <\/div>\r\n\r\n                <div style=\"margin-top:30px; font-size:9px; color:#444;\">\r\n                    <strong>Observaciones \/ T\u00e9rminos:<\/strong>\r\n                    <div id=\"out_remarks\" style=\"margin-top:4px; white-space:pre-wrap;\"><\/div>\r\n                <\/div>\r\n\r\n                <div class=\"footer\">HOBER TECHNOLOGY CO., LTD | www.hobertek.com<\/div>\r\n            <\/div>\r\n        <\/div>\r\n    <\/div>\r\n\r\n    <script>\r\n    \/\/ ================= 1. Database =================\r\n    const salesDB = {\r\n        \"Stella\": { e: \"Stella@hobertek.com\", w: \"+86-18820855856\" },\r\n        \"Janice\": { e: \"janice@hobertek.com\", w: \"+86-13418643280\" },\r\n        \"Sue\":    { e: \"Sue@hobertek.com\",    w: \"+86-18682312064\" },\r\n        \"Lily\":   { e: \"Lily@hobertek.com\",   w: \"+86-18125665786\" },\r\n        \"Emma\":   { e: \"Emma@hobertek.com\",   w: \"+86-18688952981\" }\r\n    };\r\n\r\n    const panelDB = {\r\n        450: { w: 450, vmp: 34.67, voc: 41.25, price: 85 },\r\n        550: { w: 550, vmp: 41.97, voc: 49.95, price: 105 },\r\n        580: { w: 580, vmp: 42.84, voc: 50.72, price: 110 },\r\n        630: { w: 630, vmp: 46.57, voc: 55.90, price: 125 }\r\n    };\r\n    const prices = { mount_kw: 50, combiner: 120, sensor: 15, c_pv_4: 0.6, c_pv_16: 2.5, c_pump_4: 1.8, c_pump_10: 4.5, mount_per_watt: 0.07, remote_module: 60 };\r\n\r\n    \/\/ --- PUMP DATABASE ---\r\n    const pumpDB = [\r\n      {model:\"HD-SWP9-6-24-300\", type:\"surf\", p:0.3, q_max:9, h_max:6, price: 164},\r\n      {model:\"HD-SWP18-11-48-600\", type:\"surf\", p:0.6, q_max:18, h_max:11, price: 168},\r\n      {model:\"HD-SWP19-12-72-750\", type:\"surf\", p:0.75, q_max:19, h_max:12, price: 177},\r\n      {model:\"HD-SWP22-16-110-1100\", type:\"surf\", p:1.1, q_max:22, h_max:16, price: 194},\r\n      {model:\"HD-SWP36-12-110-1100\", type:\"surf\", p:1.1, q_max:36, h_max:12, price: 200},\r\n      {model:\"HD-SWP23-25-110-1500\", type:\"surf\", p:1.5, q_max:23, h_max:25, price: 210},\r\n      {model:\"HD-SWP28-30-280-2200\", type:\"surf\", p:2.2, q_max:28, h_max:30, price: 288},\r\n      {model:\"HD-SWP45-15-110-1500\", type:\"surf\", p:1.5, q_max:45, h_max:15, price: 236},\r\n      {model:\"HD-SWP50-20-280-2200\", type:\"surf\", p:2.2, q_max:50, h_max:20, price: 325},\r\n      {model:\"HD-SWP70-16-280-2200\", type:\"surf\", p:2.2, q_max:70, h_max:16, price: 330},\r\n      {model:\"H4SP2-06\",type:\"sub\",p:0.37,c:[{q:1.8,h:27},{q:3,h:20}], price: 382},\r\n      {model:\"H4SP2-09\",type:\"sub\",p:0.37,c:[{q:1.8,h:41},{q:3,h:30}], price: 394},\r\n      {model:\"H4SP2-13\",type:\"sub\",p:0.55,c:[{q:1.8,h:59},{q:3,h:43}], price: 417},\r\n      {model:\"H4SP2-18\",type:\"sub\",p:0.75,c:[{q:1.8,h:81},{q:3,h:59}], price: 494},\r\n      {model:\"H4SP2-23\",type:\"sub\",p:1.1,c:[{q:1.8,h:104},{q:3,h:76}], price: 532},\r\n      {model:\"H4SP2-28\",type:\"sub\",p:1.5,c:[{q:1.8,h:126},{q:3,h:92}], price: 553},\r\n      {model:\"H4SP2-33\",type:\"sub\",p:1.5,c:[{q:1.8,h:149},{q:3,h:109}], price: 583},\r\n      {model:\"H4SP2-40\",type:\"sub\",p:2.2,c:[{q:1.8,h:180},{q:3,h:132}], price: 640},\r\n      {model:\"H4SP2-48\",type:\"sub\",p:2.2,c:[{q:1.8,h:216},{q:3,h:158}], price: 680},\r\n      {model:\"H4SP5-04\",type:\"sub\",p:0.37,c:[{q:4.8,h:17},{q:5.4,h:15}], price: 378},\r\n      {model:\"H4SP5-06\",type:\"sub\",p:0.55,c:[{q:4.8,h:26},{q:5.4,h:23}], price: 391},\r\n      {model:\"H4SP5-08\",type:\"sub\",p:0.75,c:[{q:4.8,h:34},{q:5.4,h:31}], price: 454},\r\n      {model:\"H4SP5-12\",type:\"sub\",p:1.1,c:[{q:4.8,h:52},{q:5.4,h:46}], price: 487},\r\n      {model:\"H4SP5-17\",type:\"sub\",p:1.5,c:[{q:4.8,h:73},{q:5.4,h:65}], price: 511},\r\n      {model:\"H4SP5-22\",type:\"sub\",p:2.2,c:[{q:4.8,h:95},{q:5.4,h:84}], price: 553},\r\n      {model:\"H4SP5-25\",type:\"sub\",p:2.2,c:[{q:4.8,h:108},{q:5.4,h:95}], price: 567},\r\n      {model:\"H4SP5-33\",type:\"sub\",p:3,c:[{q:4.8,h:142},{q:5.4,h:125}], price: 724},\r\n      {model:\"H4SP5-38\",type:\"sub\",p:4,c:[{q:4.8,h:163},{q:5.4,h:144}], price: 808},\r\n      {model:\"H4SP5-40\",type:\"sub\",p:4,c:[{q:4.8,h:172},{q:5.4,h:152}], price: 819},\r\n      {model:\"H4SP5-44\",type:\"sub\",p:4,c:[{q:4.8,h:189},{q:5.4,h:167}], price: 839},\r\n      {model:\"H4SP5-52\",type:\"sub\",p:5.5,c:[{q:4.8,h:224},{q:5.4,h:198}], price: 951},\r\n      {model:\"H4SP5-75\",type:\"sub\",p:7.5,c:[{q:4.8,h:323},{q:5.4,h:285}], price: 1244},\r\n      {model:\"H4SP8-05\",type:\"sub\",p:0.75,c:[{q:6.6,h:25},{q:8.4,h:22}], price: 462},\r\n      {model:\"H4SP8-07\",type:\"sub\",p:1.1,c:[{q:6.6,h:34},{q:8.4,h:30}], price: 491},\r\n      {model:\"H4SP8-10\",type:\"sub\",p:1.5,c:[{q:6.6,h:49},{q:8.4,h:43}], price: 514},\r\n      {model:\"H4SP8-12\",type:\"sub\",p:2.2,c:[{q:6.6,h:59},{q:8.4,h:52}], price: 546},\r\n      {model:\"H4SP8-18\",type:\"sub\",p:3,c:[{q:6.6,h:88},{q:8.4,h:77}], price: 708},\r\n      {model:\"H4SP8-21\",type:\"sub\",p:4,c:[{q:6.6,h:103},{q:8.4,h:90}], price: 783},\r\n      {model:\"H4SP8-24\",type:\"sub\",p:4,c:[{q:6.6,h:118},{q:8.4,h:103}], price: 806},\r\n      {model:\"H4SP8-30\",type:\"sub\",p:5.5,c:[{q:6.6,h:147},{q:8.4,h:129}], price: 920},\r\n      {model:\"H4SP8-35\",type:\"sub\",p:5.5,c:[{q:6.6,h:171},{q:8.4,h:151}], price: 954},\r\n      {model:\"H4SP8-40\",type:\"sub\",p:7.5,c:[{q:6.6,h:196},{q:8.4,h:172}], price: 1069},\r\n      {model:\"H4SP8-44\",type:\"sub\",p:7.5,c:[{q:6.6,h:216},{q:8.4,h:189}], price: 1097},\r\n      {model:\"H4SP8-58\",type:\"sub\",p:9.2,c:[{q:6.6,h:285},{q:8.4,h:250}], price: 1451},\r\n      {model:\"H4SP14-05\",type:\"sub\",p:1.5,c:[{q:9,h:28},{q:15,h:20}], price: 521},\r\n      {model:\"H4SP14-07\",type:\"sub\",p:2.2,c:[{q:9,h:39},{q:15,h:28}], price: 563},\r\n      {model:\"H4SP14-10\",type:\"sub\",p:3,c:[{q:9,h:55},{q:15,h:40}], price: 716},\r\n      {model:\"H4SP14-13\",type:\"sub\",p:4,c:[{q:9,h:72},{q:15,h:51}], price: 810},\r\n      {model:\"H4SP14-15\",type:\"sub\",p:5.5,c:[{q:9,h:83},{q:15,h:59}], price: 909},\r\n      {model:\"H4SP14-18\",type:\"sub\",p:5.5,c:[{q:9,h:99},{q:15,h:71}], price: 952},\r\n      {model:\"H4SP14-21\",type:\"sub\",p:7.5,c:[{q:9,h:116},{q:15,h:83}], price: 1063},\r\n      {model:\"H4SP14-25\",type:\"sub\",p:7.5,c:[{q:9,h:138},{q:15,h:99}], price: 1123},\r\n      {model:\"H4SP14-30\",type:\"sub\",p:9.2,c:[{q:9,h:166},{q:15,h:119}], price: 1350},\r\n      {model:\"H6SP46-1\",type:\"sub\",p:2.2,c:[{q:36,h:10},{q:48,h:9}], price: 569},\r\n      {model:\"H6SP46-3\",type:\"sub\",p:5.5,c:[{q:36,h:31},{q:48,h:26}], price: 1027},\r\n      {model:\"H6SP46-5\",type:\"sub\",p:7.5,c:[{q:36,h:51},{q:48,h:43}], price: 982},\r\n      {model:\"H6SP46-7\",type:\"sub\",p:11,c:[{q:36,h:72},{q:48,h:60}], price: 1107},\r\n      {model:\"H6SP46-10\",type:\"sub\",p:15,c:[{q:36,h:102},{q:48,h:86}], price: 1474},\r\n      {model:\"H6SP46-13\",type:\"sub\",p:22,c:[{q:36,h:133},{q:48,h:112}], price: 1978},\r\n      {model:\"H6SP46-18\",type:\"sub\",p:30,c:[{q:36,h:184},{q:48,h:155}], price: 2529},\r\n      {model:\"H6SP46-22\",type:\"sub\",p:37,c:[{q:36,h:225},{q:48,h:189}], price: 3224},\r\n      {model:\"H6SP46-26\",type:\"sub\",p:45,c:[{q:36,h:266},{q:48,h:224}], price: 4204},\r\n      {model:\"H8SP77-3\",type:\"sub\",p:11,c:[{q:84,h:37},{q:120,h:12}], price: 1286},\r\n      {model:\"H8SP77-5\",type:\"sub\",p:18.5,c:[{q:84,h:62},{q:120,h:20}], price: 1827},\r\n      {model:\"H8SP77-6\",type:\"sub\",p:22,c:[{q:84,h:74},{q:120,h:24}], price: 2160},\r\n      {model:\"H8SP77-8\",type:\"sub\",p:30,c:[{q:84,h:98},{q:120,h:32}], price: 3662},\r\n      {model:\"H8SP77-10\",type:\"sub\",p:37,c:[{q:84,h:123},{q:120,h:40}], price: 4377},\r\n      {model:\"H8SP77-12\",type:\"sub\",p:45,c:[{q:84,h:148},{q:120,h:48}], price: 5387},\r\n      {model:\"H8SP77-14\",type:\"sub\",p:55,c:[{q:84,h:172},{q:120,h:56}], price: 6006},\r\n      {model:\"H8SP77-18\",type:\"sub\",p:75,c:[{q:84,h:221},{q:120,h:72}], price: 7839},\r\n      {model:\"H8SP95-5\",type:\"sub\",p:22,c:[{q:95,h:60},{q:120,h:32}], price: 2102},\r\n      {model:\"H8SP95-9\",type:\"sub\",p:37,c:[{q:95,h:108},{q:120,h:57}], price: 4319},\r\n      {model:\"H8SP95-12\",type:\"sub\",p:55,c:[{q:95,h:172},{q:120,h:77}], price: 5869},\r\n      {model:\"H10SP125-3\",type:\"sub\",p:30,c:[{q:125,h:60},{q:160,h:40}], price: 3890},\r\n      {model:\"H10SP125-5\",type:\"sub\",p:55,c:[{q:125,h:100},{q:160,h:62}], price: 6152},\r\n      {model:\"H10SP125-7\",type:\"sub\",p:75,c:[{q:125,h:140},{q:160,h:89}], price: 8041},\r\n      {model:\"H10SP160-5\",type:\"sub\",p:63,c:[{q:160,h:100},{q:200,h:80}], price: 6288}\r\n    ];\r\n\r\n    const invDB = [\r\n        { m: \"HSPH750LB\", p: 0.75, ph: 1, price: 200 }, { m: \"HSPH1500LB\", p: 1.5, ph: 1, price: 250 },\r\n        { m: \"HSPH2200LB\", p: 2.2, ph: 1, price: 300 }, { m: \"HSPH2200H\", p: 2.2, ph: 3, price: 300 },\r\n        { m: \"HSPH4000H\", p: 4.0, ph: 3, price: 380 }, { m: \"HSPH5500H\", p: 5.5, ph: 3, price: 450 },\r\n        { m: \"HSPH7500H\", p: 7.5, ph: 3, price: 550 }, { m: \"HSPH11KH\", p: 11, ph: 3, price: 700 },\r\n        { m: \"HSPH15KH\", p: 15, ph: 3, price: 850 }, { m: \"HSPH18.5KH\", p: 18.5, ph: 3, price: 1000 },\r\n        { m: \"HSPH22KH\", p: 22, ph: 3, price: 1150 }, { m: \"HSPH30KH\", p: 30, ph: 3, price: 1400 },\r\n        { m: \"HSPH37KH\", p: 37, ph: 3, price: 1600 }, { m: \"HSPH45KH\", p: 45, ph: 3, price: 1800 },\r\n        { m: \"HSPH55KH\", p: 55, ph: 3, price: 2200 }, { m: \"HSPH75KH\", p: 75, ph: 3, price: 2800 },\r\n        { m: \"HSPH110KH\", p: 110, ph: 3, price: 4500 }, { m: \"HSPH132KH\", p: 132, ph: 3, price: 5200 },\r\n        { m: \"HSPH160KH\", p: 160, ph: 3, price: 6500 }, { m: \"HSPH200KH\", p: 200, ph: 3, price: 8000 }\r\n    ];\r\n\r\n    \/\/ --- COMBINER BOX ---\r\n    const combinerBoxDB = [\r\n      {model: \"HCBL1+2\", inputs:2, ph:1, type:\"hybrid\", spec: \"2 PV + 1 AC (500V)\", price: 168},\r\n      {model: \"HCBH3+2\", inputs:2, ph:3, type:\"hybrid\", spec: \"2 PV + 3 AC (1000V)\", price: 188},\r\n      {model: \"HCBH3+3\", inputs:3, ph:3, type:\"hybrid\", spec: \"3 PV + 3 AC (1000V)\", price: 218},\r\n      {model: \"HCBH3+4\", inputs:4, ph:3, type:\"hybrid\", spec: \"4 PV + 3 AC (1000V)\", price: 228},\r\n      {model: \"HCBH3+6\", inputs:6, ph:3, type:\"hybrid\", spec: \"6 PV + 3 AC (1000V)\", price: 348},\r\n      {model: \"HCBH3+8\", inputs:8, ph:3, type:\"hybrid\", spec: \"8 PV + 3 AC (1000V)\", price: 368},\r\n      {model: \"HCBL2\", inputs:2, ph:1, type:\"pv\", spec: \"2 In Max 500Vdc\", price: 98},\r\n      {model: \"HCBH2\", inputs:2, ph:3, type:\"pv\", spec: \"2 In Max 1000Vdc\", price: 118},\r\n      {model: \"HCBH3\", inputs:3, ph:3, type:\"pv\", spec: \"3 In Max 1000Vdc\", price: 128},\r\n      {model: \"HCBH4\", inputs:4, ph:3, type:\"pv\", spec: \"4 In Max 1000Vdc\", price: 138},\r\n      {model: \"HCBH12\", inputs:12, ph:3, type:\"pv\", spec: \"12 In Max 1000Vdc\", price: 398},\r\n      {model: \"HCBH14\", inputs:14, ph:3, type:\"pv\", spec: \"14 In Max 1000Vdc\", price: 434},\r\n      {model: \"HCBH16\", inputs:16, ph:3, type:\"pv\", spec: \"16 In Max 1000Vdc\", price: 445},\r\n      {model: \"HCBH18\", inputs:18, ph:3, type:\"pv\", spec: \"18 In Max 1000Vdc\", price: 668},\r\n      {model: \"HCBH20\", inputs:24, ph:3, type:\"pv\", spec: \"20\/24 In Max 1000Vdc\", price: 700}\r\n    ];\r\n\r\n    \/\/ --- CABLES ---\r\n    const pumpCableDB = [\r\n      {spec: \"3*2.5mm\u00b2 + 1*1.5mm\u00b2\", amp: 10, price: 1.44},\r\n      {spec: \"3*4mm\u00b2 + 1*2.5mm\u00b2\", amp: 15, price: 2.25},\r\n      {spec: \"3*6mm\u00b2 + 1*4mm\u00b2\", amp: 23, price: 3.33},\r\n      {spec: \"3*10mm\u00b2 + 1*6mm\u00b2\", amp: 38, price: 5.89},\r\n      {spec: \"3*16mm\u00b2 + 1*10mm\u00b2\", amp: 62, price: 8.41},\r\n      {spec: \"3*25mm\u00b2 + 1*10mm\u00b2\", amp: 96, price: 13.22},\r\n      {spec: \"3*35mm\u00b2 + 1*10mm\u00b2\", amp: 135, price: 17.47},\r\n      {spec: \"3*50mm\u00b2 + 1*16mm\u00b2\", amp: 192, price: 25.21},\r\n      {spec: \"3*70mm\u00b2 + 1*25mm\u00b2\", amp: 269, price: 35.84}\r\n    ];\r\n\r\n    const solarCableDB = [\r\n      {spec: \"4mm\u00b2\", price: 0.63}, {spec: \"6mm\u00b2\", price: 0.92}, {spec: \"10mm\u00b2\", price: 1.60},\r\n      {spec: \"16mm\u00b2\", price: 2.58}, {spec: \"25mm\u00b2\", price: 3.98}, {spec: \"35mm\u00b2\", price: 5.54},\r\n      {spec: \"50mm\u00b2\", price: 7.92}\r\n    ];\r\n\r\n    \/\/ --- REACTOR ---\r\n    const reactorDB = {\r\n        2.2: { r150: { m: \"HBR-2.2-005-140B\", p: 55 }, r250: { m: \"HBR-2.2-005-280B\", p: 75 }, f400: { m: \"HBF-2.2-005-D\", p: 140 }, f1000: { m: \"HBF-2.2-005-S\", p: 160 } },\r\n        3.7: { r150: { m: \"HBR-3.7-0010-700C\", p: 65 }, r250: { m: \"HBR-3.7-0010-140B\", p: 85 }, f400: { m: \"HBF-3.7-0010-D\", p: 130 }, f1000: { m: \"HBF-3.7-0010-S\", p: 150 } },\r\n        5.5: { r150: { m: \"HBR-5.5-0013-540C\", p: 76 }, r250: { m: \"HBR-5.5-0013-108B\", p: 90 }, f400: { m: \"HBF-5.5-0013-D\", p: 150 }, f1000: { m: \"HBF-5.5-0013-S\", p: 170 } },\r\n        7.5: { r150: { m: \"HBR-7.5-0016-438C\", p: 80 }, r250: { m: \"HBR-7.5-0016-875C\", p: 100 }, f400: { m: \"HBF-7.5-0016-D\", p: 165 }, f1000: { m: \"HBF-7.5-0016-S\", p: 200 } },\r\n        11: { r150: { m: \"HBR-11-0025-280C\", p: 85 }, r250: { m: \"HBR-11-0025-560C\", p: 110 }, f400: { m: \"HBF-11-0025-D\", p: 180 }, f1000: { m: \"HBF-11-0025-S\", p: 250 } },\r\n        15: { r150: { m: \"HBR-15-0030-233C\", p: 88 }, r250: { m: \"HBR-15-0030-467C\", p: 120 }, f400: { m: \"HBF-15-0030-D\", p: 190 }, f1000: { m: \"HBF-15-0030-S\", p: 270 } },\r\n        18.5: { r150: { m: \"HBR-18.5-0040-175C\", p: 98 }, r250: { m: \"HBR-18.5-0040-350C\", p: 150 }, f400: { m: \"HBF-18.5-0040-D\", p: 208 }, f1000: { m: \"HBF-18.5-0040-S\", p: 310 } },\r\n        22: { r150: { m: \"HBR-22-0045-155C\", p: 108 }, r250: { m: \"HBR-22-0045-311C\", p: 165 }, f400: { m: \"HBF-22-0045-D\", p: 255 }, f1000: { m: \"HBF-22-0045-S\", p: 355 } },\r\n        30: { r150: { m: \"HBR-30-0060-117C\", p: 130 }, r250: { m: \"HBR-30-0060-234C\", p: 165 }, f400: { m: \"HBF-30-0060-D\", p: 280 }, f1000: { m: \"HBF-30-0060-S\", p: 605 } },\r\n        37: { r150: { m: \"HBR-37-0075-934D\", p: 140 }, r250: { m: \"HBR-37-0075-187C\", p: 173 }, f400: { m: \"HBF-37-0075-D\", p: 340 }, f1000: { m: \"HBF-37-0075-S\", p: 702 } },\r\n        45: { r150: { m: \"HBR-45-0090-785D\", p: 155 }, r250: { m: \"HBR-45-0090-155C\", p: 190 }, f400: { m: \"HBF-45-0090-D\", p: 462 }, f1000: { m: \"HBF-45-0090-S\", p: 775 } },\r\n        55: { r150: { m: \"HBR-55-0110-640D\", p: 173 }, r250: { m: \"HBR-55-0110-128C\", p: 220 }, f400: { m: \"HBF-55-0110-D\", p: 495 }, f1000: { m: \"HBF-55-0110-S\", p: 1003 } },\r\n        75: { r150: { m: \"HBR-75-0150-467D\", p: 196 }, r250: { m: \"HBR-75-0150-934D\", p: 245 }, f400: { m: \"HBF-75-0150-D\", p: 525 }, f1000: { m: \"HBF-75-0150-S\", p: 1215 } },\r\n        110: { r150: { m: \"HBR-110-0220-320D\", p: 270 }, r250: { m: \"HBR-110-0220-640D\", p: 355 }, f400: { m: \"HBF-110-0220-D\", p: 703 }, f1000: { m: \"HBF-110-0220-S\", p: 1740 } },\r\n        132: { r150: { m: \"HBR-132-0260-270D\", p: 316 }, r250: { m: \"HBR-132-0260-540D\", p: 412 }, f400: { m: \"HBF-132-0260-D\", p: 776 }, f1000: { m: \"HBF-132-0260-S\", p: 2097 } },\r\n        160: { r150: { m: \"HBR-160-0320-220D\", p: 364 }, r250: { m: \"HBR-160-0320-438D\", p: 516 }, f400: { m: \"HBF-160-0320-D\", p: 978 }, f1000: { m: \"HBF-160-0320-S\", p: 2472 } },\r\n        200: { r150: { m: \"HBR-200-0400-175D\", p: 429 }, r250: { m: \"HBR-200-0400-350D\", p: 590 }, f400: { m: \"HBF-200-0400-D\", p: 1027 }, f1000: { m: \"HBF-200-0400-S\", p: 2612 } }\r\n    };\r\n\r\n    let draftItems = [];\r\n\r\n    \/\/ ================= 2. Logic =================\r\n    window.onload = () => {\r\n        document.getElementById('in_date').valueAsDate = new Date();\r\n        updateSales();\r\n        runCalculation();\r\n    };\r\n\r\n    function updateSales() {\r\n        const s = document.getElementById('in_sales').value;\r\n        const data = salesDB[s];\r\n        document.getElementById('out_sales').innerText = s;\r\n        document.getElementById('out_email').innerText = data.e;\r\n        document.getElementById('out_wa').innerText = data.w;\r\n    }\r\n\r\n    function findPump(reqFlow, reqHead, type) {\r\n        const tolerance = 0.9; \r\n        let candidates = [];\r\n        \r\n        pumpDB.forEach(pump => {\r\n            if (pump.type !== type) return;\r\n            if(type === 'surf') {\r\n                if(pump.q_max >= reqFlow * tolerance && pump.h_max >= reqHead * tolerance) candidates.push(pump);\r\n                return;\r\n            }\r\n            const curve = pump.c.sort((a,b) => a.q - b.q);\r\n            const maxQ = curve[curve.length-1].q * (1\/tolerance);\r\n            if (reqFlow > maxQ) return;\r\n\r\n            let calculatedHead = 0;\r\n            if (reqFlow <= curve[0].q) calculatedHead = curve[0].h;\r\n            else if (reqFlow >= curve[curve.length-1].q) calculatedHead = curve[curve.length-1].h;\r\n            else {\r\n                for (let i = 0; i < curve.length - 1; i++) {\r\n                    if (reqFlow >= curve[i].q && reqFlow <= curve[i+1].q) {\r\n                        const slope = (curve[i+1].h - curve[i].h) \/ (curve[i+1].q - curve[i].q);\r\n                        calculatedHead = curve[i].h + (reqFlow - curve[i].q) * slope;\r\n                        break;\r\n                    }\r\n                }\r\n            }\r\n            if (calculatedHead >= reqHead * tolerance) candidates.push(pump);\r\n        });\r\n        \r\n        candidates.sort((a,b) => {\r\n            if(a.p !== b.p) return a.p - b.p;\r\n            return a.price - b.price;\r\n        });\r\n\r\n        if (candidates.length === 0) {\r\n             const allType = pumpDB.filter(p => p.type === type).sort((a,b) => b.p - a.p);\r\n             return allType.length > 0 ? allType[0] : null;\r\n        }\r\n\r\n        return candidates[0];\r\n    }\r\n\r\n    function runCalculation() {\r\n        const dailyFlow = parseFloat(document.getElementById('sys_flow').value);\r\n        const sunHours = parseFloat(document.getElementById('sys_sun').value);\r\n        const head = parseFloat(document.getElementById('sys_head').value);\r\n        const type = document.getElementById('sys_source').value;\r\n        const panelW = parseInt(document.getElementById('sys_panel_model').value);\r\n        \r\n        const lenPump = parseFloat(document.getElementById('len_pump').value) || 0;\r\n        const lenPvS = parseFloat(document.getElementById('len_pv_s').value) || 0;\r\n        const lenPvM = parseFloat(document.getElementById('len_pv_m').value) || 0;\r\n\r\n        const hourlyFlow = dailyFlow \/ sunHours;\r\n        let pump = findPump(hourlyFlow, head, type);\r\n        if(!pump) pump = pumpDB[pumpDB.length-1]; \r\n\r\n        let inv = invDB.find(i => i.p >= pump.p && (pump.p >= 3 ? i.ph === 3 : true));\r\n        if(!inv) inv = invDB[invDB.length-1];\r\n\r\n        const panelData = panelDB[panelW];\r\n        const targetTotalW = pump.p * 1000 * 1.5; \r\n        let seriesNum = 0, stringsNum = 0;\r\n        if(inv.ph === 1) {\r\n            seriesNum = Math.ceil(320 \/ panelData.vmp); \r\n            if(seriesNum * panelData.voc > 440) seriesNum = Math.floor(440\/panelData.voc);\r\n        } else {\r\n            seriesNum = Math.ceil(560 \/ panelData.vmp); \r\n            if(seriesNum * panelData.voc > 750) seriesNum = Math.floor(750\/panelData.voc);\r\n        }\r\n        const totalPanelsNeeded = Math.ceil(targetTotalW \/ panelW);\r\n        stringsNum = Math.ceil(totalPanelsNeeded \/ seriesNum);\r\n        const actualPanels = seriesNum * stringsNum;\r\n        const totalPowerWatts = actualPanels * panelW;\r\n\r\n        draftItems = [];\r\n\r\n        const setPrice = pump.price; \r\n        \r\n        draftItems.push({\r\n            name: \"Solar Pump Set\",\r\n            desc: `Pump: ${pump.model} (${pump.p}kW)\\nInv: ${inv.m}\\nDuty: ${hourlyFlow.toFixed(1)}m\u00b3\/h @ ${head}m`,\r\n            unit: \"SET\", qty: 1, price: setPrice\r\n        });\r\n\r\n        draftItems.push({\r\n            name: \"Solar PV Modules\",\r\n            desc: `${panelW}W Mono, Voc:${panelData.voc}V, Vmp:${panelData.vmp}V\\nConfig: ${stringsNum} Strings * ${seriesNum} Series`,\r\n            unit: \"PCS\", qty: actualPanels, price: panelData.price\r\n        });\r\n\r\n        draftItems.push({ \r\n            name: \"Mounting Structure\", \r\n            desc: `Ground Mounting for ${actualPanels} Panels (${(totalPowerWatts\/1000).toFixed(1)}kW)`, \r\n            unit: \"W\", qty: totalPowerWatts, price: prices.mount_per_watt \r\n        });\r\n\r\n        let combiner = null;\r\n        if(inv.ph === 1) {\r\n            combiner = combinerBoxDB.find(c => c.ph===1 && c.inputs >= stringsNum && c.type===\"hybrid\");\r\n            if(!combiner) combiner = combinerBoxDB.find(c => c.ph===1 && c.inputs >= stringsNum);\r\n        } else {\r\n            combiner = combinerBoxDB.find(c => c.ph===3 && c.inputs >= stringsNum && c.type===\"hybrid\");\r\n            if(!combiner) combiner = combinerBoxDB.find(c => c.ph===3 && c.inputs >= stringsNum);\r\n        }\r\n        if(combiner) {\r\n            draftItems.push({ name: \"PV Combiner Box\", desc: `${combiner.model} (${combiner.spec})`, unit: \"SET\", qty: 1, price: combiner.price });\r\n        }\r\n\r\n        const strCableLen = (actualPanels * 1.2) + (lenPvS * stringsNum * 2);\r\n        draftItems.push({ name: \"PV String Cable\", desc: \"4mm\u00b2 PV1-F\", unit: \"M\", qty: Math.ceil(strCableLen), price: solarCableDB[0].price });\r\n        \r\n        let mainCable = null;\r\n        if(pump.p <= 4) mainCable = solarCableDB.find(c => c.spec === \"6mm\u00b2\");\r\n        else if(pump.p <= 15) mainCable = solarCableDB.find(c => c.spec === \"10mm\u00b2\");\r\n        else if(pump.p <= 30) mainCable = solarCableDB.find(c => c.spec === \"16mm\u00b2\");\r\n        else if(pump.p <= 55) mainCable = solarCableDB.find(c => c.spec === \"35mm\u00b2\");\r\n        else mainCable = solarCableDB.find(c => c.spec === \"50mm\u00b2\");\r\n        \r\n        draftItems.push({ \r\n            name: \"PV Main Cable\", \r\n            desc: `${mainCable.spec} DC Cable`, \r\n            unit: \"M\", qty: lenPvM*2, price: mainCable.price \r\n        });\r\n\r\n        let pumpAmps = inv.ph === 1 ? pump.p * 4.5 : pump.p * 2.0;\r\n        let pumpCable = pumpCableDB.find(c => c.amp >= pumpAmps);\r\n        if(!pumpCable) pumpCable = pumpCableDB[pumpCableDB.length-1]; \r\n\r\n        draftItems.push({ \r\n            name: \"Pump Cable\", \r\n            desc: `Submersible Cable (${pumpCable.spec})`, \r\n            unit: \"M\", qty: lenPump, price: pumpCable.price \r\n        });\r\n\r\n        if(lenPump > 100) {\r\n            let rKeys = Object.keys(reactorDB).map(Number).sort((a,b)=>a-b);\r\n            let rPower = rKeys.find(k => k >= inv.p);\r\n            if(!rPower) rPower = rKeys[rKeys.length-1];\r\n            \r\n            const rData = reactorDB[rPower];\r\n            let spec = null;\r\n            let rType = \"Output Reactor\";\r\n\r\n            if (lenPump <= 150) spec = rData.r150;\r\n            else if (lenPump <= 250) spec = rData.r250;\r\n            else if (lenPump <= 400) { spec = rData.f400; rType = \"Sine Wave Filter\"; }\r\n            else { spec = rData.f1000; rType = \"Sine Wave Filter\"; }\r\n\r\n            if(spec) {\r\n                draftItems.push({ name: rType, desc: `${spec.m} (For ${inv.p}kW, Cable ${lenPump}m)`, unit: \"PCS\", qty: 1, price: spec.p });\r\n            }\r\n        }\r\n\r\n        draftItems.push({ name: \"Water Sensors\", desc: \"Well & Tank Sensors\", unit: \"SET\", qty: 1, price: prices.sensor });\r\n        draftItems.push({ name: \"GPRS\/WiFi Module\", desc: \"Remote Monitoring Module\", unit: \"SET\", qty: 1, price: prices.remote_module });\r\n\r\n        renderEditor();\r\n    }\r\n\r\n    function addCustomItem() {\r\n        draftItems.push({\r\n            name: \"New Custom Item\",\r\n            desc: \"Description here...\",\r\n            unit: \"PCS\",\r\n            qty: 1,\r\n            price: 0\r\n        });\r\n        renderEditor();\r\n    }\r\n\r\n    \/\/ ================= 3. Rendering =================\r\n    function renderEditor() {\r\n        const tbody = document.getElementById('editor_tbody');\r\n        tbody.innerHTML = \"\";\r\n        draftItems.forEach((item, idx) => {\r\n            const tr = document.createElement('tr');\r\n            tr.innerHTML = `\r\n                <td>${idx+1}<\/td>\r\n                <td>\r\n                    <input class=\"editor-input\" value=\"${item.name}\" oninput=\"editItem(${idx},'name',this.value)\" style=\"font-weight:bold;color:var(--primary)\">\r\n                    <input class=\"editor-input\" value=\"${item.desc.replace(\/\\n\/g,', ')}\" oninput=\"editItem(${idx},'desc',this.value)\" style=\"color:#666;font-size:9px;\">\r\n                <\/td>\r\n                <td><input class=\"editor-input\" type=\"number\" value=\"${item.qty}\" oninput=\"editItem(${idx},'qty',this.value)\" style=\"text-align:center\"><\/td>\r\n                <td><input class=\"editor-input price-input\" type=\"number\" value=\"${item.price}\" oninput=\"editItem(${idx},'price',this.value)\"><\/td>\r\n                <td><button class=\"btn-del\" onclick=\"deleteItem(${idx})\">\u00d7<\/button><\/td>\r\n            `;\r\n            tbody.appendChild(tr);\r\n        });\r\n        updateTotals();\r\n    }\r\n\r\n    function editItem(idx, f, v) { if(f==='qty'||f==='price') draftItems[idx][f] = parseFloat(v)||0; else draftItems[idx][f] = v; updateTotals(); }\r\n    function deleteItem(idx) { draftItems.splice(idx, 1); renderEditor(); }\r\n\r\n    function updateTotals() {\r\n        document.getElementById('out_no').innerText = document.getElementById('in_no').value;\r\n        document.getElementById('out_date').innerText = document.getElementById('in_date').value;\r\n        document.getElementById('out_customer').innerText = document.getElementById('in_customer').value;\r\n        document.getElementById('out_remarks').innerText = document.getElementById('in_remarks').value;\r\n\r\n        const previewBody = document.getElementById('preview_tbody');\r\n        previewBody.innerHTML = \"\";\r\n        let sub = 0;\r\n\r\n        draftItems.forEach((item, idx) => {\r\n            const tot = item.qty * item.price;\r\n            sub += tot;\r\n            previewBody.innerHTML += `\r\n                <tr>\r\n                    <td>${idx+1}<\/td>\r\n                    <td><div class=\"item-name\">${item.name}<\/div><div class=\"item-desc\">${item.desc.replace(\/, \/g,'\\n')}<\/div><\/td>\r\n                    <td>${item.unit}<\/td>\r\n                    <td style=\"text-align:center\">${item.qty}<\/td>\r\n                    <td class=\"num\">${tot.toLocaleString('en-US',{minimumFractionDigits:2})}<\/td>\r\n                <\/tr>`;\r\n        });\r\n\r\n        const fr = parseFloat(document.getElementById('in_freight').value) || 0;\r\n        const gt = sub + fr;\r\n        document.getElementById('editor_total').innerText = gt.toLocaleString('en-US',{minimumFractionDigits:2});\r\n        document.getElementById('out_subtotal').innerText = sub.toLocaleString('en-US',{minimumFractionDigits:2});\r\n        document.getElementById('out_freight').innerText = fr.toLocaleString('en-US',{minimumFractionDigits:2});\r\n        document.getElementById('out_grand_total').innerText = gt.toLocaleString('en-US',{minimumFractionDigits:2});\r\n    }\r\n\r\n    function downloadPDF() {\r\n        const element = document.getElementById('pdf_content');\r\n        const clone = element.cloneNode(true);\r\n\r\n        \/\/ Reset basic styles for print\r\n        clone.style.transform = 'none';\r\n        clone.style.margin = '0'; \r\n        clone.style.boxShadow = 'none';\r\n        clone.style.background = '#fff';\r\n\r\n        \/\/ === \u5173\u952e\u4fee\u590d\uff1a\u786e\u4fdd\u5bbd\u5ea6\u5305\u542b padding\uff0c\u5e76\u5f3a\u5236\u4e3a A4 \u50cf\u7d20\u5bbd\u5ea6 ===\r\n        \/\/ 794px \u662f A4 \u5728 96DPI \u4e0b\u7684\u6807\u51c6\u5bbd\u5ea6\r\n        clone.style.boxSizing = 'border-box';\r\n        clone.style.width = '794px'; \r\n        clone.style.minHeight = '1123px'; \/\/ A4 Height\r\n        \r\n        \/\/ === \u5173\u952e\u4fee\u590d\uff1a\u521b\u5efa\u4e00\u4e2a\u7edd\u5bf9\u5b9a\u4f4d\u7684\u5bb9\u5668\uff0c\u786e\u4fdd clone \u4ece (0,0) \u5f00\u59cb\u6e32\u67d3 ===\r\n        const container = document.createElement('div');\r\n        container.style.position = 'absolute';\r\n        container.style.top = '0';\r\n        container.style.left = '0';\r\n        container.style.width = '794px';\r\n        container.style.zIndex = '-1'; \/\/ Hide behind other content\r\n        container.style.overflow = 'hidden'; \/\/ Prevent scrollbars affecting width\r\n\r\n        container.appendChild(clone);\r\n        document.body.appendChild(container);\r\n\r\n        const opt = {\r\n            margin: 0, \r\n            filename: (document.getElementById('in_no').value || 'Quote') + '.pdf',\r\n            image: { type: 'jpeg', quality: 0.98 },\r\n            html2canvas: { \r\n                scale: 2, \r\n                useCORS: true,\r\n                scrollY: 0,\r\n                scrollX: 0, \/\/ Force no horizontal scroll\r\n                windowWidth: 794, \/\/ Tell canvas the window is exactly this wide\r\n                width: 794, \/\/ Tell canvas the content is exactly this wide\r\n                x: 0, \/\/ Force render to start at x=0\r\n                y: 0\r\n            },\r\n            jsPDF: { unit: 'px', format: [794, 1123], orientation: 'portrait' }\r\n        };\r\n\r\n        html2pdf().set(opt).from(clone).save().then(() => {\r\n            document.body.removeChild(container);\r\n        });\r\n    }\r\n    <\/script>\r\n<\/div>\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t<\/div>","protected":false},"excerpt":{"rendered":"<p>Editor de cotizaciones de HOBER 1. N.\u00ba de cotizaci\u00f3n de cliente y ventas Fecha Cliente Ventas StellaJaniceSueLilyEmma 2. Configuraci\u00f3n autom\u00e1tica del sistema Agua (m\u00b3\/d\u00eda) Altura total (m) Tipo Pozo profundo Superficie Panel<span class=\"excerpt-hellip\"> [\u2026]<\/span><\/p>","protected":false},"author":4,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_seopress_robots_primary_cat":"","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","om_disable_all_campaigns":false,"_joinchat":[],"footnotes":""},"class_list":["post-7095","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/hobertek.com\/es\/wp-json\/wp\/v2\/pages\/7095","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hobertek.com\/es\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/hobertek.com\/es\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/hobertek.com\/es\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/hobertek.com\/es\/wp-json\/wp\/v2\/comments?post=7095"}],"version-history":[{"count":1,"href":"https:\/\/hobertek.com\/es\/wp-json\/wp\/v2\/pages\/7095\/revisions"}],"predecessor-version":[{"id":7098,"href":"https:\/\/hobertek.com\/es\/wp-json\/wp\/v2\/pages\/7095\/revisions\/7098"}],"wp:attachment":[{"href":"https:\/\/hobertek.com\/es\/wp-json\/wp\/v2\/media?parent=7095"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}