/**
  * Crea PDF de la nomina un piloto especifico 
  */
 public function dp_pdf()
 {
     $res = $this->getDetallePiloto();
     $this->load->library('mypdf');
     // Creación del objeto de la clase heredada
     $pdf = new MYpdf('L', 'mm', 'Letter');
     $pdf->titulo2 = 'Nomina del Piloto ' . $res['piloto']->nombre;
     $pdf->titulo3 = 'Del: ' . $this->input->get('ffecha1') . " Al " . $this->input->get('ffecha2') . "\n";
     // 		$pdf->titulo3 .= ($this->input->get('ftipo') == 'pv'? 'Plazo vencido': 'Pendientes por pagar');
     $pdf->AliasNbPages();
     //$pdf->AddPage();
     $pdf->SetFont('Arial', '', 8);
     $aligns = array('C', 'C', 'C', 'C', 'C', 'C', 'C');
     $widths = array(20, 30, 20, 107, 30, 30, 30);
     $header = array('Fecha', 'Avión', 'Cantidad', 'Descripción', 'Vuelos', 'Abonos', 'Saldo');
     $total_cargo = 0;
     $total_abono = 0;
     $total_saldo = 0;
     $bad_saldo_ante = true;
     if (isset($res['anterior']->total_saldo)) {
         //se suma a los totales del saldo anterior
         $total_cargo += $res['anterior']->total_vuelos;
         $total_abono += $res['anterior']->total_abonos;
         $total_saldo += $res['anterior']->total_saldo;
     } else {
         $res['anterior'] = new stdClass();
         $res['anterior']->total_vuelos = 0;
         $res['anterior']->total_abonos = 0;
         $res['anterior']->total_saldo = 0;
     }
     $res['anterior']->concepto = 'Saldo anterior a ' . $this->input->get('ffecha1');
     foreach ($res['cuentas'] as $key => $item) {
         $band_head = false;
         if ($pdf->GetY() >= $pdf->limiteY || $key == 0) {
             //salta de pagina si exede el max
             $pdf->AddPage();
             $pdf->SetFont('Arial', 'B', 8);
             $pdf->SetTextColor(255, 255, 255);
             $pdf->SetFillColor(160, 160, 160);
             $pdf->SetX(6);
             $pdf->SetAligns($aligns);
             $pdf->SetWidths($widths);
             $pdf->Row($header, true);
         }
         $pdf->SetFont('Arial', '', 8);
         $pdf->SetTextColor(0, 0, 0);
         if ($bad_saldo_ante) {
             $pdf->SetX(6);
             $pdf->SetAligns($aligns);
             $pdf->SetWidths($widths);
             $pdf->Row(array('', '', '', $res['anterior']->concepto, String::formatoNumero($res['anterior']->total_vuelos), String::formatoNumero($res['anterior']->total_abonos), String::formatoNumero($res['anterior']->total_saldo)), false);
             $bad_saldo_ante = false;
         }
         if ($item->tipo == 'vu') {
             $total_cargo += $item->total_vuelos;
             $total_saldo += $item->total_vuelos;
         } elseif ($item->tipo == 'ab') {
             $item->cantidad_vuelos = '';
             $total_abono += $item->total_abonos;
             $total_saldo -= $item->total_abonos;
         }
         $datos = array($item->fecha, $item->matricula, $item->cantidad_vuelos, $item->descripcion, String::formatoNumero($item->total_vuelos), String::formatoNumero($item->total_abonos), String::formatoNumero($total_saldo));
         $pdf->SetX(6);
         $pdf->SetAligns($aligns);
         $pdf->SetWidths($widths);
         $pdf->Row($datos, false);
     }
     $pdf->SetX(6);
     $pdf->SetFont('Arial', 'B', 8);
     $pdf->SetTextColor(255, 255, 255);
     $pdf->SetWidths(array(177, 30, 30, 30));
     $pdf->Row(array('Totales:', String::formatoNumero($total_cargo), String::formatoNumero($total_abono), String::formatoNumero($total_saldo)), true);
     $pdf->Output('cuentas_proveedor.pdf', 'I');
 }
 /**
  * Descarga el listado de cuentas por pagar en formato pdf
  */
 public function detalleTicketFacturaPdf()
 {
     $res = $this->getDetalleTicketFacturaData();
     $this->load->library('mypdf');
     // Creación del objeto de la clase heredada
     $pdf = new MYpdf('P', 'mm', 'Letter');
     $pdf->titulo2 = 'Detalle de factura ' . $res['cobro'][0]->serie . '-' . $res['cobro'][0]->folio . ' (' . $res['cobro'][0]->fecha . ')';
     $pdf->titulo3 = $res['cliente']->nombre_fiscal . "\n";
     $pdf->titulo3 .= 'Del: ' . $this->input->get('ffecha1') . " Al " . $this->input->get('ffecha2');
     $pdf->AliasNbPages();
     //$pdf->AddPage();
     $pdf->SetFont('Arial', '', 8);
     $aligns = array('C', 'C', 'C', 'C');
     $widths = array(25, 96, 40, 40);
     $header = array('Fecha', 'Concepto', 'Abono', 'Saldo');
     $total_abono = 0;
     $total_saldo = $res['cobro'][0]->total;
     $bad_cargot = true;
     foreach ($res['abonos'] as $key => $item) {
         $total_abono += $item->abono;
         $total_saldo -= $item->abono;
         if ($pdf->GetY() >= $pdf->limiteY || $key == 0) {
             //salta de pagina si exede el max
             $pdf->AddPage();
             $pdf->SetFont('Arial', 'B', 8);
             $pdf->SetTextColor(255, 255, 255);
             $pdf->SetFillColor(160, 160, 160);
             $pdf->SetX(6);
             if ($bad_cargot) {
                 $pdf->SetX(6);
                 $pdf->SetAligns(array('R'));
                 $pdf->SetWidths(array(201));
                 $pdf->Row(array('Total: ' . String::formatoNumero($res['cobro'][0]->total)), true);
                 $bad_cargot = false;
             }
             $pdf->SetX(6);
             $pdf->SetAligns($aligns);
             $pdf->SetWidths($widths);
             $pdf->Row($header, true);
         }
         $pdf->SetFont('Arial', '', 8);
         $pdf->SetTextColor(0, 0, 0);
         $datos = array($item->fecha, $item->concepto, String::formatoNumero($item->abono), String::formatoNumero($total_saldo));
         $pdf->SetX(6);
         $pdf->SetAligns($aligns);
         $pdf->SetWidths($widths);
         $pdf->Row($datos, false);
     }
     $pdf->SetX(6);
     $pdf->SetFont('Arial', 'B', 8);
     $pdf->SetTextColor(255, 255, 255);
     $pdf->SetWidths(array(121, 40, 40));
     $pdf->Row(array('Totales:', String::formatoNumero($total_abono), String::formatoNumero($total_saldo)), true);
     $pdf->Output('detalle.pdf', 'I');
 }
 public function pdf_rsa($data)
 {
     if ($_GET['dfecha1'] != '' && $_GET['dfecha2'] != '') {
         $labelFechas = "Desde la fecha " . $_GET['dfecha1'] . " hasta " . $_GET['dfecha2'];
     } elseif ($_GET['dfecha1'] != "") {
         $labelFechas = "Desde la fecha " . $_GET['dfecha1'];
     } elseif ($_GET['dfecha2'] != '') {
         $labelFechas = "Hasta la fecha " . $_GET['dfecha2'];
     }
     $this->load->library('mypdf');
     // Creación del objeto de la clase heredada
     $pdf = new MYpdf('P', 'mm', 'Letter');
     $pdf->show_head = true;
     $pdf->titulo2 = 'Reporte Salidas Vuelos';
     $lbl_pro = '';
     if (isset($_GET['ida'])) {
         if ($_GET['ida'] != '') {
             $this->load->database();
             $m = $this->db->select('matricula')->from('aviones')->where('id_avion', $_GET['ida'])->get();
             $lbl_pro = " Avion Matricula {$m->row()->matricula}";
         }
     }
     $pdf->titulo3 = "{$lbl_pro} \n" . $labelFechas;
     $pdf->AliasNbPages();
     $pdf->AddPage();
     $links = array('', '');
     $aligns = array('C', 'C');
     $widths = array(155, 50);
     $header = array('Avión', 'Total');
     if ($data['tipo'] == 'sa') {
         $links = array('', '', '', '');
         $aligns = array('C', 'C', 'C', 'C');
         $widths = array(55, 50, 50, 50);
         $header = array('Nombre', 'Cantidad', 'P. UNITARIO', 'Total');
     }
     $ttotal = 0;
     foreach ($data['data'] as $key => $item) {
         if ($data['tipo'] != 'av') {
             $pdf->SetFont('Arial', 'B', 9);
             $pdf->SetTextColor(0, 0, 0);
             $pdf->SetX(6);
             $pdf->MultiCell(200, 8, 'Salida Folio #' . $item->folio . ' Fecha ' . $item->fecha, 0, 'L');
             $pdf->SetFont('Arial', 'B', 8);
             $pdf->SetTextColor(255, 255, 255);
             $pdf->SetFillColor(160, 160, 160);
             $pdf->SetX(6);
             $pdf->SetAligns($aligns);
             $pdf->SetWidths($widths);
             $pdf->Row($header, true);
             $pdf->SetFont('Arial', '', 8);
             $pdf->SetTextColor(0, 0, 0);
             foreach ($item->productos as $key2 => $prod) {
                 if ($pdf->GetY() >= $pdf->limiteY) {
                     //salta de pagina si exede el max
                     $pdf->AddPage();
                 }
                 $ttotal += floatval($prod->total);
                 $datarow = array($prod->nombre, $prod->cantidad, String::formatoNumero($prod->precio_unitario), String::formatoNumero($prod->total));
                 $links[0] = base_url('panel/salidas/pdf_rsa/?dfecha1=' . $_GET['dfecha1'] . '&dfecha2=' . $_GET['dfecha2'] . '&idp=' . $prod->id_producto . '&tp=t');
                 $pdf->SetX(6);
                 $pdf->SetAligns($aligns);
                 $pdf->SetWidths($widths);
                 $pdf->SetMyLinks($links);
                 $pdf->Row($datarow, false);
             }
         } else {
             if ($pdf->GetY() >= $pdf->limiteY || $key == 0) {
                 //salta de pagina si exede el max
                 if ($key > 0) {
                     $pdf->AddPage();
                 }
                 $pdf->SetFont('Arial', 'B', 8);
                 $pdf->SetTextColor(255, 255, 255);
                 $pdf->SetFillColor(160, 160, 160);
                 $pdf->SetX(6);
                 $pdf->SetAligns($aligns);
                 $pdf->SetWidths($widths);
                 $pdf->Row($header, true);
             }
             $ttotal += floatval($item->total_salida);
             $datarow = array($item->avion, String::formatoNumero($item->total_salida));
             $get_pid = $_GET['didproducto'] != '' ? '&idp=' . $_GET['didproducto'] : '';
             $links[0] = base_url('panel/salidas/pdf_rsa/?dfecha1=' . $_GET['dfecha1'] . '&dfecha2=' . $_GET['dfecha2'] . '&ida=' . $item->id_avion . $get_pid);
             $pdf->SetX(6);
             $pdf->SetAligns($aligns);
             $pdf->SetWidths($widths);
             $pdf->SetMyLinks($links);
             $pdf->Row($datarow, false);
         }
     }
     if (COUNT($data['data']) > 0) {
         $y = $pdf->GetY();
         $pdf->SetFont('Arial', 'B', 10);
         $pdf->SetTextColor(255, 255, 255);
         $pdf->SetFillColor(140, 140, 140);
         $pdf->SetXY(130, $y + 5);
         $pdf->Cell(31, 6, 'Total', 1, 0, 'C', 1);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFillColor(255, 255, 255);
         $pdf->SetXY(161, $y + 5);
         $pdf->Cell(50, 6, String::formatoNumero($ttotal, 2), 1, 0, 'C');
     }
     $pdf->Output('reporte.pdf', 'I');
 }
 private function imprimir()
 {
     if (isset($_GET['id'][0])) {
         $this->load->model('salidas_model');
         $res = $this->salidas_model->getInfoSalida($_GET['id']);
         $subtotal = 0;
         $iva = 0;
         $total = 0;
         $this->load->library('mypdf');
         // Creacion del objeto de la clase heredada
         $pdf = new MYpdf('P', 'mm', 'Letter');
         $pdf->show_head = false;
         $pdf->AddPage();
         $pdf->SetFont('Arial', '', 8);
         $y = 30;
         $pdf->Image(APPPATH . '/images/logo.png', 15, 10, 25, 25, "PNG");
         $txt = $res['info']->status == 'sa' ? "SALIDA DE ALMACEN" : "BAJA DE PRODUCTO";
         $pdf->SetFont('Arial', 'B', 17);
         $pdf->SetXY(45, $y - 10);
         $pdf->MultiCell(120, 6, "F U M I G A C I O N E S   A E R E A S \n\n {$txt}", 0, 'C', 0);
         // ----------- FOLIO ------------------
         $pdf->SetXY(170, $y - 8);
         $pdf->Cell(30, 15, '', 1, 0, 'C');
         $pdf->SetFont('Arial', 'B', 11);
         $pdf->SetTextColor(255, 255, 255);
         $pdf->SetFillColor(160, 160, 160);
         $pdf->SetXY(170, $y - 8);
         $pdf->Cell(30, 5, 'FOLIO', 1, 0, 'C', 1);
         $pdf->SetFont('Arial', '', 18);
         $pdf->SetTextColor(255, 0, 0);
         $pdf->SetFillColor(255, 255, 255);
         $pdf->SetXY(170, $y - 3);
         $pdf->Cell(30, 10, $res['info']->folio, 0, 0, 'C');
         // ----------- FECHA ------------------
         $pdf->SetXY(170, $y + 8);
         $pdf->Cell(30, 12, '', 1, 0, 'C');
         $pdf->SetFont('Arial', 'B', 11);
         $pdf->SetTextColor(255, 255, 255);
         $pdf->SetFillColor(160, 160, 160);
         $pdf->SetXY(170, $y + 8);
         $pdf->Cell(30, 5, 'FECHA', 1, 0, 'C', 1);
         $pdf->SetFont('Arial', '', 15);
         $pdf->SetTextColor(255, 0, 0);
         $pdf->SetFillColor(255, 255, 255);
         $pdf->SetXY(170, $y + 13);
         $pdf->Cell(30, 7, $res['info']->fecha, 1, 0, 'C', 1);
         // ----------- DATOS DEL AVION|TRABAJADOR|VEHICULO ------------------
         $pdf->SetXY(15, $y + 9);
         $pdf->Cell(153, 23, '', 1, 0, 'C');
         $txt = '';
         switch ($res['info']->tipo_salida) {
             case 'av':
                 $txt = 'AVIÓN';
                 break;
             case 'tr':
                 $txt = 'TRABAJADOR';
                 break;
             case 've':
                 $txt = 'VEHÍCULO';
                 break;
             default:
                 $txt = 'NINGUNO';
                 break;
         }
         $pdf->SetFont('Arial', 'B', 11);
         $pdf->SetTextColor('0', '0', '0');
         $pdf->SetXY(15, $y + 9);
         $pdf->Cell(20, 5, 'Tipo:', 0, 0, 'L');
         $pdf->SetFont('Arial', '', 12);
         $pdf->SetXY(35, $y + 9);
         $pdf->Cell(130, 5, $txt, 0, 0, 'L');
         if ($res['info']->tipo_salida == 'av') {
             $pdf->SetXY(15, $y + 15);
             $pdf->Cell(20, 5, 'Matrícula:', 0, 0, 'L');
             $pdf->SetXY(15, $y + 22);
             $pdf->Cell(20, 5, 'Modelo:', 0, 0, 'L');
             $pdf->SetFont('Arial', '', 12);
             $pdf->SetXY(35, $y + 15);
             $pdf->Cell(130, 5, strtoupper($res['info_tipo'][0]->matricula), 0, 0, 'L');
             $pdf->SetXY(35, $y + 22);
             $pdf->Cell(130, 5, strtoupper($res['info_tipo'][0]->modelo), 0, 0, 'L');
         } elseif ($res['info']->tipo_salida == 'tr') {
             $domicilio = $res['info_tipo'][0]->calle != '' ? $res['info_tipo'][0]->calle : '';
             $domicilio .= $res['info_tipo'][0]->no_exterior != '' ? ' No. ' . $res['info_tipo'][0]->no_exterior : '';
             $domicilio .= $res['info_tipo'][0]->colonia != '' ? ' Col. ' . $res['info_tipo'][0]->colonia : '';
             $pdf->SetXY(15, $y + 15);
             $pdf->Cell(20, 5, 'Nombre:', 0, 0, 'L');
             $pdf->SetXY(15, $y + 22);
             $pdf->Cell(20, 5, 'Domicilio:', 0, 0, 'L');
             $pdf->SetFont('Arial', '', 12);
             $pdf->SetXY(35, $y + 15);
             $pdf->Cell(130, 5, strtoupper($res['info_tipo'][0]->nombre), 0, 0, 'L');
             $pdf->SetXY(35, $y + 22);
             $pdf->Cell(130, 5, strtoupper($domicilio), 0, 0, 'L');
         } elseif ($res['info']->tipo_salida == 've') {
             $txt = $res['info_tipo'][0]->placas != '' ? $res['info_tipo'][0]->placas : '';
             $txt .= $res['info_tipo'][0]->modelo != '' ? '           MODELO: ' . $res['info_tipo'][0]->modelo : '';
             $pdf->SetXY(15, $y + 15);
             $pdf->Cell(20, 5, 'Nombre:', 0, 0, 'L');
             $pdf->SetXY(15, $y + 22);
             $pdf->Cell(20, 5, 'Placas:', 0, 0, 'L');
             $pdf->SetFont('Arial', '', 12);
             $pdf->SetXY(35, $y + 15);
             $pdf->Cell(130, 5, strtoupper($res['info_tipo'][0]->nombre), 0, 0, 'L');
             $pdf->SetXY(35, $y + 22);
             $pdf->Cell(130, 5, strtoupper($txt), 0, 0, 'L');
         }
         // ----------- TABLA CON LOS PRODUCTOS ------------------
         $pdf->SetY($y + 33);
         $aligns = array('C', 'C');
         $widths = array(40, 145);
         $header = array('Cantidad', 'Descripción');
         foreach ($res['productos'] as $key => $item) {
             $band_head = false;
             if ($pdf->GetY() >= 200 || $key == 0) {
                 //salta de pagina si exede el max
                 if ($key > 0) {
                     $pdf->AddPage();
                 }
                 $pdf->SetFont('Arial', 'B', 8);
                 $pdf->SetTextColor(255, 255, 255);
                 $pdf->SetFillColor(160, 160, 160);
                 $pdf->SetX(15);
                 $pdf->SetAligns($aligns);
                 $pdf->SetWidths($widths);
                 $pdf->Row($header, true);
             }
             $pdf->SetFont('Arial', '', 10);
             $pdf->SetTextColor(0, 0, 0);
             $subtotal += floatval($item->importe);
             $iva += floatval($item->importe_iva);
             $datos = array($item->cantidad . ' ' . $item->abreviatura, $item->nombre);
             $pdf->SetX(15);
             $pdf->SetAligns($aligns);
             $pdf->SetWidths($widths);
             $pdf->Row($datos, false);
         }
         //------------ SUBTOTAL, IVA ,TOTAL --------------------
         // 			$total= floatval($subtotal + $iva);
         // 			$y = $pdf->GetY();
         // 			$pdf->SetFont('Arial','B',10);
         // 			$pdf->SetTextColor(255,255,255);
         // 			$pdf->SetFillColor(160,160,160);
         // 			$pdf->SetXY(144, ($y+5));
         // 			$pdf->Cell(23, 8, 'Subtotal' , 1, 0, 'C',1);
         // 			$pdf->SetXY(144, ($y+13));
         // 			$pdf->Cell(23, 8, 'IVA' , 1, 0, 'C',1);
         // 			$pdf->SetXY(144, ($y+21));
         // 			$pdf->Cell(23, 8, 'Total' , 1, 0, 'C',1);
         // 			$pdf->SetTextColor(0,0,0);
         // 			$pdf->SetFillColor(255,255,255);
         // 			$pdf->SetXY(167, ($y+5));
         // 			$pdf->Cell(33, 8, String::formatoNumero($subtotal,2) , 1, 0, 'C');
         // 			$pdf->SetXY(167, ($y+13));
         // 			$pdf->Cell(33, 8, String::formatoNumero($iva,2) , 1, 0, 'C');
         // 			$pdf->SetXY(167, ($y+21));
         // 			$pdf->Cell(33, 8, String::formatoNumero($total,2) , 1, 0, 'C');
         // 			//------------ TOTAL CON LETRA--------------------
         // 			$pdf->SetXY(15, ($y+5));
         // 			$pdf->Cell(125, 24, '' , 1, 0, 'C');
         // 			$pdf->SetFont('Arial','B',13);
         // 			$pdf->SetXY(15, ($y+5));
         // 			$pdf->Cell(60, 8, 'IMPORTE CON LETRA' , 0, 0, 'L');
         // 			$pdf->SetFont('Arial','',12);
         // 			$pdf->SetXY(15, ($y+13));
         // 			$pdf->Cell(125, 16, String::num2letras($total) , 0, 0, 'C');
         $pdf->Output('salida.pdf', 'I');
     }
 }
Exemple #5
0
 public function generarPDFQR($data = array(), $accion = array('F'), $update = false)
 {
     if (count($data) > 0) {
         $ci =& get_instance();
         $ci->load->library('mypdf');
         // Creacion del objeto de la clase heredada
         $pdf = new MYpdf('P', 'mm', 'Letter');
         $pdf->show_head = false;
         $pdf->AddPage();
         $pdf->SetFont('Arial', '', 8);
         $y = 40;
         if ($data['info_empresa']->logo != '') {
             $pdf->Image($data['info_empresa']->logo, 8, 12, 35);
         }
         $pdf->SetFont('Arial', 'B', 15);
         $pdf->SetXY(38, $y - 30);
         $pdf->Cell(170, 6, $data['info_empresa']->nombre_fiscal, 0, 0, 'C');
         $dir1 = $data['info_empresa']->calle != '' ? $data['info_empresa']->calle : '';
         $dir1 .= $data['info_empresa']->no_exterior != '' ? ' ' . $data['info_empresa']->no_exterior : '';
         $dir1 .= $data['info_empresa']->no_interior != '' ? '-' . $data['info_empresa']->no_interior : '';
         $dir1 .= $data['info_empresa']->colonia != '' ? ', ' . $data['info_empresa']->colonia : '';
         $dir2 = $data['info_empresa']->municipio != '' ? $data['info_empresa']->municipio : '';
         $dir2 .= $data['info_empresa']->estado != '' ? ', ' . $data['info_empresa']->estado : '';
         $dir2 .= $data['info_empresa']->cp != '' ? ', CP: ' . $data['info_empresa']->cp : '';
         $pdf->SetFont('Arial', '', 11);
         $pdf->SetXY(38, $y - 23);
         $pdf->MultiCell(170, 6, "R.F.C." . $data['info_empresa']->rfc . " \n " . $dir1 . " \n " . $dir2 . " \n " . $data['info_empresa']->regimen_fiscal . " ", 0, 'C', 0);
         $pdf->SetDrawColor(140, 140, 140);
         $pdf->SetFont('Arial', '', 9);
         $pdf->SetXY(8, $y);
         $pdf->SetTextColor(255, 0, 0);
         $pdf->Cell(170, 6, ($data['info_empresa']->telefono != '' ? "Tel. " . $data['info_empresa']->telefono : '') . ($data['info_empresa']->email != '' ? " | Email. " . $data['info_empresa']->email : '') . ($data['info_empresa']->pag_web != '' ? " | " . $data['info_empresa']->pag_web : ''), 0, 0, 'L');
         $pdf->SetTextColor(0, 0, 0);
         // ----------- FOLIO ------------------
         $pdf->SetFont('Arial', '', 13);
         $pdf->SetXY(164, $y);
         $pdf->Cell(38, 7, substr($data['fecha'], 0, 10) < '2012-10-31' ? 'Recibo de honorarios' : 'Factura', 0, 0, 'C');
         $pdf->SetXY(158, $y + 7);
         $pdf->Cell(50, 13, '', 1, 0, 'C');
         $pdf->SetFont('Arial', 'B', 11);
         $pdf->SetTextColor(255, 255, 255);
         $pdf->SetFillColor(140, 140, 140);
         $pdf->SetXY(158, $y + 7);
         $pdf->Cell(50, 5, 'Serie y Folio', 1, 0, 'C', 1);
         $pdf->SetFont('Arial', '', 12);
         $pdf->SetTextColor(255, 0, 0);
         $pdf->SetFillColor(255, 255, 255);
         $pdf->SetXY(158, $y + 12);
         $pdf->Cell(50, 8, ($data['serie'] != '' ? $data['serie'] . '-' : '') . $data['folio'], 0, 0, 'C');
         // ----------- FECHA ------------------
         $pdf->SetXY(158, $y + 21);
         $pdf->Cell(50, 13, '', 1, 0, 'C');
         $pdf->SetFont('Arial', 'B', 11);
         $pdf->SetTextColor(255, 255, 255);
         $pdf->SetFillColor(140, 140, 140);
         $pdf->SetXY(158, $y + 21);
         $pdf->Cell(50, 5, 'Fecha de Expedición', 1, 0, 'C', 1);
         $pdf->SetFont('Arial', '', 12);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFillColor(255, 255, 255);
         $pdf->SetXY(158, $y + 26);
         $pdf->Cell(50, 8, substr($data['fecha'], 0, 10), 1, 0, 'C', 1);
         // ----------- No y Año aprob ------------------
         $pdf->SetXY(158, $y + 35);
         $pdf->Cell(50, 13, '', 1, 0, 'C');
         $pdf->SetFont('Arial', 'B', 11);
         $pdf->SetTextColor(255, 255, 255);
         $pdf->SetFillColor(140, 140, 140);
         $pdf->SetXY(158, $y + 35);
         $pdf->Cell(50, 5, 'No. y Año aprobracion', 1, 0, 'C', 1);
         $pdf->SetFont('Arial', '', 12);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFillColor(255, 255, 255);
         $pdf->SetXY(158, $y + 40);
         $pdf->Cell(50, 8, $data['no_aprobacion'] . '-' . substr($data['ano_aprobacion'], 0, 4), 1, 0, 'C', 1);
         // ----------- No Certificado ------------------
         // $pdf->SetXY(158, ($y+20));
         // $pdf->Cell(50, 13, '' , 1, 0, 'C');
         // $pdf->SetFont('Arial','B',11);
         // $pdf->SetTextColor(255,255,255);
         // $pdf->SetFillColor(140,140,140);
         // $pdf->SetXY(158, ($y+20));
         // $pdf->Cell(50, 5, 'No. Certificado' , 1, 0, 'C',1);
         // $pdf->SetFont('Arial','',12);
         // $pdf->SetTextColor(255,0,0);
         // $pdf->SetFillColor(255,255,255);
         // $pdf->SetXY(158, ($y+25));
         // $pdf->Cell(50, 8, $data['no_certificado'] , 1, 0, 'C',1);
         // ----------- DATOS CLIENTE ------------------
         $pdf->SetXY(8, $y + 7);
         $pdf->Cell(149, 41, '', 1, 0, 'C');
         $pdf->SetFont('Arial', 'B', 9);
         $pdf->SetTextColor(255, 255, 255);
         $pdf->SetFillColor(140, 140, 140);
         $pdf->SetXY(8, $y + 7);
         // BLOQUE DATOS 1
         $pdf->Cell(16, 41, '', 0, 0, 'C', 1);
         $pdf->SetXY(8, $y + 9);
         $pdf->Cell(16, 6, 'R.F.C.', 0, 0, 'L');
         $pdf->SetXY(8, $y + 15);
         $pdf->Cell(16, 6, 'NOMBRE', 0, 0, 'L');
         $pdf->SetXY(8, $y + 21);
         $pdf->Cell(16, 6, 'CALLE', 0, 0, 'L');
         $pdf->SetXY(8, $y + 27);
         $pdf->Cell(16, 6, 'NUMERO', 0, 0, 'L');
         $pdf->SetXY(8, $y + 33);
         $pdf->Cell(16, 6, 'COLONIA', 0, 0, 'L');
         $pdf->SetXY(8, $y + 39);
         $pdf->Cell(16, 6, 'EDO', 0, 0, 'L');
         $pdf->SetXY(70, $y + 27);
         // BLOQUE DATOS 2
         $pdf->Cell(18, 21, '', 0, 0, 'C', 1);
         $pdf->SetXY(70, $y + 27);
         $pdf->Cell(18, 6, 'INT', 0, 0, 'L');
         $pdf->SetXY(70, $y + 33);
         $pdf->Cell(18, 6, 'MUNICIPIO', 0, 0, 'L');
         $pdf->SetXY(70, $y + 39);
         $pdf->Cell(18, 6, 'PAIS', 0, 0, 'L');
         $pdf->SetXY(117, $y + 27);
         // BLOQUE DATOS 3
         $pdf->Cell(16, 14, '', 0, 0, 'C', 1);
         $pdf->SetXY(117, $y + 27);
         $pdf->Cell(18, 6, 'C.P.', 0, 0, 'L');
         $pdf->SetXY(117, $y + 33);
         $pdf->Cell(18, 6, 'CIUDAD', 0, 0, 'L');
         $pdf->SetFont('Arial', '', 7);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetXY(25, $y + 9);
         // BLOQUE DATOS 1 INFO
         $pdf->Cell(132, 6, strtoupper($data['crfc']), 0, 0, 'L');
         $pdf->SetXY(25, $y + 15);
         $pdf->Cell(132, 6, strtoupper($data['cnombre']), 0, 0, 'L');
         $pdf->SetXY(25, $y + 21);
         $pdf->Cell(132, 6, strtoupper($data['ccalle']), 0, 0, 'L');
         $pdf->SetXY(25, $y + 27);
         $pdf->Cell(44, 6, strtoupper($data['cno_exterior']), 0, 0, 'L');
         $pdf->SetXY(25, $y + 33);
         $pdf->Cell(44, 6, strtoupper($data['ccolonia']), 0, 0, 'L');
         $pdf->SetXY(25, $y + 39);
         $pdf->Cell(44, 6, strtoupper($data['cestado']), 0, 0, 'L');
         $pdf->SetXY(88, $y + 27);
         // BLOQUE DATOS 2 INFO
         $pdf->Cell(28, 6, strtoupper($data['cno_interior']), 0, 0, 'L');
         $pdf->SetXY(88, $y + 33);
         $pdf->Cell(28, 6, strtoupper($data['cmunicipio']), 0, 0, 'L');
         $pdf->SetXY(88, $y + 39);
         $pdf->Cell(28, 6, strtoupper($data['cpais']), 0, 0, 'L');
         $pdf->SetXY(133, $y + 27);
         // BLOQUE DATOS 3 INFO
         $pdf->Cell(24, 6, strtoupper($data['ccp']), 0, 0, 'L');
         $pdf->SetXY(133, $y + 33);
         $pdf->Cell(24, 6, strtoupper($data['cmunicipio']), 0, 0, 'L');
         // ----------- TABLA CON LOS PRODUCTOS ------------------
         $pdf->SetY($y + 50);
         $aligns = array('C', 'C', 'C', 'C');
         $widths = array(25, 109, 33, 33);
         $header = array('CANTIDAD', 'DESCRIPCION', 'PRECIO UNIT.', 'IMPORTE');
         foreach ($data['productos'] as $key => $item) {
             $band_head = false;
             if ($pdf->GetY() >= 200 || $key == 0) {
                 //salta de pagina si exede el max
                 if ($key > 0) {
                     $pdf->AddPage();
                 }
                 $pdf->SetFont('Arial', 'B', 8);
                 $pdf->SetTextColor(255, 255, 255);
                 $pdf->SetFillColor(140, 140, 140);
                 $pdf->SetX(8);
                 $pdf->SetAligns($aligns);
                 $pdf->SetWidths($widths);
                 $pdf->Row($header, true);
             }
             $pdf->SetFont('Arial', '', 10);
             $pdf->SetTextColor(0, 0, 0);
             $datos = array($item['cantidad'], $item['descripcion'], String::formatoNumero($item['precio_unit']), String::formatoNumero($item['importe']));
             $pdf->SetX(8);
             $pdf->SetAligns($aligns);
             $pdf->SetWidths($widths);
             $pdf->Row($datos, false);
         }
         //------------ SUBTOTAL, IVA ,TOTAL --------------------
         $y = $pdf->GetY();
         $pdf->SetFont('Arial', 'B', 10);
         $pdf->SetTextColor(255, 255, 255);
         $pdf->SetFillColor(140, 140, 140);
         $pdf->SetXY(144, $y + 5);
         $pdf->Cell(31, 6, 'Subtotal', 1, 0, 'C', 1);
         $pdf->SetXY(144, $y + 11);
         $pdf->Cell(31, 6, 'IVA', 1, 0, 'C', 1);
         $pdf->SetXY(144, $y + 17);
         if (isset($data['total_isr'])) {
             $pdf->Cell(31, 6, 'Retencion ISR', 1, 0, 'C', 1);
             $pdf->SetXY(144, $y + 23);
         }
         $pdf->Cell(31, 6, 'Total', 1, 0, 'C', 1);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFillColor(255, 255, 255);
         $pdf->SetXY(175, $y + 5);
         $pdf->Cell(33, 6, String::formatoNumero($data['subtotal'], 2), 1, 0, 'C');
         $pdf->SetXY(175, $y + 11);
         $pdf->Cell(33, 6, String::formatoNumero($data['importe_iva'], 2), 1, 0, 'C');
         $pdf->SetXY(175, $y + 17);
         if (isset($data['total_isr'])) {
             $pdf->Cell(33, 6, isset($data['total_isr']) ? String::formatoNumero($data['total_isr'], 2) : '$0.00', 1, 0, 'C');
             $pdf->SetXY(175, $y + 23);
         }
         $pdf->Cell(33, 6, String::formatoNumero($data['total'], 2), 1, 0, 'C');
         //------------ TOTAL CON LETRA--------------------
         $pdf->SetXY(8, $y + 5);
         $pdf->Cell(134, 24, '', 1, 0, 'C');
         $pdf->SetFont('Arial', 'B', 10);
         $pdf->SetTextColor(255, 255, 255);
         $pdf->SetFillColor(140, 140, 140);
         $pdf->SetXY(8, $y + 5);
         $pdf->Cell(134, 6, '	IMPORTE CON LETRA', 0, 0, 'L', 1);
         $pdf->SetFont('Arial', '', 8);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetXY(9, $y + 12);
         $pdf->MultiCell(130, 6, $data['total_letra'], 0, 'L');
         $pdf->SetXY(9, $y + 24);
         $pdf->Cell(130, 6, "Método de Pago: {$data['metodo_pago']}" . ($data['metodo_pago'] == 'efectivo' ? '' : " | No. Cuenta: {$data['no_cuenta_pago']}"), 0, 0, 'L', 0);
         //------------ CADENA ORIGINAL --------------------
         $y += 32;
         $pdf->SetY($y);
         $pdf->SetX(8);
         $pdf->SetFont('Arial', '', 9);
         $pdf->Image($data['img_cbb'], 8, $y, 40);
         $pdf->SetX(58);
         // $pdf->SetFont('Arial','B',10);
         // $pdf->SetTextColor(255,255,255);
         // $pdf->SetFillColor(140,140,140);
         $pdf->SetAligns(array('L'));
         $pdf->SetWidths(array(150));
         $pdf->Row(array($data['leyenda1']), false, false);
         $pdf->SetX(58);
         // $pdf->SetFont('Arial','',9);
         // $pdf->SetTextColor(0,0,0);
         // $pdf->SetFillColor(255,255,255);
         $pdf->SetAligns(array('L'));
         $pdf->SetWidths(array(150));
         $pdf->Row(array($data['leyenda2'] . ' ' . substr($data['fecha'], 0, 10)), false, false);
         $pdf->SetX(58);
         $pdf->Row(array("No. SICOFI " . $data['no_aprobacion']), false, false);
         //------------ SELLO DIGITAL --------------------
         // $y = $pdf->GetY();
         // $pdf->SetY($y+3);
         // $pdf->SetX(8);
         // $pdf->SetFont('Arial','B',10);
         // $pdf->SetTextColor(255,255,255);
         // $pdf->SetFillColor(140,140,140);
         // $pdf->SetAligns(array('L'));
         // $pdf->SetWidths(array(200));
         // $pdf->Row(array('SELLO DIGITAL'), true);
         // $pdf->SetX(8);
         // $pdf->SetFont('Arial','',9);
         // $pdf->SetTextColor(0,0,0);
         // $pdf->SetFillColor(255,255,255);
         // $pdf->SetAligns(array('L'));
         // $pdf->SetWidths(array(200));
         // $pdf->Row(array($data['sello']), false);
         if ($data['fobservaciones'] != '') {
             $y = $pdf->GetY();
             $pdf->SetY($y + 3);
             $pdf->SetX(8);
             $pdf->SetFont('Arial', 'B', 10);
             $pdf->SetTextColor(255, 255, 255);
             $pdf->SetFillColor(140, 140, 140);
             $pdf->SetAligns(array('L'));
             $pdf->SetWidths(array(200));
             $pdf->Row(array('OBSERVACIONES'), true);
             $pdf->SetX(8);
             $pdf->SetFont('Arial', '', 9);
             $pdf->SetTextColor(0, 0, 0);
             $pdf->SetFillColor(255, 255, 255);
             $pdf->SetAligns(array('L'));
             $pdf->SetWidths(array(200));
             $pdf->Row(array($data['fobservaciones']), false);
         }
         // $y = $pdf->GetY();
         // $pdf->SetFont('Arial','',8);
         // $pdf->SetXY(8, $y+2);
         // $pdf->Cell(200,5,'ESTE DOCUMENTO ES UNA IMPRESIÓN DE UN COMPROBANTE FISCAL DIGITAL',0,0,'C');
         //------------ IMAGEN CANDELADO --------------------
         if (isset($data['status'])) {
             if ($data['status'] == 'ca') {
                 $pdf->Image(APPPATH . '/images/cancelado.png', 20, 40, 190, 190, "PNG");
             }
         }
         //-----------------------------------------------------------------------------------
         if (!$update) {
             $dir_anio = $this->validaDir('anio', 'facturasPDF/');
             $dir_mes = $this->validaDir('mes', 'facturasPDF/' . $dir_anio . '/');
         } else {
             $fecha = $this->obtenFechaMes($data['fecha_xml']);
             $dir_anio = $fecha[0];
             $dir_mes = $this->mesToString($fecha[1]);
         }
         if (count($accion) > 0) {
             foreach ($accion as $a) {
                 switch (strtolower($a)) {
                     case 's':
                         // VISUALIZA PDF EN WEB
                         return $pdf->Output($dir_anio . '|' . $dir_mes . '|' . $this->rfc . '-' . $data['serie'] . '-' . $this->acomodarFolio($data['folio']) . '.pdf', 'S');
                         break;
                     case 'f':
                         // GUARDA EN DIRECTORIO facturasPDF
                         $path_guardar = APPPATH . 'media/cfd/facturasPDF/' . $dir_anio . '/' . $dir_mes . '/' . $this->rfc . '-' . $data['serie'] . '-' . $this->acomodarFolio($data['folio']) . '.pdf';
                         $pdf->Output($path_guardar, 'F');
                         break;
                     case 'd':
                         // DESCARGA DIRECTA DEL PDF
                         $pdf->Output($dir_anio . '|' . $dir_mes . '|' . $this->rfc . '-' . $data['serie'] . '-' . $this->acomodarFolio($data['folio']) . '.pdf', 'D');
                         break;
                     default:
                         // VISUALIZA PDF EN WEB
                         $pdf->Output($dir_anio . '|' . $dir_mes . '|' . $this->rfc . '-' . $data['serie'] . '-' . $this->acomodarFolio($data['folio']) . '.pdf', 'I');
                 }
             }
         }
     }
 }
 /**
  * Contruye el PDF Certificado TLC.
  *
  * @param  string $idFactura
  * @param  string $idDocumento
  * @return void
  */
 public function pdfManifiestoDelCamion($idFactura, $idDocumento)
 {
     $jsonData = $this->getJsonDataDocus($idFactura, $idDocumento);
     $this->load->library('mypdf');
     // Creación del objeto de la clase heredada
     $pdf = new MYpdf('P', 'mm', 'Letter');
     $pdf->show_head = false;
     $pdf->AliasNbPages();
     $pdf->AddPage();
     // $pdf->SetFont('helvetica','', 8);
     $pdf->SetXY(60, 3);
     $pdf->Image(APPPATH . 'images/logo_mayer_martinez.jpg');
     // LADO IZQUIERDO
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetFont('Arial', 'B', 7);
     $pdf->SetXY(10, 22);
     $pdf->Cell(100, 4, "Remitente: " . strtoupper($jsonData->remitente), 0, 0, 'L');
     $pdf->SetXY(10, $pdf->GetY() + 4);
     $pdf->MultiCell(100, 4, "Consignatorio: " . strtoupper($jsonData->consignatorio), 0, 'L', 0);
     $fecha = explode('-', $jsonData->fecha_embarque);
     $pdf->SetXY(10, $pdf->GetY());
     $pdf->Cell(100, 4, "Fecha de Embarque: " . $fecha[2] . ' DE ' . strtoupper(String::mes($fecha[1])) . ' DEL ' . $fecha[0], 0, 0, 'L');
     // -------------------------
     $pdf->SetXY(110, $pdf->GetY() - 8);
     $pdf->Cell(100, 4, "Camion Placas No: " . $jsonData->camion_placas, 0, 0, 'L');
     $pdf->SetXY(110, $pdf->GetY() + 4);
     $pdf->Cell(100, 4, "Caja No: " . $jsonData->caja_no, 0, 0, 'L');
     $pdf->SetXY(110, $pdf->GetY() + 4);
     $pdf->Cell(100, 4, "Linea de Transporte: " . $jsonData->linea_transporte, 0, 0, 'L');
     // ------------------------
     $pdf->SetFillColor(184, 78, 78);
     $pdf->SetTextColor(255, 255, 255);
     $pdf->SetFont('Arial', 'B', 9);
     $pdf->SetXY(10, 35);
     $pdf->Cell(95, 4, "TOMATES", 1, 0, 'C', 1);
     $pdf->SetXY(10, $pdf->GetY() + 4);
     $pdf->SetFont('Arial', '', 7);
     $pdf->SetAligns(array('C', 'C', 'C', 'C'));
     $pdf->SetWidths(array(40, 20, 20, 15));
     $pdf->SetFillColor(255, 255, 255);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->Row(array('', 'Flats', '3 Tandas', 'Cartons'), true);
     $tomates = array('Max/Large 44A', 'Ex. Lg./45A', 'Ex. Large 55A', 'Large/Ex. Lg. 56A', '', 'Madium/Large', 'Medium/Small', 'Sm./Ex. Sm.', 'Ex./Sm.', 'Tomatillo', 'TOTAL:');
     $pdf->SetAligns(array('L'));
     $pdf->SetFont('Arial', '', 7);
     foreach ($tomates as $t) {
         $pdf->SetX(10);
         $pdf->Row(array($t, '', '', ''), false);
     }
     $pdf->SetX(10);
     $pdf->Cell(95, 6, "TOMATE CHERRY                         TOMATE ROMA", 1, 0, 'C', 1);
     $pdf->SetXY(10, $pdf->GetY() + 6);
     $pdf->SetFillColor(184, 78, 78);
     $pdf->SetTextColor(255, 255, 255);
     $pdf->SetFont('Arial', 'B', 9);
     $pdf->Cell(95, 4, "PEPINOS", 1, 0, 'C', 1);
     $pdf->SetXY(10, $pdf->GetY() + 4);
     $pdf->SetFillColor(255, 255, 255);
     $pdf->SetTextColor(0, 0, 0);
     $pepinos = array(array('Super select', 'Total jabas'), array('Super', 'Select'), array('Large', 'Sups/small'), array('Cartons 24s', '30s'));
     $pdf->SetAligns(array('L', 'L'));
     $pdf->SetWidths(array(48, 47));
     $pdf->SetFont('Arial', '', 7);
     foreach ($pepinos as $p) {
         $pdf->SetX(10);
         $pdf->Row(array($p[0], $p[1]), false);
     }
     $pdf->SetXY(10, $pdf->GetY());
     $pdf->SetFillColor(184, 78, 78);
     $pdf->SetTextColor(255, 255, 255);
     $pdf->SetFont('Arial', 'B', 9);
     $pdf->Cell(95, 4, "BERENJENA", 1, 0, 'C', 1);
     $pdf->SetFont('Arial', '', 7);
     $pdf->SetFillColor(255, 255, 255);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetXY(10, $pdf->GetY() + 4);
     $pdf->Cell(35, 6, "16s", 1, 0, 'L', 1);
     $pdf->SetX(45);
     $pdf->Cell(35, 6, "24s", 1, 0, 'L', 1);
     $pdf->SetXY(10, $pdf->GetY() + 6);
     $pdf->Cell(35, 6, "18s", 1, 0, 'L', 1);
     $pdf->SetX(45);
     $pdf->Cell(35, 6, "32s", 1, 0, 'L', 1);
     $pdf->SetXY(80, $pdf->GetY() - 6);
     $pdf->Cell(25, 12, "Jabas", 1, 0, 'C', 1);
     $pdf->SetXY(10, $pdf->GetY() + 12);
     $pdf->SetFillColor(184, 78, 78);
     $pdf->SetTextColor(255, 255, 255);
     $pdf->SetFont('Arial', 'B', 9);
     $pdf->Cell(95, 4, "MELON", 1, 0, 'C', 1);
     $pdf->SetFillColor(255, 255, 255);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetXY(10, $pdf->GetY() + 4);
     $pdf->Cell(60, 6, "Cantaloupe", 1, 0, 'L', 1);
     $pdf->SetX(70);
     $pdf->Cell(35, 6, "Honey Dew", 1, 0, 'L', 1);
     $melones = array(array('18s', '9s', '8s'), array('23s', '12s', '9s'), array('27s', '15s', '10s'), array('36s', '18s', ''), array('45s', '23s', '8s'), array('56s', '30s', '9s'), array('64s', '36s', '10s'), array('72s', '42s', ''), array('JABAS', 'CTNS.', 'TOTAL'));
     $pdf->SetAligns(array('L', 'L', 'L'));
     $pdf->SetWidths(array(32, 28, 35));
     $pdf->SetFont('Arial', '', 7);
     $pdf->SetY($pdf->GetY() + 6);
     foreach ($melones as $m) {
         $pdf->SetX(10);
         $pdf->Row(array($m[0], $m[1], $m[2]), false);
     }
     // LADO DERECHO
     $pdf->SetXY(110, 35);
     $pdf->SetFillColor(184, 78, 78);
     $pdf->SetTextColor(255, 255, 255);
     $pdf->SetFont('Arial', 'B', 9);
     $pdf->Cell(95, 4, "CHILES", 1, 0, 'C', 1);
     $pdf->SetFont('Arial', '', 7);
     $pdf->SetFillColor(255, 255, 255);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetXY(110, $pdf->GetY() + 4);
     $pdf->Cell(60, 6, "Bells", 1, 0, 'L', 1);
     $pdf->SetXY(110, $pdf->GetY() + 6);
     $pdf->Cell(60, 6, "X-Large", 1, 0, 'L', 1);
     $pdf->SetXY(110, $pdf->GetY() + 6);
     $pdf->Cell(60, 6, "Large", 1, 0, 'L', 1);
     $pdf->SetXY(110, $pdf->GetY() + 6);
     $pdf->Cell(60, 6, "Md.", 1, 0, 'L', 1);
     $pdf->SetXY(110, $pdf->GetY() + 6);
     $pdf->Cell(60, 6, "Sm.", 1, 0, 'L', 1);
     $pdf->SetXY(170, $pdf->GetY() - 24);
     $pdf->Cell(35, 30, "TOTAL JABAS", 1, 0, 'C', 1);
     $pdf->SetXY(110, $pdf->GetY() + 30);
     $pdf->Cell(95, 6, "TOTAL:", 1, 0, 'L', 1);
     $pdf->SetXY(110, $pdf->GetY() + 6);
     $pdf->Cell(95, 6, "Anaheim", 1, 0, 'L', 1);
     $pdf->SetXY(110, $pdf->GetY() + 6);
     $pdf->Cell(95, 6, "Caribe", 1, 0, 'L', 1);
     $pdf->SetXY(110, $pdf->GetY() + 6);
     $pdf->Cell(95, 6, "Fresno", 1, 0, 'L', 1);
     $pdf->SetXY(110, $pdf->GetY() + 6);
     $pdf->Cell(95, 6, "Jalapeño", 1, 0, 'L', 1);
     $pdf->SetXY(110, $pdf->GetY() + 6);
     $pdf->Cell(95, 6, "Pimiento", 1, 0, 'L', 1);
     $pdf->SetXY(110, $pdf->GetY() + 6);
     $pdf->SetAligns(array('C', 'C', 'C', 'C'));
     $pdf->SetWidths(array(25, 25, 25, 20));
     $pdf->Row(array('', 'Jabas', 'Cajas', 'Canastos'), false);
     $pdf->SetX(110);
     $pdf->Row(array('Ejote K/L', '', '', ''), false);
     $pdf->SetX(110);
     $pdf->Row(array('Ejote Val.', '', '', ''), false);
     $pdf->SetX(110);
     $pdf->Row(array('Ejote Bush', '', '', ''), false);
     $pdf->SetXY(110, $pdf->GetY());
     $pdf->SetFillColor(184, 78, 78);
     $pdf->SetTextColor(255, 255, 255);
     $pdf->SetFont('Arial', 'B', 9);
     $pdf->Cell(95, 4, "CALABAZAS", 1, 0, 'C', 1);
     $pdf->SetFont('Arial', '', 7);
     $pdf->SetFillColor(255, 255, 255);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetXY(110, $pdf->GetY() + 4);
     $pdf->SetAligns(array('C', 'C', 'C', 'C'));
     $pdf->SetWidths(array(25, 15, 15, 15));
     $pdf->Row(array('', 'X-Fancy', 'Fancy', 'Large'), false);
     $pdf->SetX(110);
     $pdf->Row(array('Italiana', '', '', ''), false);
     $pdf->SetX(110);
     $pdf->Row(array('Summer', '', '', ''), false);
     $pdf->SetX(110);
     $pdf->Row(array('Amarilla', '', '', ''), false);
     $pdf->SetX(110);
     $pdf->Row(array('Calabaza China', '', '', ''), false);
     $pdf->SetXY(180, $pdf->GetY() - 27);
     $pdf->Cell(25, 27, "TOTAL CAJAS", 1, 0, 'C', 1);
     // Obtenemos las clasificaciones de los pallets que se seleccionaron
     // para el cliente.
     $idEmbarque = $this->db->select('id_embarque')->from('facturacion_doc_embarque')->where('id_documento', 2)->where('id_factura', $idFactura)->get()->row()->id_embarque;
     $clasificaciones = $this->getEmbarqueClasifi($idEmbarque);
     $pdf->SetXY(110, $pdf->GetY() + 27);
     $pdf->SetFillColor(184, 78, 78);
     $pdf->SetTextColor(255, 255, 255);
     $pdf->SetFont('Arial', 'B', 9);
     $pdf->Cell(95, 4, "LIMONES", 1, 0, 'C', 1);
     $pdf->SetFont('Arial', '', 7);
     $pdf->SetFillColor(255, 255, 255);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetXY(110, $pdf->GetY() + 4);
     $pdf->SetAligns(array('C', 'C', 'C'));
     $pdf->SetWidths(array(32, 32, 31));
     $pdf->Row(array('', 'Cajas', ''), false);
     foreach ($clasificaciones['clasificaciones'] as $clas) {
         $pdf->SetX(110);
         $pdf->Row(array($clas->clasificacion, $clas->cajas, ''), false);
     }
     $pdf->SetXY(110, $pdf->GetY());
     $pdf->SetFillColor(184, 78, 78);
     $pdf->SetTextColor(255, 255, 255);
     $pdf->SetFont('Arial', 'B', 9);
     $pdf->Cell(95, 4, "UVAS", 1, 0, 'C', 1);
     $pdf->SetFont('Arial', '', 7);
     $pdf->SetFillColor(255, 255, 255);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetXY(110, $pdf->GetY() + 4);
     $pdf->SetAligns(array('C', 'C'));
     $pdf->SetWidths(array(40, 55));
     $pdf->Row(array('', 'Cajas'), false);
     $pdf->SetX(110);
     $pdf->Row(array('Perlette', ''), false);
     $pdf->SetX(110);
     $pdf->Row(array('Flame', ''), false);
     $pdf->SetX(110);
     $pdf->Row(array('Cardinal', ''), false);
     $pdf->SetX(110);
     $pdf->Row(array('Thompson', ''), false);
     $pdf->SetFont('Arial', 'B', 10);
     $pdf->SetXY(10, 215);
     $pdf->Cell(95, 4, "Datos Adicionales al Transportista", 0, 0, 'C', 1);
     $pdf->SetFont('Arial', '', 10);
     $pdf->SetXY(10, $pdf->GetY() + 4);
     $pdf->Cell(95, 4, "Nombre o Razon Social: " . $jsonData->linea_transporte, 0, 0, 'L', 1);
     $pdf->SetXY(10, $pdf->GetY() + 4);
     $pdf->MultiCell(95, 4, "Domicilio Fiscal: " . $jsonData->domicilio_fiscal, 0, 'L', 0);
     $pdf->SetXY(10, $pdf->GetY());
     $pdf->Cell(95, 4, "RFC: " . $jsonData->rfc, 0, 0, 'L', 1);
     $pdf->SetXY(10, $pdf->GetY() + 4);
     $pdf->Cell(95, 4, "CURP: " . $jsonData->curp, 0, 0, 'L', 1);
     $pdf->SetXY(115, 216);
     $pdf->Image(APPPATH . 'images/logo_mayer_martinez_pie.jpg');
     return array('pdf' => $pdf, 'texto' => 'MANIFIESTO DEL CAMION.pdf');
 }
 public function pdf_hva($data)
 {
     if ($_GET['dfecha1'] != '' && $_GET['dfecha2'] != '') {
         $labelFechas = "Desde la fecha " . $_GET['dfecha1'] . " hasta " . $_GET['dfecha2'];
     } elseif ($_GET['dfecha1'] != "") {
         $labelFechas = "Desde la fecha " . $_GET['dfecha1'];
     } elseif ($_GET['dfecha2'] != '') {
         $labelFechas = "Hasta la fecha " . $_GET['dfecha2'];
     }
     $this->load->library('mypdf');
     // Creación del objeto de la clase heredada
     $pdf = new MYpdf('P', 'mm', 'Letter');
     $pdf->show_head = true;
     $pdf->titulo2 = 'Reporte Horas de vuelo por avión';
     $pdf->titulo3 = "\n" . $labelFechas;
     $pdf->AliasNbPages();
     $pdf->AddPage();
     $links = array('', '');
     $aligns = array('C', 'C');
     $widths = array(155, 50);
     $header = array('Avión', 'Horas');
     $thoras = '00:00:00';
     foreach ($data['data'] as $key => $item) {
         if ($pdf->GetY() >= $pdf->limiteY || $key == 0) {
             //salta de pagina si exede el max
             if ($key > 0) {
                 $pdf->AddPage();
             }
             $pdf->SetFont('Arial', 'B', 8);
             $pdf->SetTextColor(255, 255, 255);
             $pdf->SetFillColor(160, 160, 160);
             $pdf->SetX(6);
             $pdf->SetAligns($aligns);
             $pdf->SetWidths($widths);
             $pdf->Row($header, true);
         }
         $datarow = array($item->matricula, $item->horas . ' hrs');
         $thoras = String::suma_horas_minutos_seg($thoras, $item->horas);
         $pdf->SetFont('Arial', '', 8);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFillColor(255, 255, 255);
         $pdf->SetX(6);
         $pdf->SetAligns($aligns);
         $pdf->SetWidths($widths);
         // $pdf->SetMyLinks($links);
         $pdf->Row($datarow, false);
     }
     if (COUNT($data['data']) > 0) {
         $y = $pdf->GetY();
         $pdf->SetFont('Arial', 'B', 10);
         $pdf->SetTextColor(255, 255, 255);
         $pdf->SetFillColor(140, 140, 140);
         $pdf->SetXY(130, $y + 5);
         $pdf->Cell(31, 6, 'Total Horas', 1, 0, 'C', 1);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFillColor(255, 255, 255);
         $pdf->SetXY(161, $y + 5);
         $pdf->Cell(50, 6, $thoras . ' Hrs', 1, 0, 'C');
     }
     $pdf->Output('reporte_horas_vuelo_avion.pdf', 'I');
 }
 public function generaFacturaPdf($idFactura, $path = null)
 {
     include APPPATH . 'libraries/phpqrcode/qrlib.php';
     $factura = $this->getDataFactura($idFactura);
     $xml = simplexml_load_string(str_replace(array('cfdi:', 'tfd:'), '', $factura['xml']));
     // echo "<pre>";
     //   var_dump($factura, $xml);
     // echo "</pre>";exit;
     $this->load->library('mypdf');
     // Creación del objeto de la clase heredada
     $pdf = new MYpdf('P', 'mm', 'Letter');
     $pdf->show_head = false;
     $pdf->AliasNbPages();
     $pdf->AddPage();
     //////////
     // Logo //
     //////////
     $pdf->SetXY(0, 0);
     // $pdf->SetXY(30, 2);
     $logo = file_exists($factura['logo']) ? $factura['logo'] : 'application/images/logos/logodefault.jpg';
     $pdf->Image($logo, 10, null, 0, 21);
     //////////////////////////
     // Rfc y Regimen Fiscal //
     //////////////////////////
     // 0, 171, 72 = verde
     $pdf->SetFont('helvetica', 'B', 9);
     // $pdf->SetFillColor(214, 214, 214);
     $pdf->SetTextColor(255, 255, 255);
     // $pdf->SetXY(0, 0);
     // $pdf->Cell(108, 15, "Factura Electrónica (CFDI)", 0, 0, 'C', 1);
     // $pdf->SetTextColor(0, 0, 0);
     // $pdf->SetXY(0, $pdf->GetY());
     // $pdf->Cell(108, 4, "RFC: {$xml->Emisor[0]['rfc']}", 0, 0, 'C', 0);
     // $pdf->SetFont('helvetica','B', 12);
     $pdf->SetFillColor(219, 219, 219);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetXY(0, $pdf->GetY() + 4);
     $pdf->Cell(108, 4, "Emisor:", 0, 0, 'L', 1);
     $pdf->SetFont('helvetica', '', 8);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetXY(0, $pdf->GetY() + 4);
     $pdf->SetX(0);
     $pdf->SetAligns(array('L', 'L'));
     $pdf->SetWidths(array(19, 93));
     $pdf->Row(array('RFC:', $xml->Emisor[0]['rfc']), false, false, null, 2, 1);
     $pdf->SetWidths(array(19, 196));
     $pdf->SetX(0);
     $pdf->Row(array('NOMBRE:', $xml->Emisor[0]['nombre']), false, false, null, 2, 1);
     $pdf->SetX(0);
     $pdf->Row(array('DOMICILIO:', $xml->Emisor->DomicilioFiscal[0]['calle'] . ' No. ' . $xml->Emisor->DomicilioFiscal[0]['noExterior'] . (isset($xml->Emisor->DomicilioFiscal[0]['noInterior']) ? ' Int. ' . $xml->Emisor->DomicilioFiscal[0]['noInterior'] : '')), false, false, null, 2, 1);
     $pdf->SetWidths(array(19, 83, 19, 83));
     $pdf->SetX(0);
     $pdf->Row(array('COLONIA:', $xml->Emisor->DomicilioFiscal[0]['colonia'], 'LOCALIDAD:', $xml->Emisor->DomicilioFiscal[0]['localidad']), false, false, null, 2, 1);
     $pdf->SetWidths(array(19, 65, 11, 65, 11, 40));
     $pdf->SetX(0);
     $pdf->Row(array('ESTADO:', $xml->Emisor->DomicilioFiscal[0]['estado'], 'PAIS:', $xml->Emisor->DomicilioFiscal[0]['pais'], 'CP:', $xml->Emisor->DomicilioFiscal[0]['codigoPostal']), false, false, null, 2, 1);
     $end_y = $pdf->GetY();
     /////////////////////////////////////
     // Folio Fisca, CSD, Lugar y Fecha //
     /////////////////////////////////////
     $pdf->SetFont('helvetica', 'B', 9);
     $pdf->SetFillColor(219, 219, 219);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetXY(109, 0);
     $pdf->Cell(108, 4, "Folio Fiscal:", 0, 0, 'R', 1);
     $pdf->SetXY(109, 0);
     $pdf->Cell(50, 4, (!isset($factura['id_nc']) ? 'Factura' : 'Nota de Crédito') . ': ' . ($factura['serie'] . $factura['folio']), 0, 0, 'L', 1);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetXY(109, 6);
     $pdf->Cell(108, 4, $xml->Complemento->TimbreFiscalDigital[0]['UUID'], 0, 0, 'C', 0);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetXY(109, $pdf->GetY() + 4);
     $pdf->Cell(108, 4, "No de Serie del Certificado del CSD:", 0, 0, 'R', 1);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetXY(109, $pdf->GetY() + 4);
     $pdf->Cell(108, 4, $xml->Complemento->TimbreFiscalDigital[0]['noCertificadoSAT'], 0, 0, 'C', 0);
     $pdf->SetFillColor(219, 219, 219);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetXY(109, $pdf->GetY() + 4);
     $pdf->Cell(108, 4, "Lugar. fecha y hora de emisión:", 0, 0, 'R', 1);
     $pdf->SetFont('helvetica', '', 9);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetXY(109, $pdf->GetY() + 4);
     $pais = strtoupper($xml->Emisor->DomicilioFiscal[0]['pais']);
     $estado = strtoupper($xml->Emisor->DomicilioFiscal[0]['estado']);
     $fecha = $xml[0]['fecha'];
     $pdf->Cell(108, 4, "{$pais} {$estado} {$fecha}", 0, 0, 'R', 0);
     $pdf->SetFont('helvetica', 'b', 9);
     $pdf->SetFillColor(219, 219, 219);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetXY(109, $pdf->GetY() + 4);
     $pdf->Cell(108, 4, "Régimen Fiscal:", 0, 0, 'R', 1);
     $pdf->SetFont('helvetica', '', 9);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetXY(109, $pdf->GetY() + 4);
     $pdf->MultiCell(108, 4, $xml->Emisor->RegimenFiscal[0]['Regimen'], 0, 'C', 0);
     //////////////////
     // domicilioEmisor //
     //////////////////
     // $domicilioEmisor = '';
     // $domicilioEmisor .= (isset($xml->Emisor->DomicilioFiscal[0]['calle'])) ? $xml->Emisor->DomicilioFiscal[0]['calle'] : '';
     // $domicilioEmisor .= (isset($xml->Emisor->DomicilioFiscal[0]['noExterior'])) ? ' #'.$xml->Emisor->DomicilioFiscal[0]['noExterior'] : '';
     // $domicilioEmisor .= (isset($xml->Emisor->DomicilioFiscal[0]['noInterior'])) ? ' Int. '.$xml->Emisor->DomicilioFiscal[0]['noInterior'] : '';
     // $domicilioEmisor .= (isset($xml->Emisor->DomicilioFiscal[0]['colonia'])) ? ', '.$xml->Emisor->DomicilioFiscal[0]['colonia'] : '';
     // $domicilioEmisor .= (isset($xml->Emisor->DomicilioFiscal[0]['localidad'])) ? ', '.$xml->Emisor->DomicilioFiscal[0]['localidad'] : '';
     // $domicilioEmisor .= (isset($xml->Emisor->DomicilioFiscal[0]['municipio'])) ? ', '.$xml->Emisor->DomicilioFiscal[0]['municipio'] : '';
     // $domicilioEmisor .= (isset($xml->Emisor->DomicilioFiscal[0]['estado'])) ? ', '.$xml->Emisor->DomicilioFiscal[0]['estado'] : '';
     // $pdf->SetFont('helvetica','B', 9);
     // $pdf->SetFillColor(140,140, 140);
     // $pdf->SetTextColor(255,255,255);
     // $pdf->SetXY(0, $pdf->GetY() + 4);
     // $pdf->Cell(216, 4, "Domicilio:", 0, 0, 'L', 1);
     // $pdf->SetFont('helvetica','', 9);
     // $pdf->SetTextColor(0, 0, 0);
     // $pdf->SetXY(0, $pdf->GetY() + 4);
     // $pdf->Cell(216, 4, $domicilioEmisor, 0, 0, 'C', 0);
     //////////////////
     // Datos Receptor //
     //////////////////
     $pdf->setY($end_y);
     $domicilioReceptor = '';
     $domicilioReceptor .= isset($xml->Receptor->Domicilio[0]['calle']) ? $xml->Receptor->Domicilio[0]['calle'] : '';
     $domicilioReceptor .= isset($xml->Receptor->Domicilio[0]['noExterior']) ? ' #' . $xml->Receptor->Domicilio[0]['noExterior'] : '';
     $domicilioReceptor .= isset($xml->Receptor->Domicilio[0]['noInterior']) ? ' Int. ' . $xml->Receptor->Domicilio[0]['noInterior'] : '';
     $domicilioReceptor .= isset($xml->Receptor->Domicilio[0]['colonia']) ? ', ' . $xml->Receptor->Domicilio[0]['colonia'] : '';
     $domicilioReceptor .= isset($xml->Receptor->Domicilio[0]['localidad']) ? ', ' . $xml->Receptor->Domicilio[0]['localidad'] : '';
     $domicilioReceptor .= isset($xml->Receptor->Domicilio[0]['municipio']) ? ', ' . $xml->Receptor->Domicilio[0]['municipio'] : '';
     $domicilioReceptor .= isset($xml->Receptor->Domicilio[0]['estado']) ? ', ' . $xml->Receptor->Domicilio[0]['estado'] : '';
     $pdf->SetFillColor(214, 214, 214);
     $pdf->SetXY(0, $pdf->GetY() + 4);
     $pdf->Cell(216, 1, "", 0, 0, 'L', 1);
     $pdf->SetFont('helvetica', 'B', 9);
     $pdf->SetFillColor(219, 219, 219);
     $pdf->SetTextColor(255, 255, 255);
     $pdf->SetXY(0, $pdf->GetY() + 1);
     $pdf->Cell(216, 4, "Receptor:", 0, 0, 'L', 1);
     $pdf->SetFont('helvetica', '', 8);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetXY(0, $pdf->GetY() + 4);
     $pdf->SetX(0);
     $pdf->SetAligns(array('L', 'L'));
     $pdf->SetWidths(array(19, 93));
     $pdf->Row(array('RFC:', $xml->Receptor[0]['rfc']), false, false, null, 2, 1);
     $pdf->SetWidths(array(19, 196));
     $pdf->SetX(0);
     $pdf->Row(array('NOMBRE:', $xml->Receptor[0]['nombre']), false, false, null, 2, 1);
     $pdf->SetX(0);
     $pdf->Row(array('DOMICILIO:', (isset($xml->Receptor->Domicilio[0]['calle']) ? $xml->Receptor->Domicilio[0]['calle'] : '') . ' No. ' . (isset($xml->Receptor->Domicilio[0]['noExterior']) ? $xml->Receptor->Domicilio[0]['noExterior'] : '') . (isset($xml->Receptor->Domicilio[0]['noInterior']) ? ' Int. ' . $xml->Receptor->Domicilio[0]['noInterior'] : '')), false, false, null, 2, 1);
     $pdf->SetWidths(array(19, 83, 19, 83));
     $pdf->SetX(0);
     $pdf->Row(array('COLONIA:', isset($xml->Receptor->Domicilio[0]['colonia']) ? $xml->Receptor->Domicilio[0]['colonia'] : '', 'LOCALIDAD:', isset($xml->Receptor->Domicilio[0]['localidad']) ? $xml->Receptor->Domicilio[0]['localidad'] : ''), false, false, null, 2, 1);
     $pdf->SetWidths(array(19, 65, 11, 65, 11, 40));
     $pdf->SetX(0);
     $pdf->Row(array('ESTADO:', isset($xml->Receptor->Domicilio[0]['estado']) ? $xml->Receptor->Domicilio[0]['estado'] : '', 'PAIS:', isset($xml->Receptor->Domicilio[0]['pais']) ? $xml->Receptor->Domicilio[0]['pais'] : '', 'CP:', isset($xml->Receptor->Domicilio[0]['codigoPostal']) ? $xml->Receptor->Domicilio[0]['codigoPostal'] : ''), false, false, null, 2, 1);
     // $pdf->Cell(216, 4, "Nombre: {$xml->Receptor[0]['nombre']} RFC: {$xml->Receptor[0]['rfc']}", 0, 0, 'L', 0);
     // $pdf->SetFont('helvetica','', 9);
     // $pdf->SetTextColor(0, 0, 0);
     // $pdf->SetXY(0, $pdf->GetY() + 4);
     // $pdf->Cell(216, 4, "Domicilio: {$domicilioReceptor}", 0, 0, 'L', 0);
     ///////////////
     // Productos //
     ///////////////
     $pdf->SetFillColor(214, 214, 214);
     $pdf->SetXY(0, $pdf->GetY() + 5);
     $pdf->Cell(216, 1, "", 0, 0, 'L', 1);
     $pdf->SetXY(0, $pdf->GetY());
     $aligns = array('C', 'C', 'C', 'C', 'C');
     $aligns2 = array('C', 'C', 'C', 'R', 'R');
     $widths = array(30, 35, 91, 30, 30);
     $header = array('Cantidad', 'Unidad de Medida', 'Descripcion', 'Precio Unitario', 'Importe');
     $conceptos = current($xml->Conceptos);
     // for ($i=0; $i < 30; $i++)
     //   $conceptos[] = $conceptos[$i];
     // echo "<pre>";
     //   var_dump($conceptos, is_array($conceptos));
     // echo "</pre>";exit;
     if (!is_array($conceptos)) {
         $conceptos = array($conceptos);
     }
     $pdf->limiteY = 250;
     $pdf->setY($pdf->GetY() + 1);
     foreach ($conceptos as $key => $item) {
         $band_head = false;
         if ($pdf->GetY() >= $pdf->limiteY || $key === 0) {
             if ($key > 0) {
                 $pdf->AddPage();
             }
             $pdf->SetFont('Arial', 'B', 8);
             $pdf->SetTextColor(0, 0, 0);
             $pdf->SetFillColor(219, 219, 219);
             $pdf->SetX(0);
             $pdf->SetAligns($aligns);
             $pdf->SetWidths($widths);
             $pdf->Row($header, true, true, null, 2, 1);
         }
         $pdf->SetFont('Arial', '', 8);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetX(0);
         $pdf->SetAligns($aligns2);
         $pdf->SetWidths($widths);
         $pdf->Row(array($item[0]['cantidad'], $item[0]['unidad'], $item[0]['descripcion'], String::formatoNumero($item[0]['valorUnitario'], 2, '$', false), String::formatoNumero($item[0]['importe'], 2, '$', false)), false, true, null, 2, 1);
     }
     /////////////
     // Totales //
     /////////////
     if ($pdf->GetY() + 30 >= $pdf->limiteY) {
         //salta de pagina si exede el max
         $pdf->AddPage();
     }
     // Traslados | IVA
     $ivas = current($xml->Impuestos->Traslados);
     /*if ( ! is_array($ivas))
       {
         $ivas = array($ivas);
       }*/
     $traslado11 = 0;
     $traslado16 = 0;
     foreach ($ivas as $key => $iva) {
         if ($iva[0]['tasa'] == '11') {
             $traslado11 = $iva[0]['importe'];
         } elseif ($iva[0]['tasa'] == '16') {
             $traslado16 = $iva[0]['importe'];
         }
     }
     $pdf->SetFillColor(214, 214, 214);
     $pdf->SetXY(0, $pdf->GetY());
     $pdf->Cell(216, 1, "", 0, 0, 'L', 1);
     $h = 25 - ($traslado11 == 0 ? 5 : 0);
     $h = $h - ($xml->Impuestos->Retenciones->Retencion[0]['importe'] == 0 ? 5 : 0);
     $pdf->SetFillColor(219, 219, 219);
     $pdf->SetXY(0, $pdf->GetY() + 1);
     $pdf->Cell(156, $h, "", 1, 0, 'L', 1);
     $pdf->SetFont('helvetica', 'B', 9);
     $pdf->SetXY(1, $pdf->GetY() + 1);
     $pdf->Cell(154, 4, "Total con letra:", 0, 0, 'L', 1);
     $pdf->SetFont('helvetica', '', 10);
     $pdf->SetXY(0, $pdf->GetY() + 4);
     $pdf->MultiCell(156, 6, $factura['total_letra'], 0, 'C', 0);
     $pdf->SetFont('helvetica', 'B', 9);
     $pdf->SetXY(1, $pdf->GetY());
     $pdf->Cell(78, 4, $xml[0]['formaDePago'], 0, 0, 'L', 1);
     $pdf->SetFont('helvetica', 'B', 9);
     $pdf->SetXY(78, $pdf->GetY());
     $pdf->Cell(78, 4, "Pago en {$xml[0]['metodoDePago']}", 0, 0, 'L', 1);
     $pdf->SetFont('helvetica', 'B', 10);
     $pdf->SetXY(156, $pdf->GetY() - 11);
     $pdf->Cell(30, 5, "Subtotal", 1, 0, 'C', 1);
     $pdf->SetXY(186, $pdf->GetY());
     $pdf->Cell(30, 5, String::formatoNumero($xml[0]['subTotal'], 2, '$', false), 1, 0, 'R', 1);
     // Pinta traslados, retenciones
     if ($traslado11 != 0) {
         $pdf->SetXY(156, $pdf->GetY() + 5);
         $pdf->Cell(30, 5, "IVA(11%)", 1, 0, 'C', 1);
         $pdf->SetXY(186, $pdf->GetY());
         $pdf->Cell(30, 5, String::formatoNumero($traslado11, 2, '$', false), 1, 0, 'R', 1);
     }
     $pdf->SetXY(156, $pdf->GetY() + 5);
     $pdf->Cell(30, 5, "IVA(16%)", 1, 0, 'C', 1);
     $pdf->SetXY(186, $pdf->GetY());
     $pdf->Cell(30, 5, String::formatoNumero($traslado16, 2, '$', false), 1, 0, 'R', 1);
     if ($xml->Impuestos->Retenciones->Retencion[0]['importe'] != 0) {
         $pdf->SetXY(156, $pdf->GetY() + 5);
         $pdf->Cell(30, 5, "IVA Retenido", 1, 0, 'C', 1);
         $pdf->SetXY(186, $pdf->GetY());
         $pdf->Cell(30, 5, String::formatoNumero($xml->Impuestos->Retenciones->Retencion[0]['importe'], 2, '$', false), 1, 0, 'R', 1);
     }
     $pdf->SetXY(156, $pdf->GetY() + 5);
     $pdf->Cell(30, 5, "TOTAL", 1, 0, 'C', 1);
     $pdf->SetXY(186, $pdf->GetY());
     $pdf->Cell(30, 5, String::formatoNumero($xml[0]['total'], 2, '$', false), 1, 0, 'R', 1);
     ///////////////////
     // Observaciones //
     ///////////////////
     $pdf->SetXY(0, $pdf->GetY() + 5);
     $width = $pdf->GetStringWidth($factura['observaciones']) / 216 * 8 + 9;
     if ($pdf->GetY() + $width >= $pdf->limiteY) {
         //salta de pagina si exede el max
         $pdf->AddPage();
     }
     if (!empty($factura['observaciones'])) {
         $pdf->SetX(0);
         $pdf->SetFont('helvetica', 'B', 10);
         $pdf->SetAligns(array('L'));
         $pdf->SetWidths(array(216));
         $pdf->Row(array('Observaciones'), true);
         $pdf->SetFont('helvetica', '', 9);
         $pdf->SetXY(0, $pdf->GetY());
         $pdf->SetAligns(array('L'));
         $pdf->SetWidths(array(216));
         $pdf->Row(array($factura['observaciones']), true, 1);
     }
     ////////////////////
     // Timbrado Datos //
     ////////////////////
     if ($pdf->GetY() + 25 >= $pdf->limiteY) {
         //salta de pagina si exede el max
         $pdf->AddPage();
     }
     $pdf->SetFont('helvetica', 'B', 8);
     $pdf->SetXY(10, $pdf->GetY() + 8);
     $pdf->SetAligns(array('L'));
     $pdf->SetWidths(array(196));
     $pdf->Row(array('Sello Digital del CFDI:'), false, 0);
     $pdf->SetFont('helvetica', '', 8);
     $pdf->SetY($pdf->GetY());
     $pdf->SetAligns(array('L'));
     $pdf->SetWidths(array(196));
     $pdf->Row(array($xml->Complemento->TimbreFiscalDigital[0]['selloCFD']), false, 0);
     if ($pdf->GetY() + 25 >= $pdf->limiteY) {
         //salta de pagina si exede el max
         $pdf->AddPage();
     }
     $pdf->SetFont('helvetica', 'B', 8);
     $pdf->SetXY(10, $pdf->GetY() + 5);
     $pdf->SetAligns(array('L'));
     $pdf->SetWidths(array(196));
     $pdf->Row(array('Sello Digital del SAT:'), false, 0);
     $pdf->SetFont('helvetica', '', 8);
     $pdf->SetY($pdf->GetY());
     $pdf->SetAligns(array('L'));
     $pdf->SetWidths(array(196));
     $pdf->Row(array($xml->Complemento->TimbreFiscalDigital[0]['selloSAT']), false, 0);
     /////////////
     // QR CODE //
     /////////////
     // formato
     // ?re=XAXX010101000&rr=XAXX010101000&tt=1234567890.123456&id=ad662d33-6934-459c-a128-BDf0393f0f44
     // 0000001213.520000
     $total = explode('.', $xml[0]['total']);
     // Obtiene la diferencia de caracteres en la parte entera.
     $diff = 10 - strlen($total[0]);
     // Agrega los 0 faltantes  a la parte entera.
     for ($i = 0; $i < $diff; $i++) {
         $total[0] = "0{$total[0]}";
     }
     // Si el total no contiene decimales le asigna en la parte decimal 6 ceros.
     if (count($total) === 1) {
         $total[1] = '000000';
     } else {
         // Obtiene la diferencia de caracteres en la parte decimal.
         $diff = 6 - strlen($total[1]);
         // Agregar los 0 restantes en la parte decimal.
         for ($i = 0; $i < $diff; $i++) {
             $total[1] = "{$total[1]}0";
         }
     }
     $code = "?re={$xml->Emisor[0]['rfc']}";
     $code .= "&rr={$xml->Receptor[0]['rfc']}";
     $code .= "&tt={$total[0]}.{$total[1]}";
     $code .= "&id={$xml->Complemento->TimbreFiscalDigital[0]['UUID']}";
     // echo "<pre>";
     //   var_dump($code, $total, $diff);
     // echo "</pre>";exit;
     QRcode::png($code, APPPATH . 'media/qrtemp.png', 'H', 3);
     if ($pdf->GetY() + 50 >= $pdf->limiteY) {
         //salta de pagina si exede el max
         $pdf->AddPage();
     }
     $pdf->SetXY(0, $pdf->GetY());
     $pdf->Image(APPPATH . 'media/qrtemp.png', null, null, 40);
     // Elimina el QR generado temporalmente.
     unlink(APPPATH . 'media/qrtemp.png');
     ////////////////////
     // Timbrado Datos //
     ////////////////////
     $pdf->SetFont('helvetica', 'B', 8);
     $pdf->SetXY(45, $pdf->GetY() - 39);
     $pdf->SetAligns(array('L'));
     $pdf->SetWidths(array(160));
     $pdf->Row(array('Cadena Original del complemento de certificación digital del SAT:'), false, 0);
     $pdf->SetFont('helvetica', '', 8);
     $cadenaOriginalSAT = "||{$xml->Complemento->TimbreFiscalDigital[0]['version']}|{$xml->Complemento->TimbreFiscalDigital[0]['UUID']}|{$xml->Complemento->TimbreFiscalDigital[0]['FechaTimbrado']}|{$xml->Complemento->TimbreFiscalDigital[0]['selloCFD']}|{$xml->Complemento->TimbreFiscalDigital[0]['noCertificadoSAT']}||";
     $pdf->SetXY(45, $pdf->GetY());
     $pdf->Row(array($cadenaOriginalSAT), false, 0);
     $pdf->SetFont('helvetica', 'B', 10);
     $pdf->SetFillColor(219, 219, 219);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetXY(45, $pdf->GetY() + 1);
     $pdf->Cell(80, 6, "No de Serie del Certificado del SAT:", 0, 0, 'R', 1);
     $pdf->SetXY(125, $pdf->GetY());
     $pdf->SetTextColor(0, 0, 0);
     $pdf->Cell(65, 6, $xml->Complemento->TimbreFiscalDigital[0]['noCertificadoSAT'], 0, 0, 'C', 0);
     $pdf->SetFont('helvetica', 'B', 10);
     $pdf->SetFillColor(219, 219, 219);
     $pdf->SetTextColor(0, 0, 0);
     $pdf->SetXY(45, $pdf->GetY() + 10);
     $pdf->Cell(80, 6, "Fecha y hora de certificación:", 0, 0, 'R', 1);
     $pdf->SetXY(125, $pdf->GetY());
     $pdf->SetTextColor(0, 0, 0);
     $pdf->Cell(65, 6, $xml->Complemento->TimbreFiscalDigital[0]['FechaTimbrado'], 0, 0, 'C', 0);
     //------------ IMAGEN CANDELADO --------------------
     if ($factura['status'] === 'ca') {
         $pdf->Image(APPPATH . '/images/cancelado.png', 20, 40, 190, 190, "PNG");
     }
     if ($path) {
         $pdf->Output($path . 'Factura.pdf', 'F');
     } else {
         $pdf->Output('Factura', 'I');
     }
 }
 /**
  * Genera el reporte existencias por costo desglosado en pdf
  * @param unknown_type $data
  * @param unknown_type $fecha1
  * @param unknown_type $fecha2
  */
 public function pdfEpcd($data, $fecha1, $fecha2)
 {
     if ($fecha1 != '' && $fecha2 != '') {
         $labelFechas = "Desde la fecha " . $fecha1 . " hasta " . $fecha2;
     } elseif ($fecha1 != "") {
         $labelFechas = "Desde la fecha " . $fecha1;
     } elseif ($fecha2 != '') {
         $labelFechas = "Hasta la fecha " . $fecha2;
     }
     $this->load->library('mypdf');
     // Creación del objeto de la clase heredada
     $pdf = new MYpdf('P', 'mm', 'Letter');
     $pdf->show_head = true;
     $pdf->titulo2 = 'Reporte de existencia por costo';
     $pdf->titulo3 = $labelFechas . "\n";
     $pdf->titulo3 .= $data['nombre'];
     $pdf->AliasNbPages();
     $pdf->AddPage();
     $aligns = array('C', 'C', 'C', 'C');
     $widths1 = array(53, 50, 50, 50);
     $header1 = array('Fecha', 'Entradas', 'Salidas', 'Existencia');
     $totales = array('Totales', 0, 0, 0);
     foreach ($data['historial'] as $key2 => $prod) {
         if ($pdf->GetY() >= $pdf->limiteY || $key2 == 0) {
             //salta de pagina si exede el max
             if ($key2 > 0) {
                 $pdf->AddPage();
             }
             $pdf->SetFont('Arial', 'B', 8);
             $pdf->SetTextColor(255, 255, 255);
             $pdf->SetFillColor(160, 160, 160);
             $pdf->SetX(6);
             $pdf->SetAligns($aligns);
             $pdf->SetWidths($widths1);
             $pdf->Row($header1, true);
         }
         $entrada = $salida = 0;
         if ($prod->tipo == 'salida') {
             $totales[2] += $prod->importe;
             $totales[3] -= $prod->importe;
             //existencias
             $salida = $prod->importe;
         } else {
             $totales[1] += $prod->importe;
             $totales[3] += $prod->importe;
             //existencias
             $entrada = $prod->importe;
         }
         $datarow = array($prod->fecha, String::formatoNumero($entrada), String::formatoNumero($salida), String::formatoNumero($totales[3]));
         $pdf->SetFont('Arial', '', 8);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetX(6);
         $pdf->SetAligns($aligns);
         $pdf->SetWidths($widths1);
         $pdf->Row($datarow, false);
     }
     $totales[1] = String::formatoNumero($totales[1]);
     $totales[2] = String::formatoNumero($totales[2]);
     $totales[3] = String::formatoNumero($totales[3]);
     $pdf->SetFont('Arial', 'B', 8);
     $pdf->SetTextColor(255, 255, 255);
     $pdf->SetFillColor(160, 160, 160);
     $pdf->SetX(6);
     $pdf->SetAligns($aligns);
     $pdf->SetWidths($widths1);
     $pdf->Row($totales, true);
     $pdf->Output('reporte.pdf', 'I');
 }
 public function imprimir()
 {
     $this->load->model('facturacion_model');
     if (isset($_GET['id'][0]) && $this->facturacion_model->exist('facturas', 'id_factura = ' . $_GET['id'])) {
         //factura
         $data = $this->facturacion_model->getInfoFactura($_GET['id']);
         $res = $this->db->select('*')->from('facturas_series_folios')->where("serie = '" . $data['info']->serie . "' AND id_empresa = " . $data['info']->id_empresa)->get();
         $data_serie = $res->row();
         $res->free_result();
         $res = $this->db->select('*')->from('empresas')->where('id_empresa = ' . $data['info']->id_empresa)->get();
         $data_empresa = $res->row();
         $this->load->library('mypdf');
         // Creación del objeto de la clase heredada
         $pdf = new MYpdf('P', 'mm', 'Letter');
         $pdf->show_head = false;
         $pdf->AddPage();
         $pdf->Image(APPPATH . 'images/factura.jpg', 0.5, 0, 215, 279);
         if ($data_empresa->logo != '') {
             $pdf->Image($data_empresa->logo, 11, 12, 40, 0);
         }
         // Logo de la Empresa
         $y = 40;
         $pdf->SetXY(51, 9);
         $pdf->SetFont('Arial', 'B', 12);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->Cell(118, 4, $data_empresa->nombre_fiscal, 0, 0, 'C');
         $pdf->SetXY(51, 13);
         $pdf->SetFont('Arial', 'B', 9);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->Cell(118, 4, 'R.F.C. ' . $data_empresa->rfc, 0, 0, 'C');
         $calle = '';
         if ($data_empresa->calle !== '') {
             $calle = $data_empresa->calle;
         }
         if ($data_empresa->no_interior !== '') {
             $calle .= ' No. ' . $data_empresa->no_interior;
         }
         if ($data_empresa->no_exterior !== '') {
             $calle .= ' No. ' . $data_empresa->no_exterior;
         }
         $colonia = '';
         if ($data_empresa->colonia !== '') {
             $colonia = ' COL. ' . $data_empresa->colonia;
         }
         $colmuni = '';
         if ($data_empresa->cp !== '') {
             $colmuni = ' C.P. ' . $data_empresa->cp;
         }
         if ($data_empresa->municipio !== '') {
             $colmuni .= ' ' . $data_empresa->municipio;
         }
         if ($data_empresa->estado !== '') {
             $colmuni .= ' ' . $data_empresa->estado;
         }
         $pdf->SetXY(51, 17);
         $pdf->SetFont('Arial', '', 9);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->Cell(118, 4, $calle, 0, 0, 'C');
         $pdf->SetXY(51, 21);
         $pdf->SetFont('Arial', '', 9);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->Cell(118, 4, $colonia, 0, 0, 'C');
         $pdf->SetXY(51, 25);
         $pdf->SetFont('Arial', '', 9);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->Cell(118, 4, $colmuni, 0, 0, 'C');
         $pdf->SetXY(51, 29);
         $pdf->SetFont('Arial', 'B', 9);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->Cell(118, 4, 'TEL/FAX: ' . $data_empresa->telefono . ($data_empresa->celular !== '' ? '   CEL:' . $data_empresa->celular : ''), 0, 0, 'C');
         $www = '';
         if ($data_empresa->pag_web !== '') {
             $www = $data_empresa->pag_web;
         }
         if ($data_empresa->email !== '') {
             $www .= '      Email: ' . $data_empresa->email;
         }
         $pdf->SetXY(51, 33);
         $pdf->SetFont('Arial', 'B', 8);
         $pdf->SetTextColor(204, 0, 0);
         $pdf->Cell(118, 4, $www, 0, 0, 'C');
         $pdf->SetXY(170, 15);
         $pdf->SetFont('Arial', '', 12);
         $pdf->SetTextColor(204, 0, 0);
         $pdf->Cell(37, 6, ($data['info']->serie != '' ? $data['info']->serie : '') . $data['info']->folio, 0, 0, 'C');
         $pdf->SetFont('Arial', 'B', 7);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetXY(170, 26);
         $pdf->SetAligns(array('L'));
         $pdf->SetWidths(array(37));
         $pdf->Row(array('EXPEDIDA EN ' . $data_empresa->municipio . ', ' . $data_empresa->estado), false, false);
         $pdf->SetXY(158, 40);
         $pdf->SetFont('Arial', '', 10);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->Cell(48, 6, $data['info']->fecha, 0, 0, 'C');
         $pdf->SetXY(158, 50);
         $pdf->SetFont('Arial', '', 10);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->Cell(48, 6, $data['info']->forma_pago, 0, 0, 'C');
         /*$pdf->SetXY(182, 50);
           $pdf->Cell(25, 6, $data['info']->serie, 0, 0, 'C');*/
         $pdf->SetXY(158, 58);
         $pdf->Cell(48, 6, $data['info']->condicion_pago == 'cr' ? 'CREDITO' : 'CONTADO', 0, 0, 'C');
         $pdf->SetAligns(array('L'));
         $pdf->SetWidths(array(128));
         $pdf->SetXY(28, 36);
         // $pdf->Cell(128, 6, $data['info']->cliente->nombre_fiscal, 0, 0, 'L');
         $pdf->Row(array($data['info']->cliente->nombre_fiscal), false, false);
         $pdf->SetFont('Arial', '', 9);
         $pdf->SetXY(28, 43);
         // $pdf->Cell(128, 6, $data['info']->domicilio, 0, 0, 'L');
         $pdf->Row(array($data['info']->domicilio), false, false);
         $pdf->SetXY(28, 52);
         $pdf->Cell(128, 6, $data['info']->ciudad, 0, 1, 'L');
         $pdf->SetXY(28, 58);
         $pdf->Cell(128, 6, strtoupper($data['info']->cliente->rfc), 0, 1, 'L');
         $pdf->SetY(70);
         $aligns = array('C', 'C', 'L', 'C', 'C');
         $widths = array(14, 18, 113, 24, 27);
         $header = array('', '', '', '', '');
         foreach ($data['productos'] as $key => $item) {
             $band_head = false;
             if ($pdf->GetY() >= 200 || $key == 0) {
                 //salta de pagina si exede el max
                 if ($key > 0) {
                     $pdf->AddPage();
                 }
             }
             $pdf->SetFont('Arial', '', 8);
             $pdf->SetTextColor(0, 0, 0);
             $datos = array($item->cantidad, $item->unidad !== NULL ? $item->unidad : $item->unidad2, $item->descripcion, String::formatoNumero($item->precio_unitario), String::formatoNumero($item->importe));
             $pdf->SetX(11);
             $pdf->SetAligns($aligns);
             $pdf->SetWidths($widths);
             $pdf->Row($datos, false, false);
         }
         $y = 214;
         $pdf->SetFont('Arial', '', 8.5);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFillColor(232, 232, 232);
         $pdf->SetXY(156, $y);
         $pdf->Cell(24, 4, 'SUB-TOTAL', 1, 0, 'L', 1);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFillColor(255, 255, 255);
         $pdf->SetXY(180, $y);
         $pdf->Cell(27, 4, string::formatoNumero($data['info']->subtotal), 1, 0, 'L');
         if (floatval($data['info']->descuento) > 0) {
             $y += 4;
             $pdf->SetFont('Arial', '', 8.5);
             $pdf->SetTextColor(0, 0, 0);
             $pdf->SetFillColor(232, 232, 232);
             $pdf->SetXY(156, 218);
             $pdf->Cell(24, 4, 'DESC.', 1, 0, 'L', 1);
             $pdf->SetTextColor(0, 0, 0);
             $pdf->SetFillColor(255, 255, 255);
             $pdf->SetXY(180, 218);
             $pdf->Cell(27, 4, string::formatoNumero($data['info']->descuento), 1, 0, 'L', 1);
             $y += 4;
             $pdf->SetFont('Arial', '', 8.5);
             $pdf->SetTextColor(0, 0, 0);
             $pdf->SetFillColor(232, 232, 232);
             $pdf->SetXY(156, 222);
             $pdf->Cell(24, 4, 'SUB-TOTAL', 1, 0, 'L', 1);
             $pdf->SetTextColor(0, 0, 0);
             $pdf->SetFillColor(255, 255, 255);
             $pdf->SetXY(180, 222);
             $pdf->Cell(27, 4, string::formatoNumero(floatval($data['info']->subtotal) - floatval($data['info']->descuento)), 1, 0, 'L', 1);
         }
         $y += 4;
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFillColor(232, 232, 232);
         $pdf->SetXY(156, $y);
         $pdf->Cell(24, 4, 'I.V.A.', 1, 0, 'L', 1);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFillColor(255, 255, 255);
         $pdf->SetXY(180, $y);
         $pdf->Cell(27, 4, string::formatoNumero($data['info']->importe_iva), 1, 0, 'L', 1);
         if (floatval($data['info']->retencion_iva) > 0) {
             $y += 4;
             $pdf->SetTextColor(0, 0, 0);
             $pdf->SetFillColor(232, 232, 232);
             $pdf->SetXY(156, $y);
             $pdf->Cell(24, 4, 'Ret. I.V.A.', 1, 0, 'L', 1);
             $pdf->SetTextColor(0, 0, 0);
             $pdf->SetFillColor(255, 255, 255);
             $pdf->SetXY(180, $y);
             $pdf->Cell(27, 4, string::formatoNumero($data['info']->retencion_iva), 1, 0, 'L', 1);
         }
         $y += 4;
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFillColor(232, 232, 232);
         $pdf->SetXY(156, $y);
         $pdf->Cell(24, 4, 'TOTAL', 1, 0, 'L', 1);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFillColor(255, 255, 255);
         $pdf->SetXY(180, $y);
         $pdf->Cell(27, 4, string::formatoNumero($data['info']->total), 1, 0, 'L', 1);
         $pdf->SetXY(51, 214);
         $pdf->Cell(105, 24, '', 1, 0, 'L');
         $pdf->SetXY(51, 217);
         $pdf->SetAligns(array('L'));
         $pdf->SetWidths(array(105));
         $pdf->Row(array(strtoupper(string::num2letras($data['info']->total))), false, false);
         $pdf->Image(APPPATH . 'images/series_folios/' . $data['info']->img_cbb, 11, 217, 34, 34);
         // 185
         $pdf->SetFont('Arial', '', 8);
         $pdf->SetXY(50, 238);
         $pdf->Cell(155, 6, $data_serie->leyenda1, 0, 0, 'L');
         $pdf->SetXY(50, 241);
         $pdf->SetAligns(array('L'));
         $pdf->SetWidths(array(155));
         $pdf->Row(array($data_serie->leyenda2 . ' ' . $data_serie->ano_aprobacion), false, false);
         // .' '.$data['info']->ano_aprobacion
         // $pdf->SetXY(50, 229);
         // $pdf->Cell(106, 6, $data['info']->forma_pago, 0, 0, 'L');
         $pdf->SetXY(50, 233);
         $pdf->Cell(106, 6, 'Metodo de pago: ' . $data['info']->metodo_pago . ', ' . $data['info']->metodo_pago_digitos, 0, 0, 'L');
         $pdf->SetFont('Arial', '', 10);
         $pdf->SetXY(50, 249);
         $pdf->Cell(155, 6, $data_empresa->regimen_fiscal, 0, 0, 'L');
         $pdf->SetXY(10, 252);
         $pdf->Cell(155, 6, "SICOFI " . $data_serie->no_aprobacion, 0, 0, 'L');
         // $pdf->SetXY(170, 258);
         // $pdf->SetFont('Arial','B', 12);
         // $pdf->SetTextColor(204, 0, 0);
         // $pdf->Cell(35, 8, ($data['info']->serie!=''? $data['info']->serie.'-': '').$data['info']->folio, 0, 0, 'C');
         if ($data['info']->status == 'ca') {
             $pdf->Image(APPPATH . 'images/cancelado.png', 3, 9, 215, 270);
         }
         $pdf->Output('Factura.pdf', 'I');
     } else {
         redirect(base_url('panel/facturacion'));
     }
 }
 public function rvp_pdf()
 {
     $data = $this->getRVP();
     $this->load->library('mypdf');
     // Creación del objeto de la clase heredada
     $pdf = new MYpdf('P', 'mm', 'Letter');
     $pdf->show_head = true;
     $pdf->titulo2 = 'Reporte Ventas Productos';
     if (!empty($_GET['ffecha1']) && !empty($_GET['ffecha2'])) {
         $pdf->titulo3 = "Del " . $_GET['ffecha1'] . " al " . $_GET['ffecha2'] . "";
     } elseif (!empty($_GET['ffecha1'])) {
         $pdf->titulo3 = "Del " . $_GET['ffecha1'];
     } elseif (!empty($_GET['ffecha2'])) {
         $pdf->titulo3 = "Del " . $_GET['ffecha2'];
     }
     $pdf->AliasNbPages();
     // $links = array('', '', '', '');
     $pdf->SetY(30);
     $aligns = array('C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C');
     $widths = array(20, 120, 20, 44);
     $header = array('Codigo', 'Producto', 'Cantidad', 'Importe');
     $total = 0;
     foreach ($data as $key => $item) {
         $band_head = false;
         if ($pdf->GetY() >= $pdf->limiteY || $key == 0) {
             $pdf->AddPage();
             $pdf->SetFont('Arial', 'B', 8);
             $pdf->SetTextColor(255, 255, 255);
             $pdf->SetFillColor(160, 160, 160);
             $pdf->SetX(6);
             $pdf->SetAligns($aligns);
             $pdf->SetWidths($widths);
             $pdf->Row($header, true);
         }
         $pdf->SetFont('Arial', '', 8);
         $pdf->SetTextColor(0, 0, 0);
         $datos = array($item->codigo, $item->producto, $item->total_cantidad, String::formatoNumero($item->total_importe));
         $pdf->SetX(6);
         $pdf->SetAligns($aligns);
         $pdf->SetWidths($widths);
         $pdf->Row($datos, false);
     }
     $pdf->Output('Reporte_Ventas_Productos.pdf', 'I');
 }
 public function imprime_nota_venta()
 {
     if (isset($_GET['id'][0])) {
         $this->load->model('notas_venta_model');
         $res = $this->notas_venta_model->getInfoNotaVenta($_GET['id']);
         $this->load->library('mypdf');
         // Creacion del objeto de la clase heredada
         $pdf = new MYpdf('P', 'mm', 'Letter');
         $pdf->show_head = false;
         $pdf->AddPage();
         $pdf->SetFont('Arial', '', 8);
         $y = 30;
         $pdf->Image(APPPATH . '/images/logo.png', 15, 10, 25, 25, "PNG");
         $pdf->SetFont('Arial', 'B', 17);
         $pdf->SetXY(45, $y);
         $pdf->Cell(120, 6, 'F U M I G A C I O N E S   A E R E A S', 0, 0, 'C');
         // ----------- FOLIO ------------------
         $pdf->SetXY(170, $y - 8);
         $pdf->Cell(30, 15, '', 1, 0, 'C');
         $pdf->SetFont('Arial', 'B', 11);
         $pdf->SetTextColor(255, 255, 255);
         $pdf->SetFillColor(160, 160, 160);
         $pdf->SetXY(170, $y - 8);
         $pdf->Cell(30, 5, 'FOLIO', 1, 0, 'C', 1);
         $pdf->SetFont('Arial', '', 18);
         $pdf->SetTextColor(255, 0, 0);
         $pdf->SetFillColor(255, 255, 255);
         $pdf->SetXY(170, $y - 3);
         $pdf->Cell(30, 10, $res[1]['cliente_info'][0]->folio, 0, 0, 'C');
         // ----------- FECHA ------------------
         $pdf->SetXY(170, $y + 8);
         $pdf->Cell(30, 12, '', 1, 0, 'C');
         $pdf->SetFont('Arial', 'B', 11);
         $pdf->SetTextColor(255, 255, 255);
         $pdf->SetFillColor(160, 160, 160);
         $pdf->SetXY(170, $y + 8);
         $pdf->Cell(30, 5, 'FECHA', 1, 0, 'C', 1);
         $pdf->SetFont('Arial', '', 15);
         $pdf->SetTextColor(255, 0, 0);
         $pdf->SetFillColor(255, 255, 255);
         $pdf->SetXY(170, $y + 13);
         $pdf->Cell(30, 7, $res[1]['cliente_info'][0]->fecha, 1, 0, 'C', 1);
         // ----------- DATOS CLIENTE ------------------
         $pdf->SetXY(15, $y + 7);
         $pdf->Cell(153, 23, '', 1, 0, 'C');
         $pdf->SetFont('Arial', 'B', 11);
         $pdf->SetTextColor('0', '0', '0');
         $pdf->SetXY(15, $y + 9);
         $pdf->Cell(20, 5, 'Nombre:', 0, 0, 'L');
         $pdf->SetXY(15, $y + 15);
         $pdf->Cell(20, 5, 'Domicilio:', 0, 0, 'L');
         $pdf->SetXY(15, $y + 22);
         $pdf->Cell(20, 5, 'Lugar:', 0, 0, 'L');
         $pdf->SetFont('Arial', '', 12);
         $pdf->SetXY(35, $y + 9);
         $pdf->Cell(130, 5, $res[1]['cliente_info'][0]->nombre_fiscal, 0, 0, 'L');
         $pdf->SetXY(35, $y + 15);
         $pdf->Cell(130, 5, $res[1]['cliente_info'][0]->domiciliof2, 0, 0, 'L');
         $pdf->SetXY(35, $y + 22);
         $pdf->Cell(130, 5, $res[1]['cliente_info'][0]->domiciliof2, 0, 0, 'L');
         // ----------- TABLA CON LOS TICKETS ------------------
         $pdf->SetY($y + 33);
         $aligns = array('C', 'C', 'C');
         $widths = array(25, 127, 33);
         $header = array('Cantidad', 'Descripción', 'Importe');
         foreach ($res[1]['tickets_info'] as $key => $item) {
             $band_head = false;
             if ($pdf->GetY() >= 200 || $key == 0) {
                 //salta de pagina si exede el max
                 if ($key > 0) {
                     $pdf->AddPage();
                 }
                 $pdf->SetFont('Arial', 'B', 8);
                 $pdf->SetTextColor(255, 255, 255);
                 $pdf->SetFillColor(160, 160, 160);
                 $pdf->SetX(15);
                 $pdf->SetAligns($aligns);
                 $pdf->SetWidths($widths);
                 $pdf->Row($header, true);
             }
             $pdf->SetFont('Arial', '', 10);
             $pdf->SetTextColor(0, 0, 0);
             $datos = array('1', 'Ticket Folio:' . $item->folio, String::formatoNumero($item->subtotal));
             $pdf->SetX(15);
             $pdf->SetAligns($aligns);
             $pdf->SetWidths($widths);
             $pdf->Row($datos, false);
         }
         //------------ SUBTOTAL, IVA ,TOTAL --------------------
         $y = $pdf->GetY();
         $pdf->SetFont('Arial', 'B', 10);
         $pdf->SetTextColor(255, 255, 255);
         $pdf->SetFillColor(160, 160, 160);
         $pdf->SetXY(144, $y + 5);
         $pdf->Cell(23, 8, 'Subtotal', 1, 0, 'C', 1);
         $pdf->SetXY(144, $y + 13);
         $pdf->Cell(23, 8, 'IVA', 1, 0, 'C', 1);
         $pdf->SetXY(144, $y + 21);
         $pdf->Cell(23, 8, 'Total', 1, 0, 'C', 1);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFillColor(255, 255, 255);
         $pdf->SetXY(167, $y + 5);
         $pdf->Cell(33, 8, String::formatoNumero($res[1]['cliente_info'][0]->subtotal, 2), 1, 0, 'C');
         $pdf->SetXY(167, $y + 13);
         $pdf->Cell(33, 8, String::formatoNumero($res[1]['cliente_info'][0]->iva, 2), 1, 0, 'C');
         $pdf->SetXY(167, $y + 21);
         $pdf->Cell(33, 8, String::formatoNumero($res[1]['cliente_info'][0]->total, 2), 1, 0, 'C');
         //------------ TOTAL CON LETRA--------------------
         $pdf->SetXY(15, $y + 5);
         $pdf->Cell(125, 24, '', 1, 0, 'C');
         $pdf->SetFont('Arial', 'B', 13);
         $pdf->SetXY(15, $y + 5);
         $pdf->Cell(60, 8, 'IMPORTE CON LETRA', 0, 0, 'L');
         $pdf->SetFont('Arial', '', 12);
         $pdf->SetXY(15, $y + 13);
         $pdf->Cell(125, 16, String::num2letras($res[1]['cliente_info'][0]->total), 0, 0, 'C');
         $pdf->Output('nota_de_venta.pdf', 'I');
     }
 }
 /**
  * Genera el reporte en pdf reporte bajos de inventario
  */
 public function RFamiliasDescripcion()
 {
     $this->load->library('mypdf');
     // Creación del objeto de la clase heredada
     $pdf = new MYpdf('L', 'mm', 'Letter');
     $pdf->show_head = true;
     $pdf->titulo2 = 'Listado de familias';
     $data = $this->getDataRFamiliasDescripcion();
     $pdf->titulo1 = $data['titulo1'];
     $pdf->titulo3 = $data['titulo3'];
     $pdf->logo = $data['logo'];
     $pdf->AliasNbPages();
     // $links = array('', '', '', '');
     $pdf->SetY(30);
     $aligns = array('L', 'C', 'C', 'L');
     $widths = array(45, 25, 25, 90);
     //90, 25, 25, 130
     $header = array('Nombre', 'Existencia', 'Precio venta', 'Descripcion');
     foreach ($data['info'] as $key => $item) {
         $band_head = false;
         if ($pdf->GetY() >= $pdf->limiteY || $key == 0) {
             $pdf->AddPage();
             $pdf->SetFont('Arial', 'B', 8);
             $pdf->SetTextColor(255, 255, 255);
             $pdf->SetFillColor(160, 160, 160);
             $pdf->SetX(45);
             $pdf->SetAligns($aligns);
             $pdf->SetWidths($widths);
             $pdf->Row($header, true);
         }
         $pdf->SetFont('Arial', '', 8);
         $pdf->SetTextColor(0, 0, 0);
         $datos = array($item->nombre, String::formatoNumero($item->existencia, 0, ''), String::formatoNumero($item->precio_venta, 2, ''), $item->descripcion);
         $pdf->SetX(45);
         $pdf->SetAligns($aligns);
         $pdf->SetWidths($widths);
         $pdf->Row($datos, false, true);
     }
     $pdf->Output('reporte_familias_descrip.pdf', 'I');
 }
 public function getPdfReporteMensual()
 {
     $_POST['fano'] = $_GET['fano'];
     $_POST['fmes'] = $_GET['fmes'];
     // $string = $this->getFacturasReporteMensual();
     $sql = $this->db->query("SELECT rfc, serie, folio, no_aprobacion, EXTRACT(YEAR from fecha) as anio, fecha, total, importe_iva, status\r\n\t\t\t\t\t\t\t\t\tFROM facturacion\r\n\t\t\t\t\t\t\t\t\tWHERE EXTRACT(YEAR from fecha) = '{$this->input->post('fano')}' AND EXTRACT(MONTH from fecha) = '{$this->input->post('fmes')}'\r\n\t\t\t\t\t\t\t\t\tORDER BY fecha ASC\r\n\t\t\t\t\t\t\t\t");
     $this->load->library('mypdf');
     // Creación del objeto de la clase heredada
     $pdf = new MYpdf('P', 'mm', 'Letter');
     $pdf->show_head = true;
     $pdf->titulo2 = 'Reporte Mensual';
     $pdf->titulo3 = String::mes($_POST['fmes']) . " del {$_POST['fano']}\n";
     //$pdf->titulo3 .=  $nombre_producto;
     $pdf->AliasNbPages();
     $pdf->AddPage();
     // $links = array('', '', '', '');
     $pdf->SetY(30);
     $aligns = array('C', 'C', 'C', 'C', 'C', 'C', 'C', 'C', 'C');
     $widths = array(25, 10, 15, 20, 24, 35, 30, 30, 18);
     $header = array('Rfc', 'Serie', 'Folio', 'Año', 'No Aprobación', 'Fecha', 'Total', 'IVA', 'Estado');
     foreach ($sql->result() as $key => $item) {
         $band_head = false;
         if ($pdf->GetY() >= 200 || $key == 0) {
             //salta de pagina si exede el max
             if ($key > 0) {
                 $pdf->AddPage();
             }
             $pdf->SetFont('Arial', 'B', 8);
             $pdf->SetTextColor(255, 255, 255);
             $pdf->SetFillColor(140, 140, 140);
             $pdf->SetX(5);
             $pdf->SetAligns($aligns);
             $pdf->SetWidths($widths);
             $pdf->Row($header, true);
         }
         $pdf->SetFont('Arial', '', 8);
         $pdf->SetTextColor(0, 0, 0);
         $datos = array($item->rfc, $item->serie, $item->folio, $item->anio, $item->no_aprobacion, str_replace('-', '/', $item->fecha), String::formatoNumero($item->total), String::formatoNumero($item->importe_iva), $item->status == 'ca' ? 'Cancelada' : 'Pagada');
         $pdf->SetX(5);
         $pdf->SetAligns($aligns);
         $pdf->SetWidths($widths);
         $pdf->Row($datos, false);
     }
     // $pdf->SetXY(5, 30);
     // $pdf->SetFont('Arial','',9);
     // $pdf->SetAligns(array('L'));
     // $pdf->SetWidths(array(205));
     // $pdf->Row(array($string), false, false);
     $pdf->Output('Reporte_Mensual_' . $_POST['fano'] . $_POST['fmes'] . '.pdf', 'I');
 }
 /**
  * Imprime el listado de precios de acuerdo a los filtros
  */
 public function imprime_lista()
 {
     $this->load->model('productos_model');
     $this->load->model('listas_precio_model');
     //Filtro familia
     $params['idfamilia'] = null;
     if ($this->input->get('ffamilia') != '0') {
         $params['idfamilia'] = $this->input->get('ffamilia');
     }
     $ids = "'" . str_replace(',', "','", substr($this->input->get('listasid'), 1)) . "'";
     $params['familias'] = $this->productos_model->getFamilias();
     $params['listas'] = $this->listas_precio_model->obtenListasPrecio("id_lista IN(" . $ids . ")");
     $params['tbl_precios'] = $this->listas_precio_model->createTblPrecios($params['listas'], $params['idfamilia'], false);
     $this->load->library('mypdf');
     // Creación del objeto de la clase heredada
     $pdf = new MYpdf('P', 'mm', 'Letter');
     $pdf->titulo2 = 'Listas de precio';
     if ($params['idfamilia'] != null) {
         $pdf->titulo3 = 'Familia: ' . $this->input->get('familia') . "\n";
     }
     if ($this->input->get('listas') != '') {
         $pdf->titulo3 .= "Listas: " . $this->input->get('listas');
     }
     $pdf->AliasNbPages();
     $pdf->AddPage();
     $pdf->SetFont('Arial', '', 8);
     $header = array();
     foreach ($params['tbl_precios']['tabla'] as $key => $rows) {
         $aligns = array();
         $widths = array();
         $datos = array();
         $band_head = false;
         if ($pdf->GetY() >= $pdf->limiteY) {
             //salta de pagina si exede el max
             $pdf->AddPage();
             $band_head = true;
         }
         foreach ($rows as $key2 => $cols) {
             if ($key2 == 0) {
                 //codigo producto
                 $aligns[$key2] = 'C';
                 $widths[$key2] = 30;
             } elseif ($key2 == 1) {
                 //nombre producto
                 $aligns[$key2] = 'L';
                 $widths[$key2] = 70;
             } else {
                 //listas precios
                 $aligns[$key2] = 'C';
                 $widths[$key2] = 25;
                 $cols = explode('|', $cols);
                 //id_producto|precio|id_lista
                 if (isset($cols[1])) {
                     $cols = String::formatoNumero($cols[1]);
                 } else {
                     $cols = $cols[0];
                 }
             }
             $datos[$key2] = $cols;
         }
         $pdf->SetFont('Arial', '', 8);
         $pdf->SetTextColor(0, 0, 0);
         if ($key == 0 || $band_head) {
             //guardo el header de la tabla para las nuevas paginas
             if ($key == 0) {
                 $header[] = $aligns;
                 $header[] = $widths;
                 $header[] = $datos;
             }
             $band_head = true;
             $pdf->SetFont('Arial', 'B', 8);
             $pdf->SetTextColor(255, 255, 255);
             $pdf->SetFillColor(160, 160, 160);
         }
         $pdf->SetX(6);
         $pdf->SetAligns($aligns);
         $pdf->SetWidths($widths);
         $pdf->Row($datos, $band_head);
     }
     $pdf->Output('listas_de_precio.pdf', 'I');
 }
 /**
  * Genera el reporte de los vuelos
  * @param unknown_type $data
  */
 public function pdf_rv($data)
 {
     if ($_GET['dfecha1'] != '' && $_GET['dfecha2'] != '') {
         $labelFechas = "Desde la fecha " . $_GET['dfecha1'] . " hasta " . $_GET['dfecha2'];
     } elseif ($_GET['dfecha1'] != "") {
         $labelFechas = "Desde la fecha " . $_GET['dfecha1'];
     } elseif ($_GET['dfecha2'] != '') {
         $labelFechas = "Hasta la fecha " . $_GET['dfecha2'];
     }
     $this->load->library('mypdf');
     // Creación del objeto de la clase heredada
     $pdf = new MYpdf('P', 'mm', 'Letter');
     $pdf->show_head = true;
     $pdf->titulo2 = 'Reporte de Vuelos';
     $lbl_cli = !empty($_GET['did_cliente']) ? "Del Cliente {$_GET['dcliente']}" : "";
     $lbl_pil = !empty($_GET['did_proveedor']) ? $lbl_cli != '' ? " y Piloto {$_GET['dproveedor']}" : "Del Piloto: {$_GET['dproveedor']}" : "";
     $pdf->titulo3 = $lbl_cli . $lbl_pil . "\n" . $labelFechas;
     $pdf->AliasNbPages();
     $pdf->AddPage();
     // $links = array('', '', '', '', '', '', '');
     $aligns = array('C', 'C', 'C', 'C', 'C', 'C', 'C');
     $widths = array(20, 50, 30, 30, 15, 30, 30);
     $header = array('fecha', 'cliente(s)', 'Piloto', 'Avión', 'Vuelos', 'T. Vuelo', 'Precio');
     $tvuelos = 0;
     $ttotal = 0;
     foreach ($data['data'] as $key => $item) {
         $band_head = false;
         if ($pdf->GetY() >= $pdf->limiteY || $key == 0) {
             //salta de pagina si exede el max
             if ($key > 0) {
                 $pdf->AddPage();
             }
             $pdf->SetFont('Arial', 'B', 9);
             $pdf->SetTextColor(255, 255, 255);
             $pdf->SetFillColor(140, 140, 140);
             $pdf->SetX(6);
             $pdf->SetAligns($aligns);
             $pdf->SetWidths($widths);
             $pdf->Row($header, true);
         }
         $pdf->SetFont('Arial', '', 8);
         $pdf->SetTextColor(0, 0, 0);
         $tvuelos += floatval($item->vuelos);
         $ttotal += floatval($item->precio);
         foreach ($data['tipos'] as $key => $tipo) {
             if ($item->tipo_vuelo == $tipo->nombre) {
                 $data['tipos'][$key]->tvuelos += 1;
                 $data['tipos'][$key]->ttotal += floatval($item->precio);
                 break;
             }
         }
         $datos = array(substr($item->fecha, 0, 19), str_replace('<br>', ', ', $item->clientes), $item->piloto, $item->avion, $item->vuelos, $item->tipo_vuelo, String::formatoNumero($item->precio));
         $pdf->SetX(6);
         $pdf->SetAligns($aligns);
         $pdf->SetWidths($widths);
         $pdf->Row($datos, false);
     }
     if (count($data['data']) > 0) {
         $y = $pdf->GetY();
         $pdf->SetFont('Arial', 'B', 9);
         if ($pdf->GetY() + 6 >= $pdf->limiteY) {
             $pdf->AddPage();
             $y = $pdf->GetY();
         }
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFillColor(255, 255, 255);
         $pdf->SetXY(106, $y + 5);
         $pdf->Cell(30, 6, 'De los Cuales: ', 0, 0, 'C', 1);
         $y = $y + 5;
         $pdf->SetFont('Arial', '', 8);
         foreach ($data['tipos'] as $key => $tipo) {
             if ($pdf->GetY() >= $pdf->limiteY || $key == 0) {
                 //salta de pagina si exede el max
                 if ($key > 0) {
                     $pdf->AddPage();
                 }
             }
             $y += 6;
             $pdf->SetTextColor(255, 255, 255);
             $pdf->SetFillColor(140, 140, 140);
             $pdf->SetXY(106, $y);
             $pdf->Cell(30, 6, $tipo->nombre, 1, 0, 'C', 1);
             $pdf->SetXY(151, $y);
             $pdf->Cell(30, 6, 'Sub-Total', 1, 0, 'C', 1);
             $pdf->SetTextColor(0, 0, 0);
             $pdf->SetFillColor(255, 255, 255);
             $pdf->SetXY(136, $y);
             $pdf->Cell(15, 6, $tipo->tvuelos, 1, 0, 'C', 1);
             $pdf->SetXY(181, $y);
             $pdf->Cell(30, 6, String::formatoNumero($tipo->ttotal), 1, 0, 'C', 1);
         }
         $pdf->SetFont('Arial', 'B', 9);
         $pdf->SetTextColor(255, 255, 255);
         $pdf->SetFillColor(140, 140, 140);
         $pdf->SetXY(106, $y + 5);
         $pdf->Cell(30, 6, 'Total Vuelos', 1, 0, 'C', 1);
         $pdf->SetXY(151, $y + 5);
         $pdf->Cell(30, 6, 'Total', 1, 0, 'C', 1);
         $pdf->SetTextColor(0, 0, 0);
         $pdf->SetFillColor(255, 255, 255);
         $pdf->SetXY(136, $y + 5);
         $pdf->Cell(15, 6, $tvuelos, 1, 0, 'C', 1);
         $pdf->SetXY(181, $y + 5);
         $pdf->Cell(30, 6, String::formatoNumero($ttotal), 1, 0, 'C', 1);
     }
     $pdf->Output('reporte_vuelos.pdf', 'I');
 }
Exemple #17
0
 /**
  * Genera el reporte productos bajos del stock
  */
 public function productos_bajos()
 {
     $prod_bajos = $this->db->query("SELECT * FROM reportes_costo_existencias1 WHERE stock_min > existencia")->result();
     $this->load->library('mypdf');
     // Creación del objeto de la clase heredada
     $pdf = new MYpdf('P', 'mm', 'Letter');
     $pdf->show_head = true;
     $pdf->titulo2 = 'Reporte Productos Bajos de Inventario';
     $pdf->AliasNbPages();
     $pdf->AddPage();
     $links = array('', '', '', '');
     $aligns = array('C', 'C', 'C', 'C');
     $widths1 = array(98, 35, 35, 35);
     $header1 = array('Producto', 'Existencia', 'Stock min', 'Faltante');
     foreach ($prod_bajos as $key => $item) {
         if ($pdf->GetY() >= $pdf->limiteY || $key == 0) {
             //salta de pagina si exede el max
             if ($key > 0) {
                 $pdf->AddPage();
             }
             $pdf->SetFont('Arial', 'B', 8);
             $pdf->SetTextColor(255, 255, 255);
             $pdf->SetFillColor(160, 160, 160);
             $pdf->SetX(6);
             $pdf->SetAligns($aligns);
             $pdf->SetWidths($widths1);
             $pdf->Row($header1, true);
         }
         $pdf->SetFont('Arial', '', 8);
         $pdf->SetTextColor(0, 0, 0);
         $datarow = array($item->nombre, $item->existencia, $item->stock_min, $item->stock_min - $item->existencia);
         $pdf->SetX(6);
         $pdf->SetAligns($aligns);
         $pdf->SetWidths($widths1);
         $pdf->Row($datarow, false);
     }
     $pdf->Output('reporte.pdf', 'I');
 }
 /**
  * Genera el reporte de las asistencias de empleados
  * @param unknown_type $data
  */
 public function pdf_rda($data)
 {
     $semanas = String::obtenerSemanasDelAnio($_GET['fanio'], true);
     foreach ($semanas as $s) {
         if ($s['semana'] == $_GET['fsemana']) {
             $finicio_semana = $s['fecha_inicio'];
             $ffin_semana = $s['fecha_final'];
             break;
         }
     }
     $labelFechas = "Semana {$_GET['fsemana']} del {$finicio_semana} al {$ffin_semana}";
     $this->load->library('mypdf');
     // Creación del objeto de la clase heredada
     $pdf = new MYpdf('P', 'mm', 'Letter');
     $pdf->show_head = true;
     $pdf->titulo2 = 'Reporte de Asistencias';
     $pdf->titulo3 = "Año {$_GET['fanio']} \n" . $labelFechas;
     $pdf->AliasNbPages();
     $pdf->AddPage();
     // $links = array('', '', '', '', '', '', '');
     $aligns = array('C', 'C', 'C', 'C', 'C');
     $widths = array(105, 30, 20, 20, 30);
     $header = array('Empleado', 'Dias Asistidos', 'Retardos', 'Faltas', 'Dias Trabajados');
     foreach ($data['empleados'] as $key => $item) {
         if ($pdf->GetY() >= $pdf->limiteY || $key == 0) {
             //salta de pagina si exede el max
             if ($key > 0) {
                 $pdf->AddPage();
             }
             $pdf->SetFont('Arial', 'B', 9);
             $pdf->SetTextColor(255, 255, 255);
             $pdf->SetFillColor(140, 140, 140);
             $pdf->SetX(6);
             $pdf->SetAligns($aligns);
             $pdf->SetWidths($widths);
             $pdf->Row($header, true);
         }
         $pdf->SetFont('Arial', '', 8);
         $pdf->SetTextColor(0, 0, 0);
         $datos = array($item->apellido_paterno . ' ' . $item->apellido_materno . ' ' . $item->nombre, $item->dias_asistidos, $item->retardos, $item->dias_faltados, $item->dias_trabajados);
         $pdf->SetX(6);
         $pdf->SetAligns($aligns);
         $pdf->SetWidths($widths);
         $pdf->Row($datos, false);
     }
     // if ( count($data['empleados']) == 0 ) {
     // 	$y = $pdf->GetY();
     // 	$pdf->SetFont('Arial','B',9);
     // 	if($pdf->GetY()+6 >= $pdf->limiteY){
     // 		$pdf->AddPage();
     // 		$y = $pdf->GetY();
     // 	}
     // 	$pdf->SetTextColor(0,0,0);
     // 	$pdf->SetFillColor(255,255,255);
     // 	$pdf->SetXY(106, $y+5);
     // 	$pdf->Cell(30, 6, 'De los Cuales: ', 0, 0, 'C', 1);
     // 	$y = $y + 5;
     // 	$pdf->SetFont('Arial','',8);
     // 	foreach ($data['tipos'] as $key => $tipo) {
     // 		if($pdf->GetY() >= $pdf->limiteY || $key==0){ //salta de pagina si exede el max
     // 			if($key > 0)
     // 				$pdf->AddPage();
     // 		}
     // 		$y += 6;
     // 		$pdf->SetTextColor(255,255,255);
     // 		$pdf->SetFillColor(140,140,140);
     // 		$pdf->SetXY(106, $y);
     // 		$pdf->Cell(30, 6, $tipo->nombre , 1, 0, 'C',1);
     // 		$pdf->SetXY(151, $y);
     // 		$pdf->Cell(30, 6, 'Sub-Total' , 1, 0, 'C',1);
     // 		$pdf->SetTextColor(0,0,0);
     // 		$pdf->SetFillColor(255,255,255);
     // 		$pdf->SetXY(136, $y);
     // 		$pdf->Cell(15, 6, $tipo->tvuelos , 1, 0, 'C',1);
     // 		$pdf->SetXY(181, $y);
     // 		$pdf->Cell(30, 6, String::formatoNumero($tipo->ttotal), 1, 0, 'C',1);
     // 	}
     // 	$pdf->SetFont('Arial','B',9);
     // 	$pdf->SetTextColor(255,255,255);
     // 	$pdf->SetFillColor(140,140,140);
     // 	$pdf->SetXY(106, ($y+5));
     // 	$pdf->Cell(30, 6, 'Total Vuelos' , 1, 0, 'C',1);
     // 	$pdf->SetXY(151, ($y+5));
     // 	$pdf->Cell(30, 6, 'Total' , 1, 0, 'C',1);
     // 	$pdf->SetTextColor(0,0,0);
     // 	$pdf->SetFillColor(255,255,255);
     // 	$pdf->SetXY(136, ($y+5));
     // 	$pdf->Cell(15, 6, $tvuelos , 1, 0, 'C',1);
     // 	$pdf->SetXY(181, ($y+5));
     // 	$pdf->Cell(30, 6, String::formatoNumero($ttotal), 1, 0, 'C',1);
     // }
     $pdf->Output('reporte_asistencias.pdf', 'I');
 }