INSERT INTO `core_pcoder_historial` VALUES (97,'mod/app_facturas/pdf_factura_descargar_tarifa_dinamica.php','2023-04-28 23:42:00','rafael',797,152978,'<?php\n\n @session_start();\n\nif(!isset($_SESSION[\'PCOSESS_SesionAbierta\'])) {\n	echo \'<head><title>Error</title><style type=\"text/css\"> body { background-color: #000000; color: #7f7f7f; font-family: sans-serif,helvetica; } </style></head><body><table width=\"100%\" height=\"100%\" border=0><tr><td align=center>&#9827; Acceso no autorizado !</td></tr></table></body>\';\n	die();\n}\n\n/*include_once \'../../core/configuracion.php\';\ninclude_once \'../../core/conexiones.php\';\ninclude_once \'../../inc/practico/def_basedatos.php\';\ninclude_once \'../../core/comunes.php\';*/\n\n//echo \"$builder\";\n$saldoFavor = $factura[\"saldo_pendiente\"] < 0 ? -$factura[\"saldo_pendiente\"] : 0;\n$saldoPendienteValor = $factura[\"saldo_pendiente\"] > 0 ? $factura[\"saldo_pendiente\"] : 0;\n$saldoPendiente = number_format($saldoPendienteValor, 0, \',\', \'.\');\n\n$descargar = 0;\nif ($PCO_Accion == \"FACTURAS_descargarFactura\")\n    $descargar = 1;\n$fechaSinRecargoBr = str_replace(\"-\", \"\", $factura[\"fecha_sin_recargo\"]);\n$totalValor =  number_format($factura[\"valor_sin_recargo\"] + $saldoPendienteValor - $saldoFavor, 0, \',\', \'.\');\n$total = $totalValor > 0 ? $totalValor : 0;\n$totalBr = str_replace(\".\", \"\", $total);\n$codigobarra=\"7709998678439\";\n$Barcode = $codigobarra.$factura[\"id_contrato\"].\"$totalBr96$fechaSinRecargoBr\";\n$BarcodeParent = \"(415)$codigobarra(8020)\" . $factura[\"id\"] . \"(3900)$totalBr(96)$fechaSinRecargoBr\";\n//$Barcode = \"(415)7709998678439(8020)12345(3900)50000(96)20220524\";\n//$Barcode = \"41577099986784398020123453900500009620220524\";\n//$Barcode = \"12345670\";\n\n$rayaDesprendibleBanco = str_repeat(\"- \", 34);\n\n$estadoMedidor = \"Bueno\";\nif($factura[\"estado_medidor\"] == 2) $estadoMedidor = \"Dañado\";\nif($factura[\"estado_medidor\"] == 3) $estadoMedidor = \"N/A\";\n\nfunction getMesEsp($mes) {\n    $mesesArray = [\"\",\"Ene\", \"Feb\", \"Mar\", \"Abr\", \"May\", \"Jun\", \"Jul\", \"Ago\", \"Sep\", \"Oct\", \"Nov\", \"Dic\"];\n    return $mesesArray[$mes];\n}\n$i = 1;\n$grafBarra = \"\";\n$tableData = \"\";\n$class = \"\";\n\n$consumos = PCO_EjecutarSQL(\"SELECT consumo_actual, MONTH(fecha_fin_facturacion) mes, valor_sin_recargo, saldo_pendiente, valor_tarifa_aplicada\n    FROM \n        app_facturas\n    WHERE \n        id_contrato = \". $factura[\"id_contrato\"]. \" ORDER BY id DESC LIMIT 6\n\")->fetchAll();\n\nforeach ($consumos as $consumo) {\n    $mes = getMesEsp($consumo[\"mes\"]);\n    $totalMes =  number_format($consumo[\"valor_sin_recargo\"], 0, \',\', \'.\');\n    $grafBarra .= \'<div class=\"barra\"><div class=\"sub_barra b\' . $i . \'\"><div class=\"tag_g\">\' . $consumo[\"consumo_actual\"] . \'</div><div class=\"tag_leyenda\">\' . $mes . \'</div></div></div>\';\n    $tableData .= \'<tr><td>\' . $mes . \'</td><td>\' . $consumo[\"consumo_actual\"] . \'</td><td>\' . $consumo[\"valor_tarifa_aplicada\"] . \'</td><td>\' . $totalMes . \'</td></tr>\';\n    $class .= \".b$i { height: \" . (is_numeric($consumo[\"consumo_actual\"]) ? $consumo[\"consumo_actual\"] : 0) . \"%} \";\n    $i++;\n}\n\n$html = \'\n<html>\n\n<head>\n   <meta charset=\"utf-8\">\n   <title>Factura</title>\n   <style>\n      * {\n         border: 0;\n         box-sizing: content-box;\n         color: inherit;\n         font-family: Verdana;\n         font-size: inherit;\n         font-style: inherit;\n         font-weight: inherit;\n         list-style: none;\n         padding: 0;\n         text-decoration: none;\n      }\n\n    table.info, \n    .info td,\n    .info tr {\n        border-width: 0px !important;\n        border-style: none;\n        text-align:left\n    }\n      /* heading */\n\n      h1 {\n         font: bold 100% sans-serif;\n         letter-spacing: 0.5em;\n         text-align: center;\n         text-transform: uppercase;\n      }\n\n      /* table */\n\n      table {\n         font-size: 75%;\n         table-layout: fixed;\n         width: 100%;\n      }\n\n      table {\n         border-collapse: separate;\n      }\n\n      th,\n      td {\n         border-width: 1px;\n         padding: 0.56em;\n         position: relative;\n         text-align: center;\n      }\n\n      th,\n      td {\n         border-radius: 0.25em;\n         border-style: solid;\n      }\n\n      th {\n         background: #1f60a0;\n         color: #fff;\n         border-color: #BBB;\n      }\n\n      td {\n         border-color: #DDD;\n      }\n\n      /* page */\n\n      html {\n         font: 16px/1 \"Open Sans\", sans-serif;\n         overflow: auto;\n         padding: 0.4in;\n      }\n\n      html {\n         background: #999;\n         cursor: default;\n      }\n\n      body {\n         box-sizing: border-box;\n         height: 11in;\n         margin: 0 auto;\n         overflow: hidden;\n         padding: 0.5in;\n         width: 8.5in;\n      }\n\n      body {\n         background: #FFF;\n         border-radius: 1px;\n         box-shadow: 0 0 1in -0.25in rgba(0, 0, 0, 0.5);\n      }\n\n      /* header */\n\n      header {\n         margin: 0 0 3em;\n      }\n\n      header:after {\n         clear: both;\n         display: table;\n      }\n\n      header h1 {\n         background: #000;\n         border-radius: 0.25em;\n         color: #FFF;\n         margin: 0 0 1em;\n         padding: 0.4em 0;\n      }\n\n      header address {\n         float: left;\n         font-size: 75%;\n         font-style: normal;\n         line-height: 1.25;\n         margin: 0 1em 1em 0;\n      }\n\n      header address p {\n         margin: 0 0 0.25em;\n      }\n\n      header span,\n      header img {\n         display: block;\n         float: right;\n      }\n\n      header span {\n         margin: 0 0 1em 1em;\n         max-height: 25%;\n         max-width: 60%;\n         position: relative;\n      }\n\n      header img {\n         max-height: 100%;\n         max-width: 100%;\n      }\n\n      header input {\n         cursor: pointer;\n         -ms-filter: \"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)\";\n         height: 100%;\n         left: 0;\n         opacity: 0;\n         position: absolute;\n         top: 0;\n         width: 100%;\n      }\n\n      /* article */\n\n      article,\n      article address,\n      table.meta,\n      table.inventory {\n         margin: 0 0 0.3em;\n      }\n\n      article:after {\n         clear: both;\n         content: \"\";\n         display: table;\n      }\n\n      article h1 {\n         clip: rect(0 0 0 0);\n         position: absolute;\n      }\n\n      article address {\n         float: left;\n         font-size: 30%;\n      }\n\n      /* table meta & balance */\n\n      table.meta,\n      table.balance {\n         float: right;\n         width: 38%;\n      }\n\n      table.meta:after,\n      table.balance:after {\n         clear: both;\n         display: table;\n      }\n\n      /* table meta */\n\n      table.meta th {\n         width: 40%;\n      }\n\n      table.meta td {\n         width: 60%;\n      }\n\n      /* table items */\n\n      table.inventory {\n         clear: both;\n         width: 100%;\n      }\n\n      table.inventory th {\n         font-weight: bold;\n         text-align: center;\n      }\n\n      table.inventory td:nth-child(1) {\n         width: 26%;\n      }\n\n      table.inventory td:nth-child(2) {\n         width: 38%;\n      }\n\n      table.inventory td:nth-child(3) {\n         text-align: center;\n         width: 12%;\n      }\n\n      table.inventory td:nth-child(4) {\n         text-align: center;\n         width: 12%;\n      }\n\n      table.inventory td:nth-child(5) {\n         text-align: center;\n         width: 12%;\n      }\n\n      /* table balance */\n\n      table.balance th {\n         width: 40%;\n         text-align: center;\n      }\n\n      table.balance td {\n         width: 60%;\n         text-align: center;\n      }\n\n      /* aside */\n\n      aside h1 {\n         border: none;\n         border-width: 0 0 1px;\n         margin: 0 0 1em;\n      }\n\n      aside h1 {\n         border-color: #999;\n         border-bottom-style: solid;\n      }\n\n      /* javascript */\n\n      @media print {\n         * {\n            -webkit-print-color-adjust: exact;\n         }\n\n         html {\n            background: none;\n            padding: 0;\n         }\n\n         body {\n            box-shadow: none;\n            margin: 0;\n         }\n\n         span:empty {\n            display: none;\n         }\n      }\n\n      @page {\n         margin: 0;\n      }\n      \n.board{\n    width: 100%;\n    height: 160px;\n    box-sizing: border-box;\n    overflow: hidden;\n}\n.titulo_grafica{\n    width: 100%;\n    height: 10%;\n}\n.titulo_grafica>h3{\n    padding: 0;\n    margin: 0px;\n    text-align: center;\n    color: #666666;\n}\n.sub_board{\n    width: 100%;\n    height: 100%;\n    margin-top: 0px;\n    overflow: hidden;\n    box-sizing: border-box;\n}\n.sep_board{\n    width: 100%;\n    height: 10%;\n}\n.cont_board{\n    width: 100%;\n    height: 80%;\n}\n.graf_board{\n    width: 90%;\n    height: 100%;\n    float: right;\n    margin-top: 0px;\n    background-color: darkgrey;\n    border-left: 2px solid #999999;\n    border-bottom: 2px solid #999999;\n    box-sizing: border-box;\n    display: flex;\n    background: -moz-linear-gradient(top, rgba(0,0,0,0) 0%, \n \n    rgba(0,0,0,0) 100%);\n    background: -webkit-linear-gradient(top, rgba(0,0,0,0) 0%, \n    rgba(0,0,0,0) 100%);\n\n    background: linear-gradient(to bottom, rgba(0,0,0,0) 0%,\n    rgba(0,0,0,0) 100%);\n    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=\"#00ffffff\", endColorstr=\"#00ffffff\",GradientType=0 );\n}\n.barra{\n    width:100%;\n    height: 100%;\n    margin-right: 9px;\n    margin-left: 9px;\n    background-color: none;\n    display: flex;\n    flex-wrap: wrap;\n    align-items: flex-end;\n}\n.sub_barra{\n    width: 100%;\n    height: 80%;\n    background: #00799b;\n    background: -moz-linear-gradient(top, #00799b 0%, #64d1be 100%);\n    \n    -webkit-border-radius: 12px 12px 0 0;\n    border-radius: 12px 12px 0 0;\n}\n.tag_g{\n    position: relative;\n    width: 100%;\n    height: 100%;\n    margin-bottom: 23px;\n    text-align: center;\n    margin-top: -20px;\n    z-index: 2;\n}\n.tag_leyenda{\n    text-align: center;\n    margin-top: 0px;\n}\n.tag_board{\n    height: 100%;\n    width: 15%;\n    border-bottom: 2px solid rgba(0,0,0,0);\n    box-sizing: border-box;\n}\n.sub_tag_board{\n    height: 85%;\n    width: 60%;\n    display: flex;\n    align-items: flex-end;\n    flex-wrap: wrap;\n}\n.sub_tag_board>div{\n    width: 100%;\n    height: 3%;\n    text-align: right;\n    padding-right: 3px;\n    box-sizing: border-box;\n}\n\'.$class.\'\nfooter{\n    position: absolute;\n    bottom: 0px;\n    width: 100%;\n    text-align: center;\n    font-size: 12px;\n    font-family: sans-serif;\n}\n   </style>\n\n    <script type=\"text/javascript\" src=\"inc/bwip/bwip-js-min.js\"></script>\n    \n    <link rel=\"stylesheet\" href=\"inc/pdfLib/all.min.css\">\n    <script type=\"text/javascript\" src=\"inc/pdfLib/html2pdf.bundle.min.js\"></script>\n    \n            <!--<link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css\">-->\n            <!--<script src=\"https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js\"\n              integrity=\"sha512-GsLlZN/3F2ErC5ifS5QtgpiJtWd43JWSuIgh7mbzZ8zBps+dvLusV+eNQATqgA/HdeKFVgA5v3S/cIrLF7QnIg==\"\n              crossorigin=\"anonymous\" referrerpolicy=\"no-referrer\"></script>-->\n      <!-- BARCODE -->\n        <!--<script type=\"text/javascript\" src=\"https://cdn.jsdelivr.net/npm/jsbarcode@3.11.0/dist/JsBarcode.all.min.js\"></script>-->\n        \n		\n	\n		\n</head>\n\n<body id=\"Invoices\">\n   <article>\n      <img\n         src=\"data:image/png;base64,[encoded data, 74668 characters]\"\n         data-filename=\"logoASJ_.png\">\n      <!--<img src=\"./logoASJ_.png\">-->\n      <BR>\n      <BR>\n      <address style=\"width: 62%;\">\n         <div style=\"color:#14406b; font-size: 18px; font-weight: bold;\">AGUAS DE SAN JERONIMO E.S.P</div>\n         <div style=\"font-size: 12px;\">NIT: 811018300-6</div>\n         <div style=\"font-size: 12px;\">CLL 21 # 8-78 San Jerónimo, Ant</div>\n         <BR>\n         <table class=\"info\">\n            <tr>\n                <td>\n                    <p style=\"font-size: 14px;\">\n                        <span style=\"font-weight: bold;\">Contrato N° </span> \' . $factura[\"id_contrato\"] . \' <br>\n                        <span style=\"font-weight: bold;\">Nombre: </span>\' . $factura[\"nombres\"] . \' \' . $factura[\"apellidos\"] . \' <br>\n                        <span style=\"font-weight: bold;\">Vereda: </span>\' . $factura[\"zona\"] . \' <br>\n                        <span style=\"font-weight: bold;\">Dirección: </span>\' . $factura[\"direccion_predio\"] . \' <br>\n                        <span style=\"font-weight: bold;\">Estrato: </span>\' . $factura[\"estrato\"] . \' <br>\n                        <span style=\"font-weight: bold;\">Consumo Periodo: </span>\' . $factura[\"fecha_inicio_facturacion\"] . \' - \' . $factura[\"fecha_fin_facturacion\"] . \' <br>\n                    </p>\n                </td>\n                <!--<td>\n\n                </td>-->\n            </tr>\n         </table>\n\n      </address>\n\n      <table class=\"meta\">\n         <tr>\n            <th style=\"width: 120px !important;\"><span>Factura</span></th>\n            <td><span>\' . $factura[\"id\"] . \'</span></td>\n         </tr>\n         <tr>\n            <th><span>Fecha sin recargo</span></th>\n            <td><span>\' . $factura[\"fecha_sin_recargo\"] . \'</span></td>\n         </tr>\n         <tr>\n            <th><span>Fecha con recargo</span></th>\n            <td><span>\' . $factura[\"fecha_con_recargo\"] . \'</span></td>\n         </tr>\n      </table>\n      <table class=\"info\" style=\"border-collapse: collapse; border:none; border-width: 0px;\">\n        <tr>\n            <td colspan=\"3\" style=\"font-weight: bold;\">INFORMACIÓN ACUEDUCTO</tr>\n        </tr>\n        <tr>\n            <td>\n                <p>\n                    <span style=\"font-weight: bold;\">Medidor </span> \' . $factura[\"numero_medidor\"] . \' <br>\n                    <span style=\"font-weight: bold;\">Diametro </span> 1/2\" <br>\n                </p>\n            </td>\n            <td>\n                <p>\n                    <span style=\"font-weight: bold;\">Lectura actual </span> \' . $factura[\"lectura_actual\"] . \' <br>\n                    <span style=\"font-weight: bold;\">Lectura anterior </span> \' . $factura[\"lectura_anterior\"] . \' <br>\n                </p>\n            </td>\n            <td>\n                <p>\n                    <span style=\"font-weight: bold;\">Estado medidor </span> \' . $estadoMedidor. \' <br>\n                    <span style=\"font-weight: bold;\">Consumo (m3)</span> \' . $factura[\"consumo_actual\"] . \' <br>\n                </p>\n            </td>\n        </tr>\n      </table>\n      <table style=\"border-collapse: collapse; border:none; border-width: 0px;\">\n          <tr>\n            <td width=\"50%\" style=\"border-collapse: collapse; border:none; border-width: 0px; vertical-align: none !important;\">\n              <table style=\"border-collapse: collapse; border:none; border-width: 0px;\">\n              \n                <tr>\n                  <th>MES</th>\n                  <th>M3</th>\n                  <th>CARGO FIJO</th>\n                  <th>TOTAL</th>\n                </tr>\n                \' . $tableData . \'\n              </table>\n            </td>\n            <td width=\"50%\" style=\"border-collapse: collapse; border:none; border-width: 0px;\">\n               <div class=\"board\">\n                <div class=\"titulo_grafica\">\n                    <h3 class=\"t_grafica\">Consumos anteriores en metros cúbicos</h3>\n                </div>\n                <div class=\"sub_board\">\n                    <div class=\"cont_board\">\n                        <div class=\"graf_board\">\n                            \' . $grafBarra . \'\n                        </div>\n                        <div class=\"tag_board\">\n                            <div class=\"sub_tag_board\">\n                                <div>100</div>\n                                <div>90</div>\n                                <div>80</div>\n                                <div>70</div>\n                                <div>60</div>\n                                <div>50</div>\n                                <div>40</div>\n                                <div>30</div>\n                                <div>20</div>\n                                <div>10</div>\n                            </div>\n                        </div>\n                   </div>\n                </div>\n               </div>\n            </td>\n          </tr>\n      </table>\n      <table class=\"info\" style=\"border-collapse: collapse; border:none; border-width: 0px;\">\n        <tr>\n            <td colspan=\"3\" style=\"font-weight: bold;\">COSTOS REFERENCIA ACUEDUCTO</tr>\n        </tr>\n        <tr>\n            <td>\n                <p>\n                    \n                    <span>Cargo Fijo. = \' . $factura[\"valor_tarifa_aplicada\"] . \'</span>\n                </p>\n            </td>\n            <td>\n                <p>\n                    \n                    <span>CMO=Costo por consumo = \' . $factura[\"costo_medio_operacion\"] . \'</span>\n                </p>\n            </td>\n           \n        </tr>\n      </table>\n      <!--<table class=\"inventory\">\n         <thead>\n            <tr>\n               <th><span>Descripción</span></th>\n               <th><span>Cantidad</span></th>\n               <th style=\"background-color: #14406b;\"><span>Precio</span></th>\n            </tr>\n         </thead>\n         <tbody>\n            <tr>\n               <td><span>Consumo de agua m3</span></td>\n               <td><span>\' . $factura[\"consumo_actual\"] . \'</span></td>\n               <td style=\"text-align: center !important;\"><span data-prefix>$</span><span>\' . number_format($factura[\"valor_sin_recargo\"], 0, \',\', \'.\') . \'</span></td>\n            </tr>\n         </tbody>\n      </table> -->\n\n      <table class=\"balance\" style=\"font-size: 11px;\">\n         <tr>\n            <td><span>SUBTOTAL</span></td>\n            <th><span data-prefix>$</span><span>\' . number_format($factura[\"valor_sin_recargo\"] + $factura[\'valor_subsidio\'] + $factura[\'valor_subsidio_cargo_fijo\'], 0, \',\', \'.\') . \'</span></th>\n         </tr>\n         <tr>\n            <td><span>CUENTAS VENCIDAS</span></td>\n            <th><span data-prefix>$</span><span>\' . $saldoPendiente . \'</span></th>\n         </tr>\n         <tr>\n            <td><span>SALDO A FAVOR</span></td>\n            <th><span data-prefix>$</span><span>\' . number_format($saldoFavor, 0, \',\', \'.\') . \'</span></th>\n         </tr>\n         <tr>\n            <td><span>SUBSIDIO</span></td>\n            <th><span data-prefix>$</span><span>\' . number_format($factura[\'valor_subsidio\'] + $factura[\'valor_subsidio_cargo_fijo\']) . \'</span></th>\n         </tr>\n         <tr style=\"color: #fff; font-size: 16px;\">\n            <td style=\"background-color: #1f60a0; font-weight: bold;\"><span>TOTAL</span></td>\n            <th style=\"background-color: #14406b;\"><span data-prefix>$</span><span>\' . $total . \'</span></th>\n         </tr>\n      </table>\n     <address style=\"width: 62%;\">\n      <table>\n            <tr>\n               <td style=\"border-radius: 0 !important; border-style: none !important;\">\n                  <p style=\"font-size: 13px; vertical-align: middle; line-height: normal\">\n                     <span style=\"font-weight: bold;\"> Canales y medios disponibles para hacer el pago de tu\n                        factura</span>\n                     <br>\n                     <br>\n                     <span>Transferencia o consignación a la cuenta de:</span>\n                     <br>\n                     <br>\n                     <span style=\"font-weight: bold;\">Ahorros Bancolombia N°</span>\n                     <br>\n                     <br>\n                     <span style=\"font-weight: bold;\">240-000018-93</span>\n                  </p>\n               </td> \n               <td style=\"border-radius: 0 !important; border-style: none !important;\">\n                    <img src=\"data:image/png;base64,[encoded data, 21620 characters]\" data-filename=\"Firma Ignacio Digital.png\"\n                    data-filename=\"Firma Ignacio Digital.png\" style=\"width: 220px; height: 70px;\">\n                    <p style=\"font-size: 10.3px; font-weight: bold;\">JORGE IGNACIO AREIZA CASTRILLON <BR> GERENTE</p>\n               </td>\n            </tr>\n         </table> \n\n      <BR>\n       </address> \n   </article>\n   <BR>\n   <p style=\"font-size:10px;\">\' . $rayaDesprendibleBanco . \' DESPRENDIBLE PARA EL BANCO \' . $rayaDesprendibleBanco . \'</p>\n   <table style=\"border-collapse: collapse; border:none; border-width: 0px; style=\"vertical-align: middle !important;\">\n        <tr style=\"float: middle; !important;\">\n            <td style=\"border-radius: 0 !important; border-style: none !important; vertical-align: middle !important; width: 30%\">\n                <img \n                	<img src=\"data:image/png;base64,[encoded data, 32188 characters]\"\n	                style=\"width: 208px;\" data-filename=\"Logo2.png\">\n            </td>\n            <td style=\"border-radius: 0 !important; border-style: none !important; vertical-align: middle !important; width:70%\">\n                <img id=\"barcodeTarget\"/>\n                <canvas id=\"mycanvas\" width=\"200\" height=\"100\"></canvas>\n                \n            </td>\n        </tr>\n    </table>\n</body>\n    <script>\n        //https://parzibyte.me/blog/2019/08/19/codigos-barras-javascript-jsbarcode/\n        const hola2 = () => {\n            try {\n               // The return value is the canvas element\n        let canvas = bwipjs.toCanvas(\"mycanvas\", {\n            bcid:        \"code128\",       // Barcode type\n            text:        \"0123456789\",    // Text to encode\n            scale:       3,               // 3x scaling factor\n            height:      10,              // Bar height, in millimeters\n            includetext: true,            // Show human-readable text\n            textxalign:  \"center\",        // Always good to set this\n        });\n                /*const canvas = document.createElement(\"canvas\");\n                const options = {\n                    bcid:        \"code128\",       // Barcode type\n                    text:        \"0123456789\",    // Text to encode\n                    scale:       3,               // 3x scaling factor\n                    height:      10,              // Bar height, in millimeters\n                    includetext: true,            // Show human-readable text\n                    textxalign:  \"center\",        // Always good to set this\n                };\n                bwipjs(canvas, options, (err, cvs) => {\n                    if (err) {\n                        console.log({err});\n                    } else {\n                    console.log({cvs});\n                        // Dont need the second param since we have the canvas in scope...    \n                        document.getElementById(\"barcodeTarget\").src = canvas.toDataURL(\"image/png\");\n                    }\n                }); */\n            } catch (e) {\n                console.log({e});\n                // `e` may be a string or Error object\n            }   \n        };\n        addEventListener(\"DOMContentLoaded\", () => {\n            setTimeout(function(){ hola2(); }, 1000);\n  \n        });\n\n         /* JsBarcode(\"#barcodeTarget\", \"\' . $Barcode. \'\", {\n            format: \"CODE128C\",// El formato\n    		width: 2.67, // La anchura de cada barra\n    		height: 65, // La altura del código\n    		displayValue: true, // ¿Mostrar el valor (como texto) del código de barras?\n    		text: \"\' . $BarcodeParent . \'\", // Texto (no código) que acompaña al barcode\n    		fontSize: 14, // Tamaño de la fuente\n    		fontOptions: \"bold\", // Opciones de la fuente del texto del barcode\n    		ean128: true,\n    	}); */\n	</script>\n   <script> \n      document.addEventListener(\"DOMContentLoaded\", function (event) {\n        //setTimeout(function(){ hola(); }, 1000);\n        var descargar = \' . $descargar . \';\n        if(descargar == 1) {\n             var element = document.getElementById(\"Invoices\");\n             \n             var opt = {\n                filename: \"\' . str_replace(\' \', \'\', $factura[\"nombres\"] . \' \' . $factura[\"apellidos\"]) . \'.pdf\",\n                image: { type: \"jpeg\", quality: 0.98 },\n                html2canvas: { scale: 2, useCORS: true, letterRendering: true },\n                jsPDF: { unit: \"mm\", format: \"letter\", orientation: \"portrait\" }\n             };\n    		 html2pdf(element, opt);\n    		 setTimeout(function(){ window.close(); }, 1650);\n        }\n        });\n        \n        function hola(){\n            var element = document.getElementById(\"Invoices\");\n             \n             var opt = {\n                filename: \"\' . $factura[\"contrato\"] . \'.pdf\",\n                image: { type: \"jpeg\", quality: 0.98 },\n                html2canvas: { scale: 2, useCORS: true, letterRendering: true },\n                jsPDF: { unit: \"mm\", format: \"letter\", orientation: \"portrait\" }\n             };\n    		 html2pdf(element, opt);\n        }\n   </script>\n</html>\';\n\necho $html;\ndie();','A'),(98,'mod/app_facturas/pdf_factura_descargar_tarifa_dinamica.php','2023-04-28 23:43:00','rafael',797,152983,'<?php\n\n @session_start();\n\nif(!isset($_SESSION[\'PCOSESS_SesionAbierta\'])) {\n	echo \'<head><title>Error</title><style type=\"text/css\"> body { background-color: #000000; color: #7f7f7f; font-family: sans-serif,helvetica; } </style></head><body><table width=\"100%\" height=\"100%\" border=0><tr><td align=center>&#9827; Acceso no autorizado !</td></tr></table></body>\';\n	die();\n}\n\n/*include_once \'../../core/configuracion.php\';\ninclude_once \'../../core/conexiones.php\';\ninclude_once \'../../inc/practico/def_basedatos.php\';\ninclude_once \'../../core/comunes.php\';*/\n\n//echo \"$builder\";\n$saldoFavor = $factura[\"saldo_pendiente\"] < 0 ? -$factura[\"saldo_pendiente\"] : 0;\n$saldoPendienteValor = $factura[\"saldo_pendiente\"] > 0 ? $factura[\"saldo_pendiente\"] : 0;\n$saldoPendiente = number_format($saldoPendienteValor, 0, \',\', \'.\');\n\n$descargar = 0;\nif ($PCO_Accion == \"FACTURAS_descargarFactura\")\n    $descargar = 1;\n$fechaSinRecargoBr = str_replace(\"-\", \"\", $factura[\"fecha_sin_recargo\"]);\n$totalValor =  number_format($factura[\"valor_sin_recargo\"] + $saldoPendienteValor - $saldoFavor, 0, \',\', \'.\');\n$total = $totalValor > 0 ? $totalValor : 0;\n$totalBr = str_replace(\".\", \"\", $total);\n$codigobarra=\"7709998678439\";\n$Barcode = $codigobarra.$factura[\"id_contrato\"].\"$totalBr96$fechaSinRecargoBr\";\n$BarcodeParent = \"(415)$codigobarra(8020)\" . $factura[\"id\"] . \"(3900)$totalBr(96)$fechaSinRecargoBr\";\n//$Barcode = \"(415)7709998678439(8020)12345(3900)50000(96)20220524\";\n//$Barcode = \"41577099986784398020123453900500009620220524\";\n//$Barcode = \"12345670\";\n\n$rayaDesprendibleBanco = str_repeat(\"- \", 34);\n\n$estadoMedidor = \"Bueno\";\nif($factura[\"estado_medidor\"] == 2) $estadoMedidor = \"Dañado\";\nif($factura[\"estado_medidor\"] == 3) $estadoMedidor = \"N/A\";\n\nfunction getMesEsp($mes) {\n    $mesesArray = [\"\",\"Ene\", \"Feb\", \"Mar\", \"Abr\", \"May\", \"Jun\", \"Jul\", \"Ago\", \"Sep\", \"Oct\", \"Nov\", \"Dic\"];\n    return $mesesArray[$mes];\n}\n$i = 1;\n$grafBarra = \"\";\n$tableData = \"\";\n$class = \"\";\n\n$consumos = PCO_EjecutarSQL(\"SELECT consumo_actual, MONTH(fecha_fin_facturacion) mes, valor_sin_recargo, saldo_pendiente, valor_tarifa_aplicada\n    FROM \n        app_facturas\n    WHERE \n        id_contrato = \". $factura[\"id_contrato\"]. \" ORDER BY id DESC LIMIT 6\n\")->fetchAll();\n\nforeach ($consumos as $consumo) {\n    $mes = getMesEsp($consumo[\"mes\"]);\n    $totalMes =  number_format($consumo[\"valor_sin_recargo\"], 0, \',\', \'.\');\n    $grafBarra .= \'<div class=\"barra\"><div class=\"sub_barra b\' . $i . \'\"><div class=\"tag_g\">\' . $consumo[\"consumo_actual\"] . \'</div><div class=\"tag_leyenda\">\' . $mes . \'</div></div></div>\';\n    $tableData .= \'<tr><td>\' . $mes . \'</td><td>\' . $consumo[\"consumo_actual\"] . \'</td><td>\' . $consumo[\"valor_tarifa_aplicada\"] . \'</td><td>\' . $totalMes . \'</td></tr>\';\n    $class .= \".b$i { height: \" . (is_numeric($consumo[\"consumo_actual\"]) ? $consumo[\"consumo_actual\"] : 0) . \"%} \";\n    $i++;\n}\n\n$html = \'\n<html>\n\n<head>\n   <meta charset=\"utf-8\">\n   <title>Factura</title>\n   <style>\n      * {\n         border: 0;\n         box-sizing: content-box;\n         color: inherit;\n         font-family: Verdana;\n         font-size: inherit;\n         font-style: inherit;\n         font-weight: inherit;\n         list-style: none;\n         padding: 0;\n         text-decoration: none;\n      }\n\n    table.info, \n    .info td,\n    .info tr {\n        border-width: 0px !important;\n        border-style: none;\n        text-align:left\n    }\n      /* heading */\n\n      h1 {\n         font: bold 100% sans-serif;\n         letter-spacing: 0.5em;\n         text-align: center;\n         text-transform: uppercase;\n      }\n\n      /* table */\n\n      table {\n         font-size: 75%;\n         table-layout: fixed;\n         width: 100%;\n      }\n\n      table {\n         border-collapse: separate;\n      }\n\n      th,\n      td {\n         border-width: 1px;\n         padding: 0.56em;\n         position: relative;\n         text-align: center;\n      }\n\n      th,\n      td {\n         border-radius: 0.25em;\n         border-style: solid;\n      }\n\n      th {\n         background: #1f60a0;\n         color: #fff;\n         border-color: #BBB;\n      }\n\n      td {\n         border-color: #DDD;\n      }\n\n      /* page */\n\n      html {\n         font: 16px/1 \"Open Sans\", sans-serif;\n         overflow: auto;\n         padding: 0.4in;\n      }\n\n      html {\n         background: #999;\n         cursor: default;\n      }\n\n      body {\n         box-sizing: border-box;\n         height: 11in;\n         margin: 0 auto;\n         overflow: hidden;\n         padding: 0.5in;\n         width: 8.5in;\n      }\n\n      body {\n         background: #FFF;\n         border-radius: 1px;\n         box-shadow: 0 0 1in -0.25in rgba(0, 0, 0, 0.5);\n      }\n\n      /* header */\n\n      header {\n         margin: 0 0 3em;\n      }\n\n      header:after {\n         clear: both;\n         display: table;\n      }\n\n      header h1 {\n         background: #000;\n         border-radius: 0.25em;\n         color: #FFF;\n         margin: 0 0 1em;\n         padding: 0.4em 0;\n      }\n\n      header address {\n         float: left;\n         font-size: 75%;\n         font-style: normal;\n         line-height: 1.25;\n         margin: 0 1em 1em 0;\n      }\n\n      header address p {\n         margin: 0 0 0.25em;\n      }\n\n      header span,\n      header img {\n         display: block;\n         float: right;\n      }\n\n      header span {\n         margin: 0 0 1em 1em;\n         max-height: 25%;\n         max-width: 60%;\n         position: relative;\n      }\n\n      header img {\n         max-height: 100%;\n         max-width: 100%;\n      }\n\n      header input {\n         cursor: pointer;\n         -ms-filter: \"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)\";\n         height: 100%;\n         left: 0;\n         opacity: 0;\n         position: absolute;\n         top: 0;\n         width: 100%;\n      }\n\n      /* article */\n\n      article,\n      article address,\n      table.meta,\n      table.inventory {\n         margin: 0 0 0.3em;\n      }\n\n      article:after {\n         clear: both;\n         content: \"\";\n         display: table;\n      }\n\n      article h1 {\n         clip: rect(0 0 0 0);\n         position: absolute;\n      }\n\n      article address {\n         float: left;\n         font-size: 30%;\n      }\n\n      /* table meta & balance */\n\n      table.meta,\n      table.balance {\n         float: right;\n         width: 38%;\n      }\n\n      table.meta:after,\n      table.balance:after {\n         clear: both;\n         display: table;\n      }\n\n      /* table meta */\n\n      table.meta th {\n         width: 40%;\n      }\n\n      table.meta td {\n         width: 60%;\n      }\n\n      /* table items */\n\n      table.inventory {\n         clear: both;\n         width: 100%;\n      }\n\n      table.inventory th {\n         font-weight: bold;\n         text-align: center;\n      }\n\n      table.inventory td:nth-child(1) {\n         width: 26%;\n      }\n\n      table.inventory td:nth-child(2) {\n         width: 38%;\n      }\n\n      table.inventory td:nth-child(3) {\n         text-align: center;\n         width: 12%;\n      }\n\n      table.inventory td:nth-child(4) {\n         text-align: center;\n         width: 12%;\n      }\n\n      table.inventory td:nth-child(5) {\n         text-align: center;\n         width: 12%;\n      }\n\n      /* table balance */\n\n      table.balance th {\n         width: 40%;\n         text-align: center;\n      }\n\n      table.balance td {\n         width: 60%;\n         text-align: center;\n      }\n\n      /* aside */\n\n      aside h1 {\n         border: none;\n         border-width: 0 0 1px;\n         margin: 0 0 1em;\n      }\n\n      aside h1 {\n         border-color: #999;\n         border-bottom-style: solid;\n      }\n\n      /* javascript */\n\n      @media print {\n         * {\n            -webkit-print-color-adjust: exact;\n         }\n\n         html {\n            background: none;\n            padding: 0;\n         }\n\n         body {\n            box-shadow: none;\n            margin: 0;\n         }\n\n         span:empty {\n            display: none;\n         }\n      }\n\n      @page {\n         margin: 0;\n      }\n      \n.board{\n    width: 100%;\n    height: 160px;\n    box-sizing: border-box;\n    overflow: hidden;\n}\n.titulo_grafica{\n    width: 100%;\n    height: 10%;\n}\n.titulo_grafica>h3{\n    padding: 0;\n    margin: 0px;\n    text-align: center;\n    color: #666666;\n}\n.sub_board{\n    width: 100%;\n    height: 100%;\n    margin-top: 0px;\n    overflow: hidden;\n    box-sizing: border-box;\n}\n.sep_board{\n    width: 100%;\n    height: 10%;\n}\n.cont_board{\n    width: 100%;\n    height: 80%;\n}\n.graf_board{\n    width: 90%;\n    height: 100%;\n    float: right;\n    margin-top: 0px;\n    background-color: darkgrey;\n    border-left: 2px solid #999999;\n    border-bottom: 2px solid #999999;\n    box-sizing: border-box;\n    display: flex;\n    background: -moz-linear-gradient(top, rgba(0,0,0,0) 0%, \n \n    rgba(0,0,0,0) 100%);\n    background: -webkit-linear-gradient(top, rgba(0,0,0,0) 0%, \n    rgba(0,0,0,0) 100%);\n\n    background: linear-gradient(to bottom, rgba(0,0,0,0) 0%,\n    rgba(0,0,0,0) 100%);\n    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=\"#00ffffff\", endColorstr=\"#00ffffff\",GradientType=0 );\n}\n.barra{\n    width:100%;\n    height: 100%;\n    margin-right: 9px;\n    margin-left: 9px;\n    background-color: none;\n    display: flex;\n    flex-wrap: wrap;\n    align-items: flex-end;\n}\n.sub_barra{\n    width: 100%;\n    height: 80%;\n    background: #00799b;\n    background: -moz-linear-gradient(top, #00799b 0%, #64d1be 100%);\n    \n    -webkit-border-radius: 12px 12px 0 0;\n    border-radius: 12px 12px 0 0;\n}\n.tag_g{\n    position: relative;\n    width: 100%;\n    height: 100%;\n    margin-bottom: 23px;\n    text-align: center;\n    margin-top: -20px;\n    z-index: 2;\n}\n.tag_leyenda{\n    text-align: center;\n    margin-top: 0px;\n}\n.tag_board{\n    height: 100%;\n    width: 15%;\n    border-bottom: 2px solid rgba(0,0,0,0);\n    box-sizing: border-box;\n}\n.sub_tag_board{\n    height: 85%;\n    width: 60%;\n    display: flex;\n    align-items: flex-end;\n    flex-wrap: wrap;\n}\n.sub_tag_board>div{\n    width: 100%;\n    height: 3%;\n    text-align: right;\n    padding-right: 3px;\n    box-sizing: border-box;\n}\n\'.$class.\'\nfooter{\n    position: absolute;\n    bottom: 0px;\n    width: 100%;\n    text-align: center;\n    font-size: 12px;\n    font-family: sans-serif;\n}\n   </style>\n\n    <script type=\"text/javascript\" src=\"inc/bwip/bwip-js-min.js\"></script>\n    \n    <link rel=\"stylesheet\" href=\"inc/pdfLib/all.min.css\">\n    <script type=\"text/javascript\" src=\"inc/pdfLib/html2pdf.bundle.min.js\"></script>\n    \n            <!--<link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css\">-->\n            <!--<script src=\"https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js\"\n              integrity=\"sha512-GsLlZN/3F2ErC5ifS5QtgpiJtWd43JWSuIgh7mbzZ8zBps+dvLusV+eNQATqgA/HdeKFVgA5v3S/cIrLF7QnIg==\"\n              crossorigin=\"anonymous\" referrerpolicy=\"no-referrer\"></script>-->\n      <!-- BARCODE -->\n        <!--<script type=\"text/javascript\" src=\"https://cdn.jsdelivr.net/npm/jsbarcode@3.11.0/dist/JsBarcode.all.min.js\"></script>-->\n        \n		\n	\n		\n</head>\n\n<body id=\"Invoices\">\n   <article>\n      <img\n         src=\"data:image/png;base64,[encoded data, 74668 characters]\"\n         data-filename=\"logoASJ_.png\">\n      <!--<img src=\"./logoASJ_.png\">-->\n      <BR>\n      <BR>\n      <address style=\"width: 62%;\">\n         <div style=\"color:#14406b; font-size: 18px; font-weight: bold;\">AGUAS DE SAN JERONIMO E.S.P</div>\n         <div style=\"font-size: 12px;\">NIT: 811018300-6</div>\n         <div style=\"font-size: 12px;\">CLL 21 # 8-78 San Jerónimo, Ant</div>\n         <BR>\n         <table class=\"info\">\n            <tr>\n                <td>\n                    <p style=\"font-size: 14px;\">\n                        <span style=\"font-weight: bold;\">Contrato N° </span> \' . $factura[\"id_contrato\"] . \' <br>\n                        <span style=\"font-weight: bold;\">Nombre: </span>\' . $factura[\"nombres\"] . \' \' . $factura[\"apellidos\"] . \' <br>\n                        <span style=\"font-weight: bold;\">Vereda: </span>\' . $factura[\"zona\"] . \' <br>\n                        <span style=\"font-weight: bold;\">Dirección: </span>\' . $factura[\"direccion_predio\"] . \' <br>\n                        <span style=\"font-weight: bold;\">Estrato: </span>\' . $factura[\"estrato\"] . \' <br>\n                        <span style=\"font-weight: bold;\">Consumo Periodo: </span>\' . $factura[\"fecha_inicio_facturacion\"] . \' - \' . $factura[\"fecha_fin_facturacion\"] . \' <br>\n                    </p>\n                </td>\n                <!--<td>\n\n                </td>-->\n            </tr>\n         </table>\n\n      </address>\n\n      <table class=\"meta\">\n         <tr>\n            <th style=\"width: 120px !important;\"><span>Factura</span></th>\n            <td><span>\' . $factura[\"id\"] . \'</span></td>\n         </tr>\n         <tr>\n            <th><span>Fecha sin recargo</span></th>\n            <td><span>\' . $factura[\"fecha_sin_recargo\"] . \'</span></td>\n         </tr>\n         <tr>\n            <th><span>Fecha con recargo</span></th>\n            <td><span>\' . $factura[\"fecha_con_recargo\"] . \'</span></td>\n         </tr>\n      </table>\n      <table class=\"info\" style=\"border-collapse: collapse; border:none; border-width: 0px;\">\n        <tr>\n            <td colspan=\"3\" style=\"font-weight: bold;\">INFORMACIÓN ACUEDUCTO</tr>\n        </tr>\n        <tr>\n            <td>\n                <p>\n                    <span style=\"font-weight: bold;\">Medidor </span> \' . $factura[\"numero_medidor\"] . \' <br>\n                    <span style=\"font-weight: bold;\">Diametro </span> 1/2\" <br>\n                </p>\n            </td>\n            <td>\n                <p>\n                    <span style=\"font-weight: bold;\">Lectura actual </span> \' . $factura[\"lectura_actual\"] . \' <br>\n                    <span style=\"font-weight: bold;\">Lectura anterior </span> \' . $factura[\"lectura_anterior\"] . \' <br>\n                </p>\n            </td>\n            <td>\n                <p>\n                    <span style=\"font-weight: bold;\">Estado medidor </span> \' . $estadoMedidor. \' <br>\n                    <span style=\"font-weight: bold;\">Consumo (m3)</span> \' . $factura[\"consumo_actual\"] . \' <br>\n                </p>\n            </td>\n        </tr>\n      </table>\n      <table style=\"border-collapse: collapse; border:none; border-width: 0px;\">\n          <tr>\n            <td width=\"50%\" style=\"border-collapse: collapse; border:none; border-width: 0px; vertical-align: none !important;\">\n              <table style=\"border-collapse: collapse; border:none; border-width: 0px;\">\n              \n                <tr>\n                  <th>MES</th>\n                  <th>M3</th>\n                  <th>CARGO FIJO</th>\n                  <th>TOTAL</th>\n                </tr>\n                \' . $tableData . \'\n              </table>\n            </td>\n            <td width=\"50%\" style=\"border-collapse: collapse; border:none; border-width: 0px;\">\n               <div class=\"board\">\n                <div class=\"titulo_grafica\">\n                    <h3 class=\"t_grafica\">Consumos anteriores en metros cúbicos</h3>\n                </div>\n                <div class=\"sub_board\">\n                    <div class=\"cont_board\">\n                        <div class=\"graf_board\">\n                            \' . $grafBarra . \'\n                        </div>\n                        <div class=\"tag_board\">\n                            <div class=\"sub_tag_board\">\n                                <div>100</div>\n                                <div>90</div>\n                                <div>80</div>\n                                <div>70</div>\n                                <div>60</div>\n                                <div>50</div>\n                                <div>40</div>\n                                <div>30</div>\n                                <div>20</div>\n                                <div>10</div>\n                            </div>\n                        </div>\n                   </div>\n                </div>\n               </div>\n            </td>\n          </tr>\n      </table>\n      <table class=\"info\" style=\"border-collapse: collapse; border:none; border-width: 0px;\">\n        <tr>\n            <td colspan=\"3\" style=\"font-weight: bold;\">COSTOS REFERENCIA ACUEDUCTO</tr>\n        </tr>\n        <tr>\n            <td>\n                <p>\n                    \n                    <span>Cargo Fijo. = \' . $factura[\"valor_tarifa_aplicada\"] . \'</span>\n                </p>\n            </td>\n            <td>\n                <p>\n                    \n                    <span>CMO=Costo por consumo = \' . $factura[\"costo_medio_operacion\"] . \'</span>\n                </p>\n            </td>\n           \n        </tr>\n      </table>\n      <!--<table class=\"inventory\">\n         <thead>\n            <tr>\n               <th><span>Descripción</span></th>\n               <th><span>Cantidad</span></th>\n               <th style=\"background-color: #14406b;\"><span>Precio</span></th>\n            </tr>\n         </thead>\n         <tbody>\n            <tr>\n               <td><span>Consumo de agua m3</span></td>\n               <td><span>\' . $factura[\"consumo_actual\"] . \'</span></td>\n               <td style=\"text-align: center !important;\"><span data-prefix>$</span><span>\' . number_format($factura[\"valor_sin_recargo\"], 0, \',\', \'.\') . \'</span></td>\n            </tr>\n         </tbody>\n      </table> -->\n\n      <table class=\"balance\" style=\"font-size: 11px;\">\n         <tr>\n            <td><span>SUBTOTAL</span></td>\n            <th><span data-prefix>$</span><span>\' . number_format($factura[\"valor_sin_recargo\"] + $factura[\'valor_subsidio\'] + $factura[\'valor_subsidio_cargo_fijo\'], 0, \',\', \'.\') . \'</span></th>\n         </tr>\n         <tr>\n            <td><span>CUENTAS VENCIDAS</span></td>\n            <th><span data-prefix>$</span><span>\' . $saldoPendiente . \'</span></th>\n         </tr>\n         <tr>\n            <td><span>SALDO A FAVOR</span></td>\n            <th><span data-prefix>$</span><span>\' . number_format($saldoFavor, 0, \',\', \'.\') . \'</span></th>\n         </tr>\n         <tr>\n            <td><span>SUBSIDIO</span></td>\n            <th><span data-prefix>$</span><span>\' . number_format($factura[\'valor_subsidio\'] + $factura[\'valor_subsidio_cargo_fijo\']) . \'</span></th>\n         </tr>\n         <tr style=\"color: #fff; font-size: 16px;\">\n            <td style=\"background-color: #1f60a0; font-weight: bold;\"><span>TOTAL</span></td>\n            <th style=\"background-color: #14406b;\"><span data-prefix>$</span><span>\' . $total . \'</span></th>\n         </tr>\n      </table>\n     <address style=\"width: 62%;\">\n      <table>\n            <tr>\n               <td style=\"border-radius: 0 !important; border-style: none !important;\">\n                  <p style=\"font-size: 13px; vertical-align: middle; line-height: normal\">\n                     <span style=\"font-weight: bold;\"> Canales y medios disponibles para hacer el pago de tu\n                        factura</span>\n                     <br>\n                     <br>\n                     <span>Transferencia o consignación a la cuenta de:</span>\n                     <br>\n                     <br>\n                     <span style=\"font-weight: bold;\">Ahorros Bancolombia N°</span>\n                     <br>\n                     <br>\n                     <span style=\"font-weight: bold;\">240-000018-93</span>\n                  </p>\n               </td> \n               <td style=\"border-radius: 0 !important; border-style: none !important;\">\n                    <img src=\"data:image/png;base64,[encoded data, 21620 characters]\" data-filename=\"Firma Ignacio Digital.png\"\n                    data-filename=\"Firma Ignacio Digital.png\" style=\"width: 220px; height: 70px;\">\n                    <p style=\"font-size: 10.3px; font-weight: bold;\">JORGE IGNACIO AREIZA CASTRILLON <BR> GERENTE</p>\n               </td>\n            </tr>\n         </table> \n\n      <BR>\n       </address> \n   </article>\n   <BR>\n   <p style=\"font-size:10px;\">\' . $rayaDesprendibleBanco . \' DESPRENDIBLE PARA EL BANCO \' . $rayaDesprendibleBanco . \'</p>\n   <table style=\"border-collapse: collapse; border:none; border-width: 0px; style=\"vertical-align: middle !important;\">\n        <tr style=\"float: middle; !important;\">\n            <td style=\"border-radius: 0 !important; border-style: none !important; vertical-align: middle !important; width: 30%\">\n                <img \n                	<img src=\"data:image/png;base64,[encoded data, 32188 characters]\"\n	                style=\"width: 208px;\" data-filename=\"Logo2.png\">\n            </td>\n            <td style=\"border-radius: 0 !important; border-style: none !important; vertical-align: middle !important; width:70%\">\n                <img id=\"barcodeTarget\"/>\n                <canvas id=\"mycanvas\" width=\"200\" height=\"100\"></canvas>\n                \n            </td>\n        </tr>\n    </table>\n</body>\n    <script>\n        //https://parzibyte.me/blog/2019/08/19/codigos-barras-javascript-jsbarcode/\n        const hola2 = () => {\n            try {\n               // The return value is the canvas element\n        let canvas = bwipjs.toCanvas(\"mycanvas\", {\n            bcid:        \"gs1-128\",       // Barcode type\n            text:        \"0123456789\",    // Text to encode\n            scale:       3,               // 3x scaling factor\n            height:      10,              // Bar height, in millimeters\n            includetext: true,            // Show human-readable text\n            textxalign:  \"center\",        // Always good to set this\n        });\n                /*const canvas = document.createElement(\"canvas\");\n                const options = {\n                    bcid:        \"code128\",       // Barcode type\n                    text:        \"\' . $Barcode. \'\",    // Text to encode\n                    scale:       3,               // 3x scaling factor\n                    height:      10,              // Bar height, in millimeters\n                    includetext: true,            // Show human-readable text\n                    textxalign:  \"center\",        // Always good to set this\n                };\n                bwipjs(canvas, options, (err, cvs) => {\n                    if (err) {\n                        console.log({err});\n                    } else {\n                    console.log({cvs});\n                        // Dont need the second param since we have the canvas in scope...    \n                        document.getElementById(\"barcodeTarget\").src = canvas.toDataURL(\"image/png\");\n                    }\n                }); */\n            } catch (e) {\n                console.log({e});\n                // `e` may be a string or Error object\n            }   \n        };\n        addEventListener(\"DOMContentLoaded\", () => {\n            setTimeout(function(){ hola2(); }, 1000);\n  \n        });\n\n         /* JsBarcode(\"#barcodeTarget\", \"\' . $Barcode. \'\", {\n            format: \"CODE128C\",// El formato\n    		width: 2.67, // La anchura de cada barra\n    		height: 65, // La altura del código\n    		displayValue: true, // ¿Mostrar el valor (como texto) del código de barras?\n    		text: \"\' . $BarcodeParent . \'\", // Texto (no código) que acompaña al barcode\n    		fontSize: 14, // Tamaño de la fuente\n    		fontOptions: \"bold\", // Opciones de la fuente del texto del barcode\n    		ean128: true,\n    	}); */\n	</script>\n   <script> \n      document.addEventListener(\"DOMContentLoaded\", function (event) {\n        //setTimeout(function(){ hola(); }, 1000);\n        var descargar = \' . $descargar . \';\n        if(descargar == 1) {\n             var element = document.getElementById(\"Invoices\");\n             \n             var opt = {\n                filename: \"\' . str_replace(\' \', \'\', $factura[\"nombres\"] . \' \' . $factura[\"apellidos\"]) . \'.pdf\",\n                image: { type: \"jpeg\", quality: 0.98 },\n                html2canvas: { scale: 2, useCORS: true, letterRendering: true },\n                jsPDF: { unit: \"mm\", format: \"letter\", orientation: \"portrait\" }\n             };\n    		 html2pdf(element, opt);\n    		 setTimeout(function(){ window.close(); }, 1650);\n        }\n        });\n        \n        function hola(){\n            var element = document.getElementById(\"Invoices\");\n             \n             var opt = {\n                filename: \"\' . $factura[\"contrato\"] . \'.pdf\",\n                image: { type: \"jpeg\", quality: 0.98 },\n                html2canvas: { scale: 2, useCORS: true, letterRendering: true },\n                jsPDF: { unit: \"mm\", format: \"letter\", orientation: \"portrait\" }\n             };\n    		 html2pdf(element, opt);\n        }\n   </script>\n</html>\';\n\necho $html;\ndie();','A'),(99,'mod/app_facturas/pdf_factura_descargar_tarifa_dinamica.php','2023-04-28 23:43:00','rafael',797,152988,'<?php\n\n @session_start();\n\nif(!isset($_SESSION[\'PCOSESS_SesionAbierta\'])) {\n	echo \'<head><title>Error</title><style type=\"text/css\"> body { background-color: #000000; color: #7f7f7f; font-family: sans-serif,helvetica; } </style></head><body><table width=\"100%\" height=\"100%\" border=0><tr><td align=center>&#9827; Acceso no autorizado !</td></tr></table></body>\';\n	die();\n}\n\n/*include_once \'../../core/configuracion.php\';\ninclude_once \'../../core/conexiones.php\';\ninclude_once \'../../inc/practico/def_basedatos.php\';\ninclude_once \'../../core/comunes.php\';*/\n\n//echo \"$builder\";\n$saldoFavor = $factura[\"saldo_pendiente\"] < 0 ? -$factura[\"saldo_pendiente\"] : 0;\n$saldoPendienteValor = $factura[\"saldo_pendiente\"] > 0 ? $factura[\"saldo_pendiente\"] : 0;\n$saldoPendiente = number_format($saldoPendienteValor, 0, \',\', \'.\');\n\n$descargar = 0;\nif ($PCO_Accion == \"FACTURAS_descargarFactura\")\n    $descargar = 1;\n$fechaSinRecargoBr = str_replace(\"-\", \"\", $factura[\"fecha_sin_recargo\"]);\n$totalValor =  number_format($factura[\"valor_sin_recargo\"] + $saldoPendienteValor - $saldoFavor, 0, \',\', \'.\');\n$total = $totalValor > 0 ? $totalValor : 0;\n$totalBr = str_replace(\".\", \"\", $total);\n$codigobarra=\"7709998678439\";\n$Barcode = $codigobarra.$factura[\"id_contrato\"].\"$totalBr96$fechaSinRecargoBr\";\n$BarcodeParent = \"(415)$codigobarra(8020)\" . $factura[\"id\"] . \"(3900)$totalBr(96)$fechaSinRecargoBr\";\n//$Barcode = \"(415)7709998678439(8020)12345(3900)50000(96)20220524\";\n//$Barcode = \"41577099986784398020123453900500009620220524\";\n//$Barcode = \"12345670\";\n\n$rayaDesprendibleBanco = str_repeat(\"- \", 34);\n\n$estadoMedidor = \"Bueno\";\nif($factura[\"estado_medidor\"] == 2) $estadoMedidor = \"Dañado\";\nif($factura[\"estado_medidor\"] == 3) $estadoMedidor = \"N/A\";\n\nfunction getMesEsp($mes) {\n    $mesesArray = [\"\",\"Ene\", \"Feb\", \"Mar\", \"Abr\", \"May\", \"Jun\", \"Jul\", \"Ago\", \"Sep\", \"Oct\", \"Nov\", \"Dic\"];\n    return $mesesArray[$mes];\n}\n$i = 1;\n$grafBarra = \"\";\n$tableData = \"\";\n$class = \"\";\n\n$consumos = PCO_EjecutarSQL(\"SELECT consumo_actual, MONTH(fecha_fin_facturacion) mes, valor_sin_recargo, saldo_pendiente, valor_tarifa_aplicada\n    FROM \n        app_facturas\n    WHERE \n        id_contrato = \". $factura[\"id_contrato\"]. \" ORDER BY id DESC LIMIT 6\n\")->fetchAll();\n\nforeach ($consumos as $consumo) {\n    $mes = getMesEsp($consumo[\"mes\"]);\n    $totalMes =  number_format($consumo[\"valor_sin_recargo\"], 0, \',\', \'.\');\n    $grafBarra .= \'<div class=\"barra\"><div class=\"sub_barra b\' . $i . \'\"><div class=\"tag_g\">\' . $consumo[\"consumo_actual\"] . \'</div><div class=\"tag_leyenda\">\' . $mes . \'</div></div></div>\';\n    $tableData .= \'<tr><td>\' . $mes . \'</td><td>\' . $consumo[\"consumo_actual\"] . \'</td><td>\' . $consumo[\"valor_tarifa_aplicada\"] . \'</td><td>\' . $totalMes . \'</td></tr>\';\n    $class .= \".b$i { height: \" . (is_numeric($consumo[\"consumo_actual\"]) ? $consumo[\"consumo_actual\"] : 0) . \"%} \";\n    $i++;\n}\n\n$html = \'\n<html>\n\n<head>\n   <meta charset=\"utf-8\">\n   <title>Factura</title>\n   <style>\n      * {\n         border: 0;\n         box-sizing: content-box;\n         color: inherit;\n         font-family: Verdana;\n         font-size: inherit;\n         font-style: inherit;\n         font-weight: inherit;\n         list-style: none;\n         padding: 0;\n         text-decoration: none;\n      }\n\n    table.info, \n    .info td,\n    .info tr {\n        border-width: 0px !important;\n        border-style: none;\n        text-align:left\n    }\n      /* heading */\n\n      h1 {\n         font: bold 100% sans-serif;\n         letter-spacing: 0.5em;\n         text-align: center;\n         text-transform: uppercase;\n      }\n\n      /* table */\n\n      table {\n         font-size: 75%;\n         table-layout: fixed;\n         width: 100%;\n      }\n\n      table {\n         border-collapse: separate;\n      }\n\n      th,\n      td {\n         border-width: 1px;\n         padding: 0.56em;\n         position: relative;\n         text-align: center;\n      }\n\n      th,\n      td {\n         border-radius: 0.25em;\n         border-style: solid;\n      }\n\n      th {\n         background: #1f60a0;\n         color: #fff;\n         border-color: #BBB;\n      }\n\n      td {\n         border-color: #DDD;\n      }\n\n      /* page */\n\n      html {\n         font: 16px/1 \"Open Sans\", sans-serif;\n         overflow: auto;\n         padding: 0.4in;\n      }\n\n      html {\n         background: #999;\n         cursor: default;\n      }\n\n      body {\n         box-sizing: border-box;\n         height: 11in;\n         margin: 0 auto;\n         overflow: hidden;\n         padding: 0.5in;\n         width: 8.5in;\n      }\n\n      body {\n         background: #FFF;\n         border-radius: 1px;\n         box-shadow: 0 0 1in -0.25in rgba(0, 0, 0, 0.5);\n      }\n\n      /* header */\n\n      header {\n         margin: 0 0 3em;\n      }\n\n      header:after {\n         clear: both;\n         display: table;\n      }\n\n      header h1 {\n         background: #000;\n         border-radius: 0.25em;\n         color: #FFF;\n         margin: 0 0 1em;\n         padding: 0.4em 0;\n      }\n\n      header address {\n         float: left;\n         font-size: 75%;\n         font-style: normal;\n         line-height: 1.25;\n         margin: 0 1em 1em 0;\n      }\n\n      header address p {\n         margin: 0 0 0.25em;\n      }\n\n      header span,\n      header img {\n         display: block;\n         float: right;\n      }\n\n      header span {\n         margin: 0 0 1em 1em;\n         max-height: 25%;\n         max-width: 60%;\n         position: relative;\n      }\n\n      header img {\n         max-height: 100%;\n         max-width: 100%;\n      }\n\n      header input {\n         cursor: pointer;\n         -ms-filter: \"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)\";\n         height: 100%;\n         left: 0;\n         opacity: 0;\n         position: absolute;\n         top: 0;\n         width: 100%;\n      }\n\n      /* article */\n\n      article,\n      article address,\n      table.meta,\n      table.inventory {\n         margin: 0 0 0.3em;\n      }\n\n      article:after {\n         clear: both;\n         content: \"\";\n         display: table;\n      }\n\n      article h1 {\n         clip: rect(0 0 0 0);\n         position: absolute;\n      }\n\n      article address {\n         float: left;\n         font-size: 30%;\n      }\n\n      /* table meta & balance */\n\n      table.meta,\n      table.balance {\n         float: right;\n         width: 38%;\n      }\n\n      table.meta:after,\n      table.balance:after {\n         clear: both;\n         display: table;\n      }\n\n      /* table meta */\n\n      table.meta th {\n         width: 40%;\n      }\n\n      table.meta td {\n         width: 60%;\n      }\n\n      /* table items */\n\n      table.inventory {\n         clear: both;\n         width: 100%;\n      }\n\n      table.inventory th {\n         font-weight: bold;\n         text-align: center;\n      }\n\n      table.inventory td:nth-child(1) {\n         width: 26%;\n      }\n\n      table.inventory td:nth-child(2) {\n         width: 38%;\n      }\n\n      table.inventory td:nth-child(3) {\n         text-align: center;\n         width: 12%;\n      }\n\n      table.inventory td:nth-child(4) {\n         text-align: center;\n         width: 12%;\n      }\n\n      table.inventory td:nth-child(5) {\n         text-align: center;\n         width: 12%;\n      }\n\n      /* table balance */\n\n      table.balance th {\n         width: 40%;\n         text-align: center;\n      }\n\n      table.balance td {\n         width: 60%;\n         text-align: center;\n      }\n\n      /* aside */\n\n      aside h1 {\n         border: none;\n         border-width: 0 0 1px;\n         margin: 0 0 1em;\n      }\n\n      aside h1 {\n         border-color: #999;\n         border-bottom-style: solid;\n      }\n\n      /* javascript */\n\n      @media print {\n         * {\n            -webkit-print-color-adjust: exact;\n         }\n\n         html {\n            background: none;\n            padding: 0;\n         }\n\n         body {\n            box-shadow: none;\n            margin: 0;\n         }\n\n         span:empty {\n            display: none;\n         }\n      }\n\n      @page {\n         margin: 0;\n      }\n      \n.board{\n    width: 100%;\n    height: 160px;\n    box-sizing: border-box;\n    overflow: hidden;\n}\n.titulo_grafica{\n    width: 100%;\n    height: 10%;\n}\n.titulo_grafica>h3{\n    padding: 0;\n    margin: 0px;\n    text-align: center;\n    color: #666666;\n}\n.sub_board{\n    width: 100%;\n    height: 100%;\n    margin-top: 0px;\n    overflow: hidden;\n    box-sizing: border-box;\n}\n.sep_board{\n    width: 100%;\n    height: 10%;\n}\n.cont_board{\n    width: 100%;\n    height: 80%;\n}\n.graf_board{\n    width: 90%;\n    height: 100%;\n    float: right;\n    margin-top: 0px;\n    background-color: darkgrey;\n    border-left: 2px solid #999999;\n    border-bottom: 2px solid #999999;\n    box-sizing: border-box;\n    display: flex;\n    background: -moz-linear-gradient(top, rgba(0,0,0,0) 0%, \n \n    rgba(0,0,0,0) 100%);\n    background: -webkit-linear-gradient(top, rgba(0,0,0,0) 0%, \n    rgba(0,0,0,0) 100%);\n\n    background: linear-gradient(to bottom, rgba(0,0,0,0) 0%,\n    rgba(0,0,0,0) 100%);\n    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=\"#00ffffff\", endColorstr=\"#00ffffff\",GradientType=0 );\n}\n.barra{\n    width:100%;\n    height: 100%;\n    margin-right: 9px;\n    margin-left: 9px;\n    background-color: none;\n    display: flex;\n    flex-wrap: wrap;\n    align-items: flex-end;\n}\n.sub_barra{\n    width: 100%;\n    height: 80%;\n    background: #00799b;\n    background: -moz-linear-gradient(top, #00799b 0%, #64d1be 100%);\n    \n    -webkit-border-radius: 12px 12px 0 0;\n    border-radius: 12px 12px 0 0;\n}\n.tag_g{\n    position: relative;\n    width: 100%;\n    height: 100%;\n    margin-bottom: 23px;\n    text-align: center;\n    margin-top: -20px;\n    z-index: 2;\n}\n.tag_leyenda{\n    text-align: center;\n    margin-top: 0px;\n}\n.tag_board{\n    height: 100%;\n    width: 15%;\n    border-bottom: 2px solid rgba(0,0,0,0);\n    box-sizing: border-box;\n}\n.sub_tag_board{\n    height: 85%;\n    width: 60%;\n    display: flex;\n    align-items: flex-end;\n    flex-wrap: wrap;\n}\n.sub_tag_board>div{\n    width: 100%;\n    height: 3%;\n    text-align: right;\n    padding-right: 3px;\n    box-sizing: border-box;\n}\n\'.$class.\'\nfooter{\n    position: absolute;\n    bottom: 0px;\n    width: 100%;\n    text-align: center;\n    font-size: 12px;\n    font-family: sans-serif;\n}\n   </style>\n\n    <script type=\"text/javascript\" src=\"inc/bwip/bwip-js-min.js\"></script>\n    \n    <link rel=\"stylesheet\" href=\"inc/pdfLib/all.min.css\">\n    <script type=\"text/javascript\" src=\"inc/pdfLib/html2pdf.bundle.min.js\"></script>\n    \n            <!--<link rel=\"stylesheet\" href=\"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.1/css/all.min.css\">-->\n            <!--<script src=\"https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js\"\n              integrity=\"sha512-GsLlZN/3F2ErC5ifS5QtgpiJtWd43JWSuIgh7mbzZ8zBps+dvLusV+eNQATqgA/HdeKFVgA5v3S/cIrLF7QnIg==\"\n              crossorigin=\"anonymous\" referrerpolicy=\"no-referrer\"></script>-->\n      <!-- BARCODE -->\n        <!--<script type=\"text/javascript\" src=\"https://cdn.jsdelivr.net/npm/jsbarcode@3.11.0/dist/JsBarcode.all.min.js\"></script>-->\n        \n		\n	\n		\n</head>\n\n<body id=\"Invoices\">\n   <article>\n      <img\n         src=\"data:image/png;base64,[encoded data, 74668 characters]\"\n         data-filename=\"logoASJ_.png\">\n      <!--<img src=\"./logoASJ_.png\">-->\n      <BR>\n      <BR>\n      <address style=\"width: 62%;\">\n         <div style=\"color:#14406b; font-size: 18px; font-weight: bold;\">AGUAS DE SAN JERONIMO E.S.P</div>\n         <div style=\"font-size: 12px;\">NIT: 811018300-6</div>\n         <div style=\"font-size: 12px;\">CLL 21 # 8-78 San Jerónimo, Ant</div>\n         <BR>\n         <table class=\"info\">\n            <tr>\n                <td>\n                    <p style=\"font-size: 14px;\">\n                        <span style=\"font-weight: bold;\">Contrato N° </span> \' . $factura[\"id_contrato\"] . \' <br>\n                        <span style=\"font-weight: bold;\">Nombre: </span>\' . $factura[\"nombres\"] . \' \' . $factura[\"apellidos\"] . \' <br>\n                        <span style=\"font-weight: bold;\">Vereda: </span>\' . $factura[\"zona\"] . \' <br>\n                        <span style=\"font-weight: bold;\">Dirección: </span>\' . $factura[\"direccion_predio\"] . \' <br>\n                        <span style=\"font-weight: bold;\">Estrato: </span>\' . $factura[\"estrato\"] . \' <br>\n                        <span style=\"font-weight: bold;\">Consumo Periodo: </span>\' . $factura[\"fecha_inicio_facturacion\"] . \' - \' . $factura[\"fecha_fin_facturacion\"] . \' <br>\n                    </p>\n                </td>\n                <!--<td>\n\n                </td>-->\n            </tr>\n         </table>\n\n      </address>\n\n      <table class=\"meta\">\n         <tr>\n            <th style=\"width: 120px !important;\"><span>Factura</span></th>\n            <td><span>\' . $factura[\"id\"] . \'</span></td>\n         </tr>\n         <tr>\n            <th><span>Fecha sin recargo</span></th>\n            <td><span>\' . $factura[\"fecha_sin_recargo\"] . \'</span></td>\n         </tr>\n         <tr>\n            <th><span>Fecha con recargo</span></th>\n            <td><span>\' . $factura[\"fecha_con_recargo\"] . \'</span></td>\n         </tr>\n      </table>\n      <table class=\"info\" style=\"border-collapse: collapse; border:none; border-width: 0px;\">\n        <tr>\n            <td colspan=\"3\" style=\"font-weight: bold;\">INFORMACIÓN ACUEDUCTO</tr>\n        </tr>\n        <tr>\n            <td>\n                <p>\n                    <span style=\"font-weight: bold;\">Medidor </span> \' . $factura[\"numero_medidor\"] . \' <br>\n                    <span style=\"font-weight: bold;\">Diametro </span> 1/2\" <br>\n                </p>\n            </td>\n            <td>\n                <p>\n                    <span style=\"font-weight: bold;\">Lectura actual </span> \' . $factura[\"lectura_actual\"] . \' <br>\n                    <span style=\"font-weight: bold;\">Lectura anterior </span> \' . $factura[\"lectura_anterior\"] . \' <br>\n                </p>\n            </td>\n            <td>\n                <p>\n                    <span style=\"font-weight: bold;\">Estado medidor </span> \' . $estadoMedidor. \' <br>\n                    <span style=\"font-weight: bold;\">Consumo (m3)</span> \' . $factura[\"consumo_actual\"] . \' <br>\n                </p>\n            </td>\n        </tr>\n      </table>\n      <table style=\"border-collapse: collapse; border:none; border-width: 0px;\">\n          <tr>\n            <td width=\"50%\" style=\"border-collapse: collapse; border:none; border-width: 0px; vertical-align: none !important;\">\n              <table style=\"border-collapse: collapse; border:none; border-width: 0px;\">\n              \n                <tr>\n                  <th>MES</th>\n                  <th>M3</th>\n                  <th>CARGO FIJO</th>\n                  <th>TOTAL</th>\n                </tr>\n                \' . $tableData . \'\n              </table>\n            </td>\n            <td width=\"50%\" style=\"border-collapse: collapse; border:none; border-width: 0px;\">\n               <div class=\"board\">\n                <div class=\"titulo_grafica\">\n                    <h3 class=\"t_grafica\">Consumos anteriores en metros cúbicos</h3>\n                </div>\n                <div class=\"sub_board\">\n                    <div class=\"cont_board\">\n                        <div class=\"graf_board\">\n                            \' . $grafBarra . \'\n                        </div>\n                        <div class=\"tag_board\">\n                            <div class=\"sub_tag_board\">\n                                <div>100</div>\n                                <div>90</div>\n                                <div>80</div>\n                                <div>70</div>\n                                <div>60</div>\n                                <div>50</div>\n                                <div>40</div>\n                                <div>30</div>\n                                <div>20</div>\n                                <div>10</div>\n                            </div>\n                        </div>\n                   </div>\n                </div>\n               </div>\n            </td>\n          </tr>\n      </table>\n      <table class=\"info\" style=\"border-collapse: collapse; border:none; border-width: 0px;\">\n        <tr>\n            <td colspan=\"3\" style=\"font-weight: bold;\">COSTOS REFERENCIA ACUEDUCTO</tr>\n        </tr>\n        <tr>\n            <td>\n                <p>\n                    \n                    <span>Cargo Fijo. = \' . $factura[\"valor_tarifa_aplicada\"] . \'</span>\n                </p>\n            </td>\n            <td>\n                <p>\n                    \n                    <span>CMO=Costo por consumo = \' . $factura[\"costo_medio_operacion\"] . \'</span>\n                </p>\n            </td>\n           \n        </tr>\n      </table>\n      <!--<table class=\"inventory\">\n         <thead>\n            <tr>\n               <th><span>Descripción</span></th>\n               <th><span>Cantidad</span></th>\n               <th style=\"background-color: #14406b;\"><span>Precio</span></th>\n            </tr>\n         </thead>\n         <tbody>\n            <tr>\n               <td><span>Consumo de agua m3</span></td>\n               <td><span>\' . $factura[\"consumo_actual\"] . \'</span></td>\n               <td style=\"text-align: center !important;\"><span data-prefix>$</span><span>\' . number_format($factura[\"valor_sin_recargo\"], 0, \',\', \'.\') . \'</span></td>\n            </tr>\n         </tbody>\n      </table> -->\n\n      <table class=\"balance\" style=\"font-size: 11px;\">\n         <tr>\n            <td><span>SUBTOTAL</span></td>\n            <th><span data-prefix>$</span><span>\' . number_format($factura[\"valor_sin_recargo\"] + $factura[\'valor_subsidio\'] + $factura[\'valor_subsidio_cargo_fijo\'], 0, \',\', \'.\') . \'</span></th>\n         </tr>\n         <tr>\n            <td><span>CUENTAS VENCIDAS</span></td>\n            <th><span data-prefix>$</span><span>\' . $saldoPendiente . \'</span></th>\n         </tr>\n         <tr>\n            <td><span>SALDO A FAVOR</span></td>\n            <th><span data-prefix>$</span><span>\' . number_format($saldoFavor, 0, \',\', \'.\') . \'</span></th>\n         </tr>\n         <tr>\n            <td><span>SUBSIDIO</span></td>\n            <th><span data-prefix>$</span><span>\' . number_format($factura[\'valor_subsidio\'] + $factura[\'valor_subsidio_cargo_fijo\']) . \'</span></th>\n         </tr>\n         <tr style=\"color: #fff; font-size: 16px;\">\n            <td style=\"background-color: #1f60a0; font-weight: bold;\"><span>TOTAL</span></td>\n            <th style=\"background-color: #14406b;\"><span data-prefix>$</span><span>\' . $total . \'</span></th>\n         </tr>\n      </table>\n     <address style=\"width: 62%;\">\n      <table>\n            <tr>\n               <td style=\"border-radius: 0 !important; border-style: none !important;\">\n                  <p style=\"font-size: 13px; vertical-align: middle; line-height: normal\">\n                     <span style=\"font-weight: bold;\"> Canales y medios disponibles para hacer el pago de tu\n                        factura</span>\n                     <br>\n                     <br>\n                     <span>Transferencia o consignación a la cuenta de:</span>\n                     <br>\n                     <br>\n                     <span style=\"font-weight: bold;\">Ahorros Bancolombia N°</span>\n                     <br>\n                     <br>\n                     <span style=\"font-weight: bold;\">240-000018-93</span>\n                  </p>\n               </td> \n               <td style=\"border-radius: 0 !important; border-style: none !important;\">\n                    <img src=\"data:image/png;base64,[encoded data, 21620 characters]\" data-filename=\"Firma Ignacio Digital.png\"\n                    data-filename=\"Firma Ignacio Digital.png\" style=\"width: 220px; height: 70px;\">\n                    <p style=\"font-size: 10.3px; font-weight: bold;\">JORGE IGNACIO AREIZA CASTRILLON <BR> GERENTE</p>\n               </td>\n            </tr>\n         </table> \n\n      <BR>\n       </address> \n   </article>\n   <BR>\n   <p style=\"font-size:10px;\">\' . $rayaDesprendibleBanco . \' DESPRENDIBLE PARA EL BANCO \' . $rayaDesprendibleBanco . \'</p>\n   <table style=\"border-collapse: collapse; border:none; border-width: 0px; style=\"vertical-align: middle !important;\">\n        <tr style=\"float: middle; !important;\">\n            <td style=\"border-radius: 0 !important; border-style: none !important; vertical-align: middle !important; width: 30%\">\n                <img \n                	<img src=\"data:image/png;base64,[encoded data, 32188 characters]\"\n	                style=\"width: 208px;\" data-filename=\"Logo2.png\">\n            </td>\n            <td style=\"border-radius: 0 !important; border-style: none !important; vertical-align: middle !important; width:70%\">\n                <img id=\"barcodeTarget\"/>\n                <canvas id=\"mycanvas\" width=\"200\" height=\"100\"></canvas>\n                \n            </td>\n        </tr>\n    </table>\n</body>\n    <script>\n        //https://parzibyte.me/blog/2019/08/19/codigos-barras-javascript-jsbarcode/\n        const hola2 = () => {\n            try {\n               // The return value is the canvas element\n        let canvas = bwipjs.toCanvas(\"mycanvas\", {\n            bcid:        \"gs1-128\",       // Barcode type\n            text:        \"\' . $Barcode. \'\",    // Text to encode\n            scale:       3,               // 3x scaling factor\n            height:      10,              // Bar height, in millimeters\n            includetext: true,            // Show human-readable text\n            textxalign:  \"center\",        // Always good to set this\n        });\n                /*const canvas = document.createElement(\"canvas\");\n                const options = {\n                    bcid:        \"gs1-128\",       // Barcode type\n                    text:        \"\' . $Barcode. \'\",    // Text to encode\n                    scale:       3,               // 3x scaling factor\n                    height:      10,              // Bar height, in millimeters\n                    includetext: true,            // Show human-readable text\n                    textxalign:  \"center\",        // Always good to set this\n                };\n                bwipjs(canvas, options, (err, cvs) => {\n                    if (err) {\n                        console.log({err});\n                    } else {\n                    console.log({cvs});\n                        // Dont need the second param since we have the canvas in scope...    \n                        document.getElementById(\"barcodeTarget\").src = canvas.toDataURL(\"image/png\");\n                    }\n                }); */\n            } catch (e) {\n                console.log({e});\n                // `e` may be a string or Error object\n            }   \n        };\n        addEventListener(\"DOMContentLoaded\", () => {\n            setTimeout(function(){ hola2(); }, 1000);\n  \n        });\n\n         /* JsBarcode(\"#barcodeTarget\", \"\' . $Barcode. \'\", {\n            format: \"CODE128C\",// El formato\n    		width: 2.67, // La anchura de cada barra\n    		height: 65, // La altura del código\n    		displayValue: true, // ¿Mostrar el valor (como texto) del código de barras?\n    		text: \"\' . $BarcodeParent . \'\", // Texto (no código) que acompaña al barcode\n    		fontSize: 14, // Tamaño de la fuente\n    		fontOptions: \"bold\", // Opciones de la fuente del texto del barcode\n    		ean128: true,\n    	}); */\n	</script>\n   <script> \n      document.addEventListener(\"DOMContentLoaded\", function (event) {\n        //setTimeout(function(){ hola(); }, 1000);\n        var descargar = \' . $descargar . \';\n        if(descargar == 1) {\n             var element = document.getElementById(\"Invoices\");\n             \n             var opt = {\n                filename: \"\' . str_replace(\' \', \'\', $factura[\"nombres\"] . \' \' . $factura[\"apellidos\"]) . \'.pdf\",\n                image: { type: \"jpeg\", quality: 0.98 },\n                html2canvas: { scale: 2, useCORS: true, letterRendering: true },\n                jsPDF: { unit: \"mm\", format: \"letter\", orientation: \"portrait\" }\n             };\n    		 html2pdf(element, opt);\n    		 setTimeout(function(){ window.close(); }, 1650);\n        }\n        });\n        \n        function hola(){\n            var element = document.getElementById(\"Invoices\");\n             \n             var opt = {\n                filename: \"\' . $factura[\"contrato\"] . \'.pdf\",\n                image: { type: \"jpeg\", quality: 0.98 },\n                html2canvas: { scale: 2, useCORS: true, letterRendering: true },\n                jsPDF: { unit: \"mm\", format: \"letter\", orientation: \"portrait\" }\n             };\n    		 html2pdf(element, opt);\n        }\n   </script>\n</html>\';\n\necho $html;\ndie();','A'),