public function generarPDF($pedido_cab_id, $salida_archivo_pdf) { $MPDFApp = new MPDFApp(); $PedidoCabDAO = new PedidoCabDAO(); $PedidoDetDAO = new PedidoDetDAO(); $reader = new \Zend\Config\Reader\Ini(); $config = $reader->fromFile('ini/config.ini'); $plantilla_pdf = $config['plantilla_pdf']['dispo']['ruta'] . "pdf_pedido.html"; $plantilla_html = utf8_decode(file_get_contents($plantilla_pdf)); $PedidoCabDAO->setEntityManager($this->getEntityManager()); $PedidoDetDAO->setEntityManager($this->getEntityManager()); //Consulta la cabecera del pedido $reg_pedido_cab = $PedidoCabDAO->consultar($pedido_cab_id, \Application\Constants\ResultType::MATRIZ); //Consulta el detalle del pedido $condiciones = array('pedido_cab_id' => $pedido_cab_id, 'cliente_id' => null); $result_det = $PedidoDetDAO->listado($condiciones); //Inicializa la configuracion //set_time_limit ( 0 ); ini_set('memory_limit', '-1'); //$mpdf=new \mPDF('c', array(210, 297),10,'serif',2,2,30,13,9,9,'L'); $mpdf = new \mPDF('c', array(210, 297), 10, 'serif', 10, 10, 40, 13, 9, 9, 'P'); $mpdf->useSubstitutions = false; $mpdf->simpleTables = true; $mpdf->SetDisplayMode('fullpage'); $html = $plantilla_html; //Fecha Impresion $fec_impresion = \Application\Classes\Fecha::getFechaImpresion(\Application\Classes\Fecha::getFechaHoraActualServidor(), \Application\Classes\Fecha::IMPRESION_FECHA_LARGA); $html = str_replace('$$fec_impresion$$', $fec_impresion, $html); //Numero de Pedido $html = str_replace('$$pedido_cab_id$$', \Application\Classes\Mascara::getNroPedidoFormateado($pedido_cab_id, $config['pedido']['mascara']), $html); //Nombre del Cliente $html = str_replace('$$nombre_cliente$$', $reg_pedido_cab['cliente_nombre'], $html); //Direccion $html = str_replace('$$direccion_cliente$$', $reg_pedido_cab['cliente_direccion'], $html); //Telefono 1 $html = str_replace('$$telefono1_cliente$$', $reg_pedido_cab['cliente_telefono1'], $html); //Fax 1 $html = str_replace('$$fax1_cliente$$', $reg_pedido_cab['cliente_fax1'], $html); //Nombre Marcacion $html = str_replace('$$nombre_marcacion$$', $reg_pedido_cab['marcacion_nombre'], $html); //Nombre Marcacion $html = str_replace('$$direccion_marcacion$$', $reg_pedido_cab['marcacion_direccion'], $html); //Telefono Marcacion $html = str_replace('$$telefono_marcacion$$', $reg_pedido_cab['marcacion_telefono'], $html); //Fecha Ingreso $fec_ingreso = \Application\Classes\Fecha::getFechaImpresion($reg_pedido_cab['fec_ingreso'], \Application\Classes\Fecha::IMPRESION_FECHA_LARGA); $html = str_replace('$$fec_creado$$', $fec_ingreso, $html); //Fecha Confirmado $fec_confirmado = \Application\Classes\Fecha::getFechaImpresion($reg_pedido_cab['fec_confirmado'], \Application\Classes\Fecha::IMPRESION_FECHA_LARGA); $html = str_replace('$$fec_confirmado$$', $fec_confirmado, $html); //Fecha Despacho $fec_despacho = \Application\Classes\Fecha::getFechaImpresion($reg_pedido_cab['fec_despacho'], \Application\Classes\Fecha::IMPRESION_FECHA_CORTA); $html = str_replace('$$fec_despacho$$', $fec_despacho, $html); //Comentario $html = str_replace('$$comentario$$', $reg_pedido_cab['comentario'], $html); $html_det = ''; $total = 0; $tot_eq_fb = 0; foreach ($result_det as $reg) { $format_price_item = '$' . number_format($reg['precio'], 2); $format_total_box = '$' . number_format($reg['total_x_caja'], 2); $format_total = '$' . number_format($reg['total'], 2); $html_det = $html_det . ' <tr> <td>' . $reg['variedad_nombre'] . '</td> <td align="center">' . $reg['grado_id'] . '</td> <td align="center">' . $reg['tallos_x_bunch'] . '</td> <td align="center">' . $reg['tipo_caja_nombre'] . '</td> <td align="center">' . $reg['cantidad_bunch'] / $reg['nro_cajas'] . '</td> <td align="center">' . $reg['nro_cajas'] . '</td> <td align="center">' . $reg['tallos_total'] . '</td> <td align="right">' . $format_price_item . '</td> <td align="right">' . $format_total_box . '</td> <td align="right" >' . $format_total . '</td> <td>' . $reg['marca'] . '</td> </tr> '; $total = $total + $reg['total']; $tot_eq_fb = $tot_eq_fb + $reg['eq_fb']; } //end foreach //Detalles del Pedido $html = str_replace('$$detalle_factura$$', $html_det, $html); //Total Eq FB $html = str_replace('$$eq_fb$$', $tot_eq_fb, $html); //Total del Pedido $total_format = '$' . number_format($total, 2); $html = str_replace('$$total$$', $total_format, $html); $mpdf->WriteHTML($html); if (empty($salida_archivo_pdf)) { $mpdf->Output(); } else { $mpdf->Output($salida_archivo_pdf, 'F'); } //end if return true; }