function geraPDF($id)
    {
        $passagem = $this->Passagem->findById($id);
        $tcpdf = new XTCPDF();
        $textfont = 'aefurat';
        // looks better, finer, and more condensed than 'dejavusans'
        // $tcpdf->SetAuthor("BuyPass - BuyPass.com.br");
        $tcpdf->SetAutoPageBreak(false);
        // $tcpdf->setHeaderFont(array($textfont,'',40));
        // // $tcpdf->xheadercolor = array(150,0,0);
        // $tcpdf->xheadertext = 'BuyPas';
        $tcpdf->xfootertext = 'Copyright © %d BuyPass direitos reservadas.';
        $tcpdf->SetFont($textfont, 'B', 16);
        // add a page (required with recent versions of tcpdf)
        $tcpdf->AddPage();
        $tcpdf->SetTextColor(0, 0, 0);
        // set text shadow effect
        $tcpdf->setTextShadow(array('enabled' => true, 'depth_w' => 0.2, 'depth_h' => 0.2, 'color' => array(196, 196, 196), 'opacity' => 1, 'blend_mode' => 'Normal'));
        $string = '<div class="row">
                    <h2> Segunda via: Comprovante de compra de passagem </h2>
                       
                     <span>Nome:</span>' . ' ' . h($passagem['Passagem']['cliente']) . '<br>' . '<span>Transação feita (por/no):</span>' . ' ' . h($passagem['Passagem']['funcionario']) . '<br>' . '<span>Trajeto e Data e Horário:</span>' . ' ' . h($passagem['Rota']['trajeto']) . '<br>' . '<span>Valor:</span>' . ' ' . h($passagem['Rota']['valor']) . '.00' . '<br>' . '<span>Tipo de Ônibus:</span>' . ' ' . h($passagem['Veiculo']['tipo']) . '<br>' . '<span>Pontos ganhos:</span>' . ' ' . h($passagem['Rota']['pontos']) . '
                        
                </div>
';
        $html = <<<EOD
        {$string}
EOD;
        // Print text using writeHTMLCell()
        $tcpdf->writeHTMLCell(0, 0, '', '', $html, 0, 1, 0, true, '', true);
        // ...
        // etc.
        // see the TCPDF examples
        echo $tcpdf->Output('BuyPass.pdf', 'D');
        $this->redirect(array('action' => 'view', $id));
    }
 function informe_densidad($boleta)
 {
     $cantidad_densidades = 6;
     $this->BoletaHasDensidades->BindModel(array('hasOne' => array('Area' => array('className' => 'Area', 'foreignKey' => '', 'conditions' => array('Area.id = BoletaHasDensidades.area')), 'SubArea' => array('className' => 'SubArea', 'foreignKey' => '', 'conditions' => array('SubArea.id = BoletaHasDensidades.subarea')), 'TipoRelleno' => array('className' => 'TipoRelleno', 'foreignKey' => '', 'conditions' => array('TipoRelleno.id = BoletaHasDensidades.tipo_relleno')))));
     $bho = $this->BoletaHasObra->find('first', array('conditions' => array('BoletaHasObra.boleta' => $boleta)));
     $contratista = $this->DatosClientes->find('first', array('conditions' => array('DAT_CLI_RUT' => $bho['Obra']['contratista_rut'])));
     $solicitante = $this->DatosClientes->find('first', array('conditions' => array('DAT_CLI_RUT' => $bho['Obra']['cliente_rut'])));
     $destinatario = $this->Destinatario->find('first', array('conditions' => array('id' => $bho['Obra']['destinatario'])));
     $operador = $this->Operador->find('first', array('conditions' => array('id' => $bho['DatosBoleta']['operador'])));
     $bhd = $this->BoletaHasDensidades->find('all', array('conditions' => array('BoletaHasDensidades.boleta' => $boleta), 'order' => 'BoletaHasDensidades.numero_densidad ASC'));
     $mes_densimetro = date('n', strtotime($bho['DatosBoleta']['fecha_inspeccion']));
     $año_densimetro = date('y', strtotime($bho['DatosBoleta']['fecha_inspeccion']));
     $densimetro = $this->Densimetro->find('first', array('conditions' => array('and' => array('codigo_densimetro' => $bho['DatosBoleta']['densimetro'], 'mes' => $mes_densimetro, 'año' => $año_densimetro))));
     if ($mes_densimetro + 1 == 13) {
         $mes_densimetro = 0;
         $año_densimetro = $año_densimetro + 1;
     }
     $densimetro_siguiente = $this->Densimetro->find('first', array('conditions' => array('and' => array('codigo_densimetro' => $bho['DatosBoleta']['densimetro'], 'mes' => $mes_densimetro + 1, 'año' => $año_densimetro))));
     if ($bho['DatosBoleta']['tipo_instrumento'] == 1) {
         //Cono de arena
         $nombre_ensayo = 'Densidad in situ con Cono de Arena';
         $metodologia = 'NCh1516.Of1979 Mecánica de suelos - Determinación de la densidad en el terreno - Método del cono de arena.<br>' . 'NCh1515.Of1979 Mecánica de suelos - Determinación de la humedad.';
     } elseif ($bho['DatosBoleta']['tipo_instrumento'] == 2) {
         //Densimetro nuclear
         $nombre_ensayo = 'Densidad in situ con densímetro nuclear';
         $metodologia = 'ASTM D 6938-08a, Standard Test Methods for In-Place Density and Water Content of Soil and Soil-Aggregate by Nuclear Methods (Shallows Depth) 1';
     }
     if ($bho['DatosBoleta']['tipo_ensayo'] == 1) {
         //densidad relativa
         $tipo_ensayo = 'Densidad Relativa';
         $densidad_relativa = 'Densidad Relativa';
         $proctor = '';
         $densidad_minima = 'Densidad<br>Mínima<br>(g/cm<sup>3</sup>)';
         $densidad_maxima = 'Densidad<br>Máxima<br>(g/cm<sup>3</sup>)';
         $dmcs1 = '';
         $dmcs2 = '';
         $densidad1 = 'Densidad';
         $densidad2_1 = 'Mínima';
         $densidad2_2 = 'Máxima';
         $densidad3 = '(g/cm<sup>3</sup>)';
         //largos analisis de suelos
         $largo_muestra = 25;
         $largo_informe = 35;
         $largo_ensayo = 30;
         $largo_proctor = 1;
         $largo_humedad_optima = 35;
         $largo_densidad_min = 30;
         $largo_densidad_max = 34;
         //termina largo analisis de suelos
         //largo densidad in situ
         $largo_espesor_capa = 25;
         $largo_espesor_medicion = 25;
         $largo_densidad_humeda = 25;
         $largo_humedad = 24;
         $largo_densidad_seca = 25;
         $largo_dmcs = 1;
         $largo_dmin = 15;
         $largo_dmax = 15;
         $largo_densidad_relativa = 25;
         //termina largo densidad in situ
         $nota = '';
     } elseif ($bho['DatosBoleta']['tipo_ensayo'] == 2) {
         //proctor modificado
         $tipo_ensayo = 'Proctor Modificado';
         $densidad_relativa = 'Compactación';
         $proctor = 'DMCS<br>(g/cm<sup>3</sup>)';
         $densidad_minima = '';
         $densidad_maxima = '';
         $dmcs1 = 'DMCS';
         $dmcs2 = '(g/cm<sup>3</sup>)';
         $densidad1 = '';
         $densidad2_1 = '';
         $densidad2_2 = '';
         $densidad3 = '';
         //largos analisis de suelos
         $largo_muestra = 35;
         $largo_informe = 35;
         $largo_ensayo = 35;
         $largo_proctor = 39;
         $largo_humedad_optima = 35;
         $largo_densidad_min = 1;
         $largo_densidad_max = 10;
         //termina largo analisis de suelos
         //largo densidad in situ
         $largo_espesor_capa = 25;
         $largo_espesor_medicion = 25;
         $largo_densidad_humeda = 25;
         $largo_humedad = 28;
         $largo_densidad_seca = 25;
         $largo_dmcs = 25;
         $largo_dmin = 1;
         $largo_dmax = 1;
         $largo_densidad_relativa = 25;
         //termina largo densidad in situ
         $nota = '';
     } elseif ($bho['DatosBoleta']['tipo_ensayo'] == 3) {
         //suelo cementado
         $tipo_ensayo = 'Suelo Cementado';
         $densidad_relativa = 'Compactación';
         $proctor = '';
         $densidad_minima = '';
         $densidad_maxima = '';
         $dmcs1 = '';
         $dmcs2 = '';
         $densidad1 = '';
         $densidad2_1 = '';
         $densidad2_2 = '';
         $densidad3 = '';
         //largos analisis de suelos
         $largo_muestra = 35;
         $largo_informe = 35;
         $largo_ensayo = 35;
         $largo_proctor = 39;
         $largo_humedad_optima = 35;
         $largo_densidad_min = 1;
         $largo_densidad_max = 10;
         //termina largo analisis de suelos
         //largo densidad in situ
         $largo_espesor_capa = 20;
         $largo_espesor_medicion = 20;
         $largo_densidad_humeda = 20;
         $largo_humedad = 25;
         $largo_densidad_seca = 25;
         $largo_dmcs = 25;
         $largo_dmin = 10;
         $largo_dmax = 10;
         $largo_densidad_relativa = 25;
         //termina largo densidad in situ
         //nota solo para suelo cementado
         $nota = '<br>2. El ensayo de control in situ no puede ser controlado, debido a que la densidad presente en el suelo, no permite la penetración mínima para determinar la densidad del elemento.';
     } elseif ($bho['DatosBoleta']['tipo_ensayo'] == 4) {
         //combinado
         $tipo_ensayo = 'Densidad Relativa y Proctor Modificado';
         $densidad_relativa = 'Compactación';
         $proctor = 'DMCS<br>(g/cm<sup>3</sup>)';
         $densidad_minima = 'Densidad<br>Mínima<br>(g/cm<sup>3</sup>)';
         $densidad_maxima = 'Densidad<br>Máxima<br>(g/cm<sup>3</sup>)';
         $dmcs1 = 'DMCS';
         $dmcs2 = '(g/cm<sup>3</sup>)';
         $densidad1 = 'Densidad';
         $densidad2_1 = 'Mínima';
         $densidad2_2 = 'Máxima';
         $densidad3 = '(g/cm<sup>3</sup>)';
         //largos analisis de suelos
         $largo_muestra = 30;
         $largo_informe = 29;
         $largo_ensayo = 30;
         $largo_proctor = 30;
         $largo_humedad_optima = 35;
         $largo_densidad_min = 18;
         $largo_densidad_max = 18;
         //termina largo analisis de suelos
         //largo densidad in situ
         $largo_espesor_capa = 20;
         $largo_espesor_medicion = 20;
         $largo_densidad_humeda = 25;
         $largo_humedad = 20;
         $largo_densidad_seca = 21;
         $largo_dmcs = 25;
         $largo_dmin = 12;
         $largo_dmax = 12;
         $largo_densidad_relativa = 25;
         //termina largo densidad in situ
         $nota = '';
     }
     $numero_informe = $this->punto_miles($bho['DatosBoleta']['numero_informe']);
     $guion = $bho['DatosBoleta']['guion'];
     $verificar_firma = $this->verificar_firma($boleta);
     if ($verificar_firma == 1) {
         KERNEL::error('No se puede subir el informe Nº ' . $numero_informe . '-' . $guion . ' ya que el definitivo se encuentra firmado.');
     } elseif ($verificar_firma == 2) {
         $guion += 1;
         $this->DatosBoleta->id = $bho['DatosBoleta']['boleta'];
         $this->DatosBoleta->saveField('guion', $guion);
     }
     App::import('Vendor', 'informe_densidad');
     $tcpdf = new XTCPDF('M', PDF_UNIT, PDF_PAGE_FORMAT, false, 'ISO-8859-1', false);
     $tcpdf->SetMargins(10, 18, 10);
     $tcpdf->AddPage();
     $tcpdf->SetFont('arial', '', 8);
     $tcpdf->SetCreator(PDF_CREATOR);
     $tcpdf->SetAuthor('IDIEM');
     $tcpdf->SetTitle('Informe Densidad');
     $tcpdf->SetSubject('');
     $tcpdf->SetKeywords('');
     $tcpdf->SetAutoPageBreak(false, PDF_MARGIN_BOTTOM);
     $tcpdf->SetFillColor(204, 204, 204);
     $tcpdf->SetLineWidth(0.1);
     $tcpdf->SetFont('arial', 'black', 9);
     $tcpdf->MultiCell(130, 4, 'INFORME DE ENSAYO Nº ' . $numero_informe . '-' . $guion, 0, 'R', 0, 0, '', '', true, 0, false, true, 4, 'T');
     $tcpdf->SetFont('arial', '', 8);
     $tcpdf->MultiCell(60, 4, 'Fecha de Emisión: ' . $this->fecha_spanish(date('Y-m-d')), 0, 'R', 0, 1, '', '', true, 0, false, true, 4, 'T');
     $tcpdf->SetFont('arial', 'black', 7);
     $tcpdf->MultiCell(190, 4, 'ANTECEDENTES GENERALES', 'B', 'C', 1, 1, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->SetFont('arial', '', 7);
     $tcpdf->MultiCell(35, 4, 'NOMBRE DEL ENSAYO', 'L', 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(95, 4, ': ' . $nombre_ensayo, 0, 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(25, 4, 'CÓDIGO DE OBRA', 0, 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(35, 4, ': ' . $bho['Obra']['codigo_obra'], 'R', 'L', 0, 1, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(35, 4, 'OBRA', 'L', 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(95, 4, ': ' . $bho['Obra']['nombre_obra'], 0, 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(25, 4, '', 0, 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     //eliminaron el numero de control
     $tcpdf->MultiCell(35, 4, '', 'R', 'L', 0, 1, '', '', true, 0, false, true, 4, 'M');
     //eliminaron el numero de control
     $tcpdf->MultiCell(35, 4, 'UBICACIÓN DE LA OBRA', 'L', 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(95, 4, ': ' . $bho['Obra']['direccion'], 0, 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(25, 4, 'DESTINATARIO', 0, 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(35, 4, ': ' . $destinatario['Destinatario']['nombre'], 'R', 'L', 0, 1, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(35, 4, 'CONTRATISTA', 'L', 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(95, 4, ': ' . $contratista['DatosClientes']['DAT_CLI_NOMBRE'], 0, 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(25, 4, 'Nº BOLETA', 0, 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(35, 4, ': ' . $boleta, 'R', 'L', 0, 1, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(35, 4, 'SOLICITANTE', 'L', 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(95, 4, ': ' . $solicitante['DatosClientes']['DAT_CLI_NOMBRE'], 0, 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(25, 4, 'FECHA INSPEC.', 0, 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(35, 4, ': ' . $this->fechaMysql($bho['DatosBoleta']['fecha_inspeccion']), 'R', 'L', 0, 1, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(35, 4, 'DIRECCIÓN', 'L', 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(95, 4, ': ' . $contratista['DatosClientes']['DAT_CLI_DIRECCION'], 0, 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(25, 4, 'FACILITY', 0, 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(35, 4, ': ' . $bho['DatosBoleta']['facility'], 'R', 'L', 0, 1, '', '', true, 0, false, true, 4, 'M');
     //----------
     $tcpdf->SetFont('arial', 'black', 7);
     $tcpdf->MultiCell(190, 4, 'METODOLOGÍA', 'LRT', 'L', 0, 1, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->SetFont('arial', '', 7);
     $tcpdf->MultiCell(190, 4, $metodologia, 'LRB', 'L', 0, 1, '', '', true, 0, true, true, 4, 'M');
     //---------
     $tcpdf->SetFont('arial', 'black', 7);
     $tcpdf->MultiCell(190, 2, '', 'B', 'C', 0, 1, '', '', true, 0, false, true, 2, 'M');
     $tcpdf->MultiCell(190, 4, 'DATOS DEL DENSIMETRO', 'B', 'C', 1, 1, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->SetFont('arial', '', 7);
     $tcpdf->MultiCell(30, 4, 'MARCA', 'LT', 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(40, 4, ': ' . $densimetro['Densimetro']['marca'], 'T', 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(20, 4, 'CONTEO', 'T', 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(40, 4, ': ' . $densimetro['Densimetro']['conteo'], 'T', 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(25, 4, 'OPERADOR', 'T', 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(35, 4, ': ' . $operador['Operador']['nombre'], 'TR', 'L', 0, 1, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(30, 4, 'DENSIMETRO Nº', 'L', 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(40, 4, ': ' . $densimetro['Densimetro']['codigo_densimetro'], '', 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(20, 4, 'MODELO', '', 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(40, 4, ': ' . $densimetro['Densimetro']['modelo'], '', 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(25, 4, 'HUMEDAD', '', 'L', 0, 0, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(35, 4, ': ' . $densimetro['Densimetro']['humedad'], 'R', 'L', 0, 1, '', '', true, 0, false, true, 4, 'M');
     //--------tabla de densidad:
     $tcpdf->MultiCell(30, 4, 'Fecha', 1, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell(80, 4, 'Limite inferior de proyección de densidad de conteo (kg/cm<sup>3</sup>)', 1, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell(80, 4, 'Limite superior de proyección de densidad de conteo (kg/cm<sup>3</sup>)', 1, 'C', 0, 1, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell(30, 4, $this->mesEspañol($densimetro['Densimetro']['mes']) . '-' . $densimetro['Densimetro']['año'], 1, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell(80, 4, $this->punto_miles($densimetro['Densimetro']['limite_inferior']), 1, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell(80, 4, $this->punto_miles($densimetro['Densimetro']['limite_superior']), 1, 'C', 0, 1, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell(30, 4, $this->mesEspañol($densimetro_siguiente['Densimetro']['mes']) . '-' . $densimetro_siguiente['Densimetro']['año'], 1, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell(80, 4, $this->punto_miles($densimetro_siguiente['Densimetro']['limite_inferior']), 1, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell(80, 4, $this->punto_miles($densimetro_siguiente['Densimetro']['limite_superior']), 1, 'C', 0, 1, '', '', true, 0, true, true, 4, 'M');
     //ubicacion de los puntos de control:
     $tcpdf->SetFont('arial', 'black', 7);
     $tcpdf->MultiCell(190, 2, '', 'B', 'C', 0, 1, '', '', true, 0, false, true, 2, 'M');
     $tcpdf->MultiCell(190, 4, 'UBICACIÓN DE LOS PUNTOS DE CONTROL', 'B', 'C', 1, 1, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->SetFont('arial', '', 7);
     for ($i = 1; $i <= $cantidad_densidades; $i++) {
         if ($i == 1) {
             $borde = 'T';
         } elseif ($i == $cantidad_densidades) {
             $borde = 'B';
         } else {
             $borde = '';
         }
         $ubicacion_ptos_control = array();
         if ($bhd[$i - 1]['BoletaHasDensidades']['area']) {
             array_push($ubicacion_ptos_control, $bhd[$i - 1]['Area']['nombre']);
         }
         if ($bhd[$i - 1]['BoletaHasDensidades']['subarea']) {
             array_push($ubicacion_ptos_control, $bhd[$i - 1]['SubArea']['nombre']);
         }
         if ($bhd[$i - 1]['BoletaHasDensidades']['tipo_relleno']) {
             array_push($ubicacion_ptos_control, $bhd[$i - 1]['TipoRelleno']['nombre']);
         }
         if ($bhd[$i - 1]['BoletaHasDensidades']['acopio']) {
             array_push($ubicacion_ptos_control, $bhd[$i - 1]['BoletaHasDensidades']['acopio']);
         }
         if ($bhd[$i - 1]['BoletaHasDensidades']['elemento']) {
             array_push($ubicacion_ptos_control, $bhd[$i - 1]['BoletaHasDensidades']['elemento']);
         }
         if ($bhd[$i - 1]['BoletaHasDensidades']['capa']) {
             array_push($ubicacion_ptos_control, $bhd[$i - 1]['BoletaHasDensidades']['capa']);
         }
         if ($bhd[$i - 1]['BoletaHasDensidades']['ejes']) {
             array_push($ubicacion_ptos_control, $bhd[$i - 1]['BoletaHasDensidades']['ejes']);
         }
         if ($bhd[$i - 1]['BoletaHasDensidades']['otros']) {
             array_push($ubicacion_ptos_control, $bhd[$i - 1]['BoletaHasDensidades']['otros']);
         }
         if ($bhd[$i - 1]['BoletaHasDensidades']['c_norte']) {
             array_push($ubicacion_ptos_control, $bhd[$i - 1]['BoletaHasDensidades']['c_norte']);
         }
         if ($bhd[$i - 1]['BoletaHasDensidades']['c_este']) {
             array_push($ubicacion_ptos_control, $bhd[$i - 1]['BoletaHasDensidades']['c_este']);
         }
         if ($bhd[$i - 1]['BoletaHasDensidades']['elevacion']) {
             array_push($ubicacion_ptos_control, $bhd[$i - 1]['BoletaHasDensidades']['elevacion']);
         }
         $ubicacion_ptos_control = implode(', ', $ubicacion_ptos_control);
         $tcpdf->MultiCell(10, 8, 'D' . $i, 'L' . $borde, 'L', 0, 0, '', '', true, 0, false, true, 8, 'M');
         $tcpdf->MultiCell(180, 8, $ubicacion_ptos_control, 'R' . $borde, 'L', 0, 1, '', '', true, 0, false, true, 8, 'M');
     }
     //Analisis de suelos:
     $tcpdf->SetFont('arial', 'black', 7);
     $tcpdf->SetFillColor(204, 204, 204);
     $tcpdf->MultiCell(190, 2, '', 'B', 'C', 0, 1, '', '', true, 0, false, true, 2, 'M');
     $tcpdf->MultiCell(190, 4, 'ANÁLISIS DE SUELOS', 'B', 'C', 1, 1, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell($largo_muestra, 6, 'Muestra<br> <br>', 'LT', 'C', 0, 0, '', '', true, 0, true, true, 6, 'M');
     $tcpdf->MultiCell($largo_informe, 6, 'Informe<br> <br>', 'T', 'C', 0, 0, '', '', true, 0, true, true, 6, 'M');
     $tcpdf->MultiCell($largo_ensayo, 6, 'Ensayo<br> <br>', 'T', 'C', 0, 0, '', '', true, 0, true, true, 6, 'M');
     $tcpdf->MultiCell($largo_proctor, 6, $proctor, 'T', 'C', 0, 0, '', '', true, 0, true, true, 6, 'M');
     $tcpdf->MultiCell($largo_humedad_optima, 6, 'Humedad<br>Óptima (%)', 'T', 'C', 0, 0, '', '', true, 0, true, true, 6, 'M');
     $tcpdf->MultiCell($largo_densidad_min, 6, $densidad_minima, 'T', 'C', 0, 0, '', '', true, 0, true, true, 6, 'M');
     $tcpdf->MultiCell($largo_densidad_max, 6, $densidad_maxima, 'RT', 'C', 0, 1, '', '', true, 0, true, true, 6, 'M');
     //--------
     $tcpdf->SetFont('arial', '', 7);
     $contador = 0;
     $muestras = array();
     for ($i = 0; $i < 6; $i++) {
         if ($contador < 6) {
             if ($contador == 5) {
                 $borde = 'B';
             } else {
                 $borde = '';
             }
             if (!empty($bhd[$i]['ResultadosAnalisisSuelo']['id']) && !in_array($bhd[$i]['ResultadosAnalisisSuelo']['id'], $muestras)) {
                 $m = 'M' . $bhd[$i]['ResultadosAnalisisSuelo']['identificador_muestra'];
                 $dato_numero_informe = $bhd[$i]['ResultadosAnalisisSuelo']['numero_informe'];
                 $ensayo = $tipo_ensayo;
                 $dato_proctor = str_replace('.', ',', $this->punto_miles($bhd[$i]['ResultadosAnalisisSuelo']['proctor']));
                 $dato_humedad_optima = str_replace('.', ',', $bhd[$i]['ResultadosAnalisisSuelo']['humedad']);
                 $dato_dmin = $this->punto_miles($bhd[$i]['ResultadosAnalisisSuelo']['densidad_minima']);
                 $dato_dmax = $this->punto_miles($bhd[$i]['ResultadosAnalisisSuelo']['densidad_maxima']);
                 array_push($muestras, $bhd[$i]['ResultadosAnalisisSuelo']['id']);
                 //se le agrega el id de la muestra que se va a mostrar
             } else {
                 $m = '';
                 $dato_numero_informe = '';
                 $ensayo = '';
                 $dato_proctor = '';
                 $dato_humedad_optima = '';
                 $dato_dmin = '';
                 $dato_dmax = '';
             }
             $tcpdf->MultiCell($largo_muestra, 4, $this->emptyGuion($m), 'L' . $borde, 'C', 0, 0, '', '', true, 0, false, true, 4, 'M');
             $tcpdf->MultiCell($largo_informe, 4, $this->emptyGuion($dato_numero_informe), '' . $borde, 'C', 0, 0, '', '', true, 0, false, true, 4, 'M');
             $tcpdf->MultiCell($largo_ensayo, 4, $this->emptyGuion($ensayo), '' . $borde, 'C', 0, 0, '', '', true, 0, false, true, 4, 'M');
             if ($bho['DatosBoleta']['tipo_ensayo'] == 1) {
                 //densidad relativa
                 $tcpdf->MultiCell($largo_proctor, 4, '', '' . $borde, 'C', 0, 0, '', '', true, 0, false, true, 4, 'M');
             } elseif ($bho['DatosBoleta']['tipo_ensayo'] == 2) {
                 //proctor modificado
                 $tcpdf->MultiCell($largo_proctor, 4, $this->emptyGuion($dato_proctor), '' . $borde, 'C', 0, 0, '', '', true, 0, false, true, 4, 'M');
             } elseif ($bho['DatosBoleta']['tipo_ensayo'] == 3) {
                 //suelo cementado
                 $tcpdf->MultiCell($largo_proctor, 4, '', '' . $borde, 'C', 0, 0, '', '', true, 0, false, true, 4, 'M');
             } elseif ($bho['DatosBoleta']['tipo_ensayo'] == 4) {
                 //combinado
                 $tcpdf->MultiCell($largo_proctor, 4, $this->emptyGuion($dato_proctor), '' . $borde, 'C', 0, 0, '', '', true, 0, false, true, 4, 'M');
             }
             $tcpdf->MultiCell($largo_humedad_optima, 4, $this->emptyGuion($dato_humedad_optima), '' . $borde, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
             if ($bho['DatosBoleta']['tipo_ensayo'] == 1) {
                 //densidad relativa
                 $tcpdf->MultiCell($largo_densidad_min, 4, $this->emptyGuion($dato_dmin), '' . $borde, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
                 $tcpdf->MultiCell($largo_densidad_max, 4, $this->emptyGuion($dato_dmax), 'R' . $borde, 'C', 0, 1, '', '', true, 0, true, true, 4, 'M');
             } elseif ($bho['DatosBoleta']['tipo_ensayo'] == 2) {
                 //proctor modificado
                 $tcpdf->MultiCell($largo_densidad_min, 4, '', '' . $borde, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
                 $tcpdf->MultiCell($largo_densidad_max, 4, '', 'R' . $borde, 'C', 0, 1, '', '', true, 0, true, true, 4, 'M');
             } elseif ($bho['DatosBoleta']['tipo_ensayo'] == 3) {
                 //suelo cementado
                 $tcpdf->MultiCell($largo_densidad_min, 4, '', '' . $borde, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
                 $tcpdf->MultiCell($largo_densidad_max, 4, '', 'R' . $borde, 'C', 0, 1, '', '', true, 0, true, true, 4, 'M');
             } elseif ($bho['DatosBoleta']['tipo_ensayo'] == 4) {
                 //combinado
                 $tcpdf->MultiCell($largo_densidad_min, 4, $this->emptyGuion($dato_dmin), '' . $borde, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
                 $tcpdf->MultiCell($largo_densidad_max, 4, $this->emptyGuion($dato_dmax), 'R' . $borde, 'C', 0, 1, '', '', true, 0, true, true, 4, 'M');
             }
             $contador++;
         }
     }
     //---
     //empiezan encabezados
     $tcpdf->SetFont('arial', 'black', 7);
     $tcpdf->SetFillColor(204, 204, 204);
     $tcpdf->MultiCell(190, 2, '', 'B', 'C', 0, 1, '', '', true, 0, false, true, 2, 'M');
     $tcpdf->MultiCell(190, 4, 'DENSIDAD IN SITU', 'B', 'C', 1, 1, '', '', true, 0, false, true, 4, 'M');
     $tcpdf->MultiCell(10, 4, '', 'LT', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell($largo_espesor_capa, 4, 'Espesor', 'T', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell($largo_espesor_medicion, 4, 'Espesor', 'T', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell($largo_densidad_humeda, 4, 'Densidad', 'T', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell($largo_humedad, 4, 'Humedad', 'T', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell($largo_densidad_seca, 4, 'Densidad', 'T', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell($largo_dmcs, 4, $dmcs1, 'T', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     //DMCS=Densidad maxima compactada seca
     $tcpdf->MultiCell($largo_dmin + $largo_dmax, 4, $densidad1, 'T', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell($largo_densidad_relativa, 4, '', 'RT', 'C', 0, 1, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell(10, 4, '', 'L', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell($largo_espesor_capa, 4, 'Capa', '', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell($largo_espesor_medicion, 4, 'Medición', '', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell($largo_densidad_humeda, 4, 'Húmeda', '', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell($largo_humedad, 4, '', '', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell($largo_densidad_seca, 4, 'Seca', '', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell($largo_dmcs, 4, '', '', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell($largo_dmin, 4, $densidad2_1, '', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell($largo_dmax, 4, $densidad2_2, '', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell($largo_densidad_relativa, 4, $densidad_relativa, 'R', 'C', 0, 1, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell(10, 4, '', 'LB', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell($largo_espesor_capa, 4, '(m)', 'B', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell($largo_espesor_medicion, 4, '(m)', 'B', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell($largo_densidad_humeda, 4, '(g/cm<sup>3</sup>)', 'B', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell($largo_humedad, 4, '(%)', 'B', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell($largo_densidad_seca, 4, '(g/cm<sup>3</sup>)', 'B', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell($largo_dmcs, 4, $dmcs2, 'B', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell($largo_dmin, 4, $densidad3, 'B', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell($largo_dmax, 4, $densidad3, 'B', 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
     $tcpdf->MultiCell($largo_densidad_relativa, 4, '(%)', 'RB', 'C', 0, 1, '', '', true, 0, true, true, 4, 'M');
     //terminan encabezados
     $tcpdf->SetFont('arial', '', 7);
     for ($i = 1; $i <= $cantidad_densidades; $i++) {
         if ($i == 1) {
             $borde = 'T';
         } elseif ($i == $cantidad_densidades) {
             $borde = 'B';
         } else {
             $borde = '';
         }
         $tcpdf->MultiCell(10, 4, 'D' . $i, 'L' . $borde, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
         $tcpdf->MultiCell($largo_espesor_capa, 4, $this->emptyGuion(str_replace('.', ',', $bhd[$i - 1]['DensidadHasResultados'][0]['promedio'])), '' . $borde, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
         $tcpdf->MultiCell($largo_espesor_medicion, 4, $this->emptyGuion(str_replace('.', ',', $bhd[$i - 1]['DensidadHasResultados'][1]['promedio'])), '' . $borde, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
         $tcpdf->MultiCell($largo_densidad_humeda, 4, $this->emptyGuion(str_replace('.', ',', $this->punto_miles($bhd[$i - 1]['DensidadHasResultados'][2]['promedio']))), '' . $borde, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
         $tcpdf->MultiCell($largo_humedad, 4, $this->emptyGuion(str_replace('.', ',', $bhd[$i - 1]['DensidadHasResultados'][3]['promedio'])), '' . $borde, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
         $tcpdf->MultiCell($largo_densidad_seca, 4, $this->emptyGuion(str_replace('.', ',', $this->punto_miles($bhd[$i - 1]['DensidadHasResultados'][4]['promedio']))), '' . $borde, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
         if ($bho['DatosBoleta']['tipo_ensayo'] == 1) {
             //densidad relativa
             $tcpdf->MultiCell($largo_dmcs, 4, '', '' . $borde, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
         } elseif ($bho['DatosBoleta']['tipo_ensayo'] == 2) {
             //proctor modificado
             $tcpdf->MultiCell($largo_dmcs, 4, $this->emptyGuion(str_replace('.', ',', $this->punto_miles($bhd[$i - 1]['DensidadHasResultados'][5]['promedio']))), '' . $borde, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
         } elseif ($bho['DatosBoleta']['tipo_ensayo'] == 3) {
             //suelo cementado
             $tcpdf->MultiCell($largo_dmcs, 4, '', '' . $borde, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
         } elseif ($bho['DatosBoleta']['tipo_ensayo'] == 4) {
             //combinado
             $tcpdf->MultiCell($largo_dmcs, 4, $this->emptyGuion(str_replace('.', ',', $this->punto_miles($bhd[$i - 1]['DensidadHasResultados'][5]['promedio']))), '' . $borde, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
         }
         if ($bho['DatosBoleta']['tipo_ensayo'] == 1) {
             //densidad relativa
             $tcpdf->MultiCell($largo_dmin, 4, $this->emptyGuion(str_replace('.', ',', $this->punto_miles($bhd[$i - 1]['DensidadHasResultados'][7]['promedio']))), '' . $borde, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
             $tcpdf->MultiCell($largo_dmax, 4, $this->emptyGuion(str_replace('.', ',', $this->punto_miles($bhd[$i - 1]['DensidadHasResultados'][6]['promedio']))), '' . $borde, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
         } elseif ($bho['DatosBoleta']['tipo_ensayo'] == 2) {
             //proctor modificado
             $tcpdf->MultiCell($largo_dmin, 4, '', '' . $borde, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
             $tcpdf->MultiCell($largo_dmax, 4, '', '' . $borde, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
         } elseif ($bho['DatosBoleta']['tipo_ensayo'] == 3) {
             //suelo cementado
             $tcpdf->MultiCell($largo_dmin, 4, '', '' . $borde, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
             $tcpdf->MultiCell($largo_dmax, 4, '', '' . $borde, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
         } elseif ($bho['DatosBoleta']['tipo_ensayo'] == 4) {
             //combinado
             $tcpdf->MultiCell($largo_dmin, 4, $this->emptyGuion(str_replace('.', ',', $this->punto_miles($bhd[$i - 1]['DensidadHasResultados'][7]['promedio']))), '' . $borde, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
             $tcpdf->MultiCell($largo_dmax, 4, $this->emptyGuion(str_replace('.', ',', $this->punto_miles($bhd[$i - 1]['DensidadHasResultados'][6]['promedio']))), '' . $borde, 'C', 0, 0, '', '', true, 0, true, true, 4, 'M');
         }
         $tcpdf->MultiCell($largo_densidad_relativa, 4, $this->emptyGuion(round($bhd[$i - 1]['DensidadHasResultados'][8]['promedio'])), 'R' . $borde, 'C', 0, 1, '', '', true, 0, true, true, 4, 'M');
     }
     if (!empty($bho['DatosBoleta']['observaciones'])) {
         $observaciones = '<br>' . nl2br($bho['DatosBoleta']['observaciones']);
     } else {
         $observaciones = '';
     }
     //---
     $tcpdf->SetFont('arial', 'black', 7);
     $tcpdf->MultiCell(190, 8, 'Observaciones: <br>1. El control de compactación fue realizado en el sector definido por el solicitante.' . $nota . $observaciones . '', 1, 'L', 0, 1, '', '', true, 0, true, true, 8, 'M');
     //parte firmas
     $validador = $this->Validador->find('first', array('conditions' => array('id' => $bho['DatosBoleta']['validador'])));
     $firmante = $this->Firmante->find('first', array('conditions' => array('id' => $bho['DatosBoleta']['firmante'])));
     $firma1 = $this->ruta_imagenes . $validador['Validador']['ruta_firma'];
     $nombre1 = $validador['Validador']['nombre'];
     $cargo1 = $validador['Validador']['cargo'];
     $firma2 = $this->ruta_imagenes . $firmante['Firmante']['ruta_firma'];
     $nombre2 = $firmante['Firmante']['nombre'];
     $cargo2 = $firmante['Firmante']['cargo'];
     $tcpdf->SetFont('arial', 'black', 9);
     //firmante 1
     //        $tcpdf->writeHTMLCell(95, 10, 0, 269, $nombre1, 0, 0, false, true, 'C');
     //        $tcpdf->writeHTMLCell(95, 10, 0, 273, $cargo1, 0, 0, false, true, 'C');
     //        $tcpdf->Image($firma1, 30, 238, 30, 30, 'JPEG', '', '', false, 150, '', false, false, 0, false, false, false);
     //firmante 2
     $tcpdf->writeHTMLCell(95, 10, 105, 269, $nombre2, 0, 0, false, true, 'C');
     $tcpdf->writeHTMLCell(95, 10, 105, 273, $cargo2, 0, 0, false, true, 'C');
     $tcpdf->Image($firma2, 135, 238, 30, 30, 'JPEG', '', '', false, 150, '', false, false, 0, false, false, false);
     $timbre_idiem = $this->ruta_imagenes . 'timbre_centro.jpeg';
     $tcpdf->Image($timbre_idiem, 85, 240, 33, 33, 'JPEG', '', '', false, 150, '', false, false, 0, false, false, false);
     $doc_key1 = $this->randStr();
     $doc_key2 = md5($doc_key1);
     $doc_key = $doc_key1 . $doc_key2[13];
     $listo = $this->existeDocKey($doc_key);
     while (!$listo) {
         $doc_key1 = $this->randStr();
         $doc_key2 = md5($doc_key1);
         $doc_key = $doc_key1 . $doc_key2[13];
         $listo = $this->existeDocKey($doc_key);
     }
     $archivo = $doc_key . ".pdf";
     $tcpdf->SetY(-8);
     $tcpdf->SetX(-163);
     $tcpdf->SetFontSize(8);
     $tcpdf->Cell(30, 10, 'Para verificar este documento ingrese a http://repositorio.idiem.cl - Código del documento: ' . $doc_key, 0, false, 'L', 0, '', 0, false, 'T', 'M');
     if ($verificar_firma == 3 || $verificar_firma == 2) {
         //con el 3 se puede generar, si es 1 no se puede generar
         $tcpdf->Output($this->rutaFirma . date("Y") . "/" . date("m") . "/" . $archivo, "F");
         chmod($this->rutaFirma . date("Y") . "/" . date("m") . "/" . $archivo, 0777);
         $documento_anterior = $this->Documentos->find('all', array('conditions' => array('and' => array('DOC_ARCHIVO_ORIGINAL' => 'informe_densidad=' . $boleta, 'DOC_ESTADO' => 1))));
         if (!empty($documento_anterior)) {
             if ($verificar_firma == 2) {
                 $sql = '
                     Update DOCUMENTOS Set DOC_ESTADO=3,
                     DOC_FECHA_ANULACION=\'' . date('Y-m-d H:i:s') . '\',
                     DOC_TEXTO_ANULACION=\'<br> Documento anulado y reemplazado por el informe nº ' . $numeroInforme . ' (http://repositorio.idiem.cl/verifica/' . $doc_key . '). \'  
                     Where (DOC_ARCHIVO_ORIGINAL=\'informe_densidad=' . $boleta . '\') and (DOC_ESTADO=1)';
             } else {
                 $sql = '
                     Update DOCUMENTOS Set DOC_ESTADO=2
                     Where (DOC_ARCHIVO_ORIGINAL=\'informe_densidad=' . $boleta . '\') and (DOC_ESTADO=1)';
             }
             $this->Documentos->query($sql);
         }
         if ($bho['DatosBoleta']['estado'] == 0) {
             $estado = 'Provisorio';
         } elseif ($bho['DatosBoleta']['estado'] == 1) {
             $estado = 'Definitivo';
         }
         $datos_documento = array('DOC_CLI_ID' => $solicitante['DatosClientes']['DAT_CLI_ID'], 'DOC_OBR_CODIGO' => $bho['Obra']['codigo_obra'], 'DOC_ID_MODULO' => $numero_informe . '-' . $guion, 'DOC_ARCHIVO' => $archivo, 'DOC_GRU_ID' => 'idiem.hormigones_proyecto.ews', 'DOC_MODULO' => 'idiem.hormigones_tecnologia.densidad_suelo', 'DOC_KEY' => $doc_key, 'DOC_ARCHIVO_ORIGINAL' => 'informe_densidad=' . $boleta, 'DOC_FECHA' => date("Y-m-d H:i:s"), 'DOC_METADATOS' => "array('area' => '" . $bhd[0]['Area']['nombre'] . "', \n                    'subarea' => '" . $bhd[0]['SubArea']['nombre'] . "', 'num_guion'=>'" . $guion . "', " . "'tipo_ensayo'=>'Densidad de suelo', 'numero_muestra'=>'" . $boleta . "','fecha_muestreo'=>'" . $this->fechaMysql($bho['DatosBoleta']['fecha_inspeccion']) . "', 'estado'=>'" . $estado . "', 'numero_control'=>'" . $bho['DatosBoleta']['numero_control'] . "', 'facility'=>'" . $bho['DatosBoleta']['facility'] . "');");
         $this->Documentos->create();
         $this->Documentos->save($datos_documento);
         $this->redirect(array('controller' => 'suelos', 'action' => 'edit_boleta/' . $boleta), null, true);
     }
 }
Пример #3
0
 /**
  * createPdf
  *
  * @param mixed $params params
  * @param mixed $event  event
  *
  * @access public
  * @return void
  */
 function createPDF($params, $event)
 {
     App::import('Vendor', 'xtcpdf');
     $this->User = ClassRegistry::init('User');
     $this->GroupsMembers = ClassRegistry::init('GroupsMembers');
     $this->responseModelName = EvaluationResponseBase::$types[$event['Event']['event_template_type_id']];
     $this->responseModel = ClassRegistry::init($this->responseModelName);
     $epdf = new XTCPDF();
     // Construct the filename and extension
     $fileName = !empty($params['file_name']) ? $params['file_name'] . '.pdf' : date('m.d.y') . '.pdf';
     $epdf->AddPage();
     $courseName = $params['include']['course'] ? ': ' . $event['Course']['course'] : '';
     $eventName = $params['include']['eval_event_names'] ? ' - ' . $event['Event']['title'] : '';
     $headerText = '<h2>Evaluation Event Detail' . $courseName . $eventName . '</h2>';
     $epdf->writeHTML($headerText, true, false, true, false, '');
     $pageCount = 0;
     foreach ($event['GroupEvent'] as $groupEvent) {
         $grpEventId = $groupEvent['id'];
         $grpId = $groupEvent['group_id'];
         // write group/event details
         $evalDetails = $this->_writeEvalDetails($event, $grpId, $params);
         $epdf->writeHTML($evalDetails, true, false, true, false, '');
         // get incomplete/unenrolled members
         $submitted = $this->responseModel->findAllByGrpEventId($grpEventId);
         $members = Set::extract('/GroupsMembers/user_id', $this->GroupsMembers->findAllByGroupId($grpId));
         $evaluators = Set::extract('/' . $this->responseModelName . '/evaluator', $submitted);
         $evaluatees = Set::extract('/' . $this->responseModelName . '/evaluatee', $submitted);
         $inComplete = array_diff($members, $evaluators);
         $inComplete = empty($inComplete) ? array() : $this->User->getFullNames($inComplete);
         $unEnrolled = array_diff(array_unique(array_merge($evaluators, $evaluatees)), $members);
         $unEnrolled = empty($unEnrolled) ? array() : $this->User->getFullNames($unEnrolled);
         $title = !empty($inComplete) || !empty($unEnrolled) ? __('Summary', true) : '';
         $epdf->writeHTML('<br><h3>' . $title . '</h3>', true, false, true, false, '');
         $title = !empty($inComplete) ? __('Members who have not submitted their evaluations', true) : '';
         $epdf->writeHTML('<p><b>' . $title . '</b></p>', true, false, true, false, '');
         foreach ($inComplete as $name) {
             $epdf->writeHTML($name, true, false, true, false, '');
         }
         $title = !empty($unEnrolled) ? __('Left the group, but had submitted or were evaluated', true) : '';
         $epdf->writeHTML('<p><b>' . $title . '</b></p>', true, false, true, false, '');
         foreach ($unEnrolled as $name) {
             $epdf->writeHTML($name, true, false, true, false, '');
         }
         $header = '<h3>' . __('Evaluation Results', true) . '</h3><br>';
         // broke the summary table and details section into two switch blocks
         // would be more efficient if the user is filtering out sections
         if ($params['include']['grade_tables']) {
             switch ($event['Event']['event_template_type_id']) {
                 case 1:
                     $table = $this->_writeScoresTbl($event, $grpEventId, $grpId, $params);
                     break;
                 case 2:
                     $table = $this->_writeRubricResultsTbl($event, $grpEventId, $grpId, $params);
                     break;
                 case 4:
                     $table = $this->_writeMixResultsTbl($event, $grpEventId, $grpId, $params);
                     break;
             }
             if (!empty($table)) {
                 $epdf->writeHTML('<br>', true, false, true, false, '');
             }
             $epdf->writeHTML($table, true, false, true, false, '');
         }
         switch ($event['Event']['event_template_type_id']) {
             case 1:
                 $results = $params['include']['comments'] ? $this->_writeComments($grpEventId) : '';
                 $header = $params['include']['comments'] ? '<h3>' . __('Comments', true) . '</h3><br>' : '';
                 break;
             case 2:
                 $results = $this->_writeRubricEvalResults($event, $grpEventId, $grpId, $params);
                 break;
             case 4:
                 $results = $this->_writeMixEvalResults($event, $grpEventId, $grpId, $params);
                 break;
         }
         $epdf->writeHTML($header, true, false, true, false, '');
         $epdf->writeHTML($results, true, false, true, false, '');
         $epdf->lastPage();
         $epdf->addPage();
         $pageCount++;
     }
     $epdf->deletePage($epdf->getNumPages());
     if (ob_get_contents()) {
         ob_clean();
     }
     return $epdf->Output($fileName, 'I');
 }
Пример #4
0
    function payslip_update()
    {
        if ($this->request->data) {
            $this->set('employee_id', $this->request->data['SalaryRecord']['employee_id']);
            $res = $this->Employee->SalaryRecord->salarySearch($this->request->data['SalaryRecord']['employee_id'], $this->request->data['SalaryRecord']['salary_date']);
            if ($res['SalaryRecord']['payslip_generated'] != 1) {
                //debug($this->request->data);
                $earnings = $this->request->data['SalaryRecord']['basic'] + $this->request->data['SalaryRecord']['da'] + $this->request->data['SalaryRecord']['bonus'] + $this->request->data['SalaryRecord']['medical_allowance'] + $this->request->data['SalaryRecord']['tiffin'] + $this->request->data['SalaryRecord']['house_rent'] + $this->request->data['SalaryRecord']['education'] + $this->request->data['SalaryRecord']['entertainment'];
                $deductions = $this->request->data['SalaryRecord']['pf'] + $this->request->data['SalaryRecord']['esi'] + $this->request->data['SalaryRecord']['income_tax'];
                $this->request->data['SalaryRecord']['net_salary'] = $earnings - $deductions;
                $se = $this->Session->read("Auth");
                $this->request->data['SalaryRecord']['user_id'] = $se['User']['id'];
                $this->request->data['SalaryRecord']['print_copy'] = 1;
                $this->request->data['SalaryRecord']['payslip_generated'] = 1;
                //debug($this->request->data['SalaryRecord']);exit();
                if ($res['SalaryRecord']['id']) {
                    $this->Employee->SalaryRecord->id = $res['SalaryRecord']['id'];
                } else {
                    $this->Employee->SalaryRecord->create();
                }
                if ($this->Employee->SalaryRecord->save($this->request->data)) {
                    //update the loan amount
                    if ($this->request->data['SalaryRecord']['loan_amount'] > 0) {
                        $this->request->data['Loan']['loan_amount'] = $this->request->data['SalaryRecord']['loan_amount'];
                        $this->request->data['Loan']['employee_id'] = $this->request->data['SalaryRecord']['employee_id'];
                        $loan_save = $this->Employee->Loan->loanEntryUpdate($this->request->data['Loan']);
                    }
                    $this->set('salary_saved', 1);
                    $name = $this->request->data['SalaryRecord']['fname'];
                    if ($this->request->data['SalaryRecord']['mname'] != null) {
                        $name .= ' ' . $this->request->data['SalaryRecord']['mname'];
                    }
                    $name .= ' ' . $this->request->data['SalaryRecord']['lname'];
                    App::import('Vendor', 'xtcpdf');
                    $tcpdf = new XTCPDF();
                    $textfont = 'freesans';
                    // looks better, finer, and more condensed than 'dejavusans'
                    $tcpdf->SetAuthor("Company Name");
                    $tcpdf->SetAutoPageBreak(false);
                    $tcpdf->setPrintHeader(false);
                    $tcpdf->setPrintFooter(false);
                    //$tcpdf->setHeaderFont(array($textfont,'',40));
                    //$tcpdf->xheadercolor = array(0,0,0);
                    //$tcpdf->xheadertext = '';
                    //$tcpdf->xfootertext = '';
                    // add a page (required with recent versions of tcpdf)
                    $tcpdf->AddPage();
                    // Now you position and print your page content
                    // example:
                    $fill = 0;
                    $tcpdf->SetTextColor(0, 0, 0);
                    $tcpdf->SetFont($textfont, 'B', 20);
                    $header_html = '<span>Company Logo</span>';
                    $header_html2 = '<span>Company Address</span>';
                    $payslip_date = '<p style="font-size:20px!important">Playslip for the month of ' . $this->request->data['SalaryRecord']['salary_date'] . '</p>';
                    $emp_name = '<p style="font-size:20px!important">Name : ' . $name . '</p>';
                    $employee_id = '<p style="font-size:20px!important">Employee Id : emp' . $this->request->data['SalaryRecord']['employee_id'] . '</p>';
                    $department = '<p style="font-size:20px!important">Department : ' . $this->request->data['SalaryRecord']['department'] . '</p>';
                    $designation = '<p style="font-size:20px!important">Designation : ' . $this->request->data['SalaryRecord']['designation'] . '</p>';
                    $employee = $this->Employee->employeeSearch($this->request->data['SalaryRecord']['employee_id']);
                    $expected_earnings = $employee['Employee']['net_salary'] + $employee['Employee']['da'] + $employee['Employee']['bonus'] + $employee['Employee']['medical_allowance'] + $employee['Employee']['tiffin'] + $employee['Employee']['house_rent'] + $employee['Employee']['education'] + $employee['Employee']['entertainment'];
                    $expected_deductions = $employee['Employee']['pf'] + $employee['Employee']['esi'] + $employee['Employee']['income_tax'];
                    $earnings_content = '
<style>
	table{width:100%;border:none}
	th{font-size:12px;height:10px;font-size:22px!important;border-bottom:0px solid black}
	td{font-size:20px!important;width:100%;}
	.total{border-top:0px solid black}
</style>
<table>
 <tr>
  <th><b>Earnings</b></th>
 </tr>
 <tr>
 <td width="50%"></td>
  <td width="25%">Full (Rs.)</td>
  <td width="25%">Actual (Rs.)</td>
 </tr>
 <tr>
 <td width="50%">Basic</td>
  <td width="25%">' . $employee['Employee']['net_salary'] . '</td>
  <td width="25%">' . $this->request->data['SalaryRecord']['basic'] . '</td>
 </tr>
 <tr>
  <td width="50%">DA</td>
  <td width="25%">' . $employee['Employee']['da'] . '</td>
  <td width="25%">' . $this->request->data['SalaryRecord']['da'] . '</td>
 </tr>
 <tr>
  <td width="50%">Bonus</td>
  <td width="25%">' . $employee['Employee']['bonus'] . '</td>
  <td width="25%">' . $this->request->data['SalaryRecord']['bonus'] . '</td>
 </tr>
 <tr>
  <td width="50%">Medical Allowance</td>
  <td width="25%">' . $employee['Employee']['medical_allowance'] . '</td>
  <td width="25%">' . $this->request->data['SalaryRecord']['medical_allowance'] . '</td>
 </tr>
  <tr>
  <td width="50%">Tiffin Allowance</td>
  <td width="25%">' . $employee['Employee']['tiffin'] . '</td>
  <td width="25%">' . $this->request->data['SalaryRecord']['tiffin'] . '</td>
 </tr>
  <tr>
  <td width="50%">House Rent Allowance</td>
  <td width="25%">' . $employee['Employee']['house_rent'] . '</td>
  <td width="25%">' . $this->request->data['SalaryRecord']['house_rent'] . '</td>
 </tr>
 <tr>
  <td width="50%">Education Allowance</td>
  <td width="25%">' . $employee['Employee']['education'] . '</td>
  <td width="25%">' . $this->request->data['SalaryRecord']['education'] . '</td>
 </tr>
  <tr>
  <td width="50%">Entertainment Allowance</td>
  <td width="25%">' . $employee['Employee']['entertainment'] . '</td>
  <td width="25%">' . $this->request->data['SalaryRecord']['entertainment'] . '</td>
 </tr>
 <tr>
  <td width="50%"  class="total"><b>Total Earnings (Rs.) :</b></td>
  <td width="25%"  class="total"><b>' . $expected_earnings . '</b></td>
  <td width="25%"  class="total"><b>' . $earnings . '</b></td>
 </tr>
	 </table>';
                    $deductions_content = '
<style>
	table{width:100%;border:none}
	th{font-size:12px;height:10px;font-size:22px!important;border-bottom:0px solid black}
	td{font-size:20px!important;width:100%;}
	.total{border-top:0px solid black}

</style>
<table>
 <tr>
  <th><b>Deductions</b></th>
 </tr>
 <tr>
 <td width="50%"></td>
  <td width="25%">Full (Rs.)</td>
  <td width="25%">Actual (Rs.)</td>
 </tr>
 <tr>
 <td width="50%">PF</td>
  <td width="25%">' . $employee['Employee']['pf'] . '</td>
  <td width="25%">' . $this->request->data['SalaryRecord']['pf'] . '</td>
 </tr>
 <tr>
  <td width="50%">ESI</td>
  <td width="25%">' . $employee['Employee']['esi'] . '</td>
  <td width="25%">' . $this->request->data['SalaryRecord']['esi'] . '</td>
 </tr>
 <tr>
  <td width="50%">TDS</td>
  <td width="25%">' . $employee['Employee']['income_tax'] . '</td>
  <td width="25%">' . $this->request->data['SalaryRecord']['income_tax'] . '</td>
 </tr>
  <tr>
  <td width="50%">Advance</td>
  <td width="25%">0</td>
  <td width="25%">0</td>
 </tr>
  <tr>
  <td width="50%">Loan</td>
  <td width="25%">0</td>
  <td width="25%">0</td>
 </tr>
 <tr>
  <td width="50%"></td>
  <td width="25%"></td>
  <td width="25%"></td>
 </tr>
 <tr>
  <td width="50%"></td>
  <td width="25%"></td>
  <td width="25%"></td>
 </tr>
 <tr>
  <td width="50%"></td>
  <td width="25%"></td>
  <td width="25%"></td>
 </tr>
 <tr>
  <td width="50%"  class="total"><b>Total Deductions (Rs.) :</b></td>
  <td width="25%"  class="total"><b>' . $expected_deductions . '</b></td>
  <td width="25%"  class="total"><b>' . $deductions . '</b></td>
 </tr>
	 </table>';
                    $net_earnings = $earnings - $deductions;
                    $net_salary = '<p style="font-size:20px!important"><b>Net Salary : Rs. ' . $net_earnings . '</b></p>';
                    $auto_text = '<p style="font-size:22px!important;color:#cccccc">This is a computer-generated salary slip. Does not require a Signature</p>';
                    $tcpdf->SetFillColor(155, 100, 0);
                    $tcpdf->writeHTMLCell(50, 0, '', 10, $header_html, 0, 1, 0, true, 'L', true);
                    $tcpdf->writeHTMLCell(50, 0, 55, 10, $header_html2, 0, 0, 0, true, 'R', true);
                    $tcpdf->writeHTMLCell(0, 0, '', 35, $payslip_date, 0, 1, 0, true, 'L', true);
                    $tcpdf->writeHTMLCell(80, 5, '', 40, $emp_name, 'LRTB', 1, 0, true, 'C', true);
                    $tcpdf->writeHTMLCell(80, 5, 85, 40, $employee_id, 'RTB', 1, 0, true, 'C', true);
                    $tcpdf->writeHTMLCell(80, 5, '', 45, $department, 'LRB', 1, 0, true, 'C', true);
                    $tcpdf->writeHTMLCell(80, 5, 85, 45, $designation, 'RB', 1, 0, true, 'C', true);
                    $tcpdf->writeHTMLCell(80, '', '', 55, $earnings_content, 'LRTB', 1, 0, true, 'C', true);
                    $tcpdf->writeHTMLCell(80, '', 85, 55, $deductions_content, 'RTB', 1, 0, true, 'C', true);
                    $tcpdf->writeHTMLCell(155, 3, '', '', $net_salary, 'LRTB', 1, 0, true, 'L', true);
                    $tcpdf->writeHTMLCell(155, '', '', 105, $auto_text, '', 1, 0, true, 'L', true);
                    // ...
                    // etc.
                    // see the TCPDF examples
                    $file_name = time() . '.pdf';
                    echo $tcpdf->Output($file_name, 'F');
                    //setting view variables before sending email so that if email is not sent generated salry slip will still be viewed
                    $this->set('salaryrecord', $this->request->data['SalaryRecord']);
                    $this->set('employee', $employee);
                    $this->set('earnings', $earnings);
                    $this->set('deductions', $deductions);
                    $this->set('expected_earnings', $expected_earnings);
                    $this->set('net_earnings', $net_earnings);
                    App::uses('CakeEmail', 'Network/Email');
                    $Email = new CakeEmail();
                    $Email->to($this->request->data['SalaryRecord']['email']);
                    $Email->bcc($se['User']['email']);
                    $Email->subject('Salary Slip of ' . $name . ' [ emp' . $this->request->data['SalaryRecord']['employee_id'] . ' ] for ' . $this->request->data['SalaryRecord']['salary_date']);
                    $Email->replyTo($se['User']['email']);
                    $Email->from($se['User']['email']);
                    $Email->emailFormat('html');
                    $Email->viewVars(array('salary_record' => $this->request->data['SalaryRecord']));
                    $Email->attachments($file_name);
                    $Email->template('salaryslip');
                    //$Email->send();
                    App::uses('File', 'Utility');
                    $file = new File($file_name);
                    $file->delete();
                } else {
                    $this->set('salary_saved', 0);
                }
            }
        }
    }
    function sp_performance_report_pdf()
    {
        $this->layout = "pdf";
        $this->layout = "session";
        $s_society_id = $this->Session->read('society_id');
        $s_user_id = $this->Session->read('user_id');
        $date1 = $this->request->query('con');
        $date2 = $this->request->query('con2');
        $this->loadmodel('help_desk');
        $conditions = array('society_id' => $s_society_id, 'help_desk.help_desk_service_provider_id' => array('$ne' => 0));
        $result12 = $this->help_desk->find('all', array('conditions' => $conditions));
        $this->set('result_help_desk', $result12);
        App::import('Vendor', 'xtcpdf');
        $tcpdf = new XTCPDF();
        $textfont = 'freesans';
        // looks better, finer, and more condensed than 'dejavusans'
        $tcpdf->SetAuthor("KBS Homes & Properties at http://kbs-properties.com");
        $tcpdf->SetAutoPageBreak(true);
        //$tcpdf->setHeaderFont(array($textfont,'',40));
        $tcpdf->xheadercolor = array(255, 255, 255);
        $tcpdf->xheadertext = '';
        $tcpdf->xfootertext = 'HousingMatters';
        $tcpdf->AddPage();
        $tcpdf->SetTextColor(0, 0, 0);
        $tcpdf->SetFont($textfont, 'N', 12);
        $html = '
<div style="background-color:#EFEFEF; border-top:1px solid #e6e6e6; border-bottom:1px solid #e6e6e6; padding:10px; box-shadow:5px; font-size:16px; color:#006;">
Service Provider Performance Report
</div>
<br>
<table><tr><th><b>Sr No.</b></th>
<th><b>Ticket</b></th>
<th><b>Service Provider</b></th>
<th><b>Assigned Date</b></th>
<th><b>Closure Date</b></th>
<th><b>Average</b></th></tr>';
        $i = 0;
        foreach ($result12 as $data) {
            $avg = '';
            $assign_date = $data['help_desk']['help_desk_assign_date'];
            $close_date = @$data['help_desk']['help_desk_close_date'];
            $help_desk_date = $data['help_desk']['help_desk_date'];
            $sp_id = $data['help_desk']['help_desk_service_provider_id'];
            $ticket_id = $data['help_desk']['ticket_id'];
            $help_desk_date1 = date("d-m-y", strtotime($help_desk_date));
            $help_desk_date2 = date("Y-m-d", strtotime($help_desk_date1));
            $help_desk_date3 = date("d-m-Y", strtotime($help_desk_date2));
            if (!empty($assign_date) && !empty($close_date)) {
                $newDate = date("d-m-y", strtotime($assign_date));
                $newDate1 = date("Y-m-d", strtotime($newDate));
                $newDate2 = date("d-m-y", strtotime($close_date));
                $newDate3 = date("Y-m-d", strtotime($newDate2));
                $datetime1 = date_create($newDate1);
                $datetime2 = date_create($newDate3);
                $interval = date_diff($datetime1, $datetime2);
                $avg = $interval->format('%R%a days');
            }
            $sp = $this->fetch_service_provider_info_via_vendor_id($sp_id);
            foreach ($sp as $data) {
                $sp_name = $data['service_provider']['sp_name'];
            }
            if (strtotime($date1) <= strtotime($help_desk_date3) && strtotime($date2) >= strtotime($help_desk_date3)) {
                $i++;
                $html .= '
<tr>
<td>' . $i . '</td>
<td>' . $ticket_id . '</td>
<td>' . $sp_name . '</td>
<td>' . $assign_date . '</td>
<td>' . $close_date . '</td>
<td>' . $avg . '</td></tr>
';
            }
        }
        $html .= "</table>";
        $tcpdf->writeHTML($html);
        echo $tcpdf->Output('sp_report.pdf', 'D');
    }
Пример #6
0
    function registration_pdf()
    {
        $this->layout = "pdf";
        $id_pdf = $this->request->query('id_pdf');
        $this->loadModel('registration');
        $registrations = $this->registration->find('all', array('conditions' => array('id' => $id_pdf)));
        App::import('Vendor', 'xtcpdf');
        $tcpdf = new XTCPDF();
        //$textfont = 'freesans'; // looks better, finer, and more condensed than 'dejavusans'
        //$tcpdf->SetAuthor("KBS Homes & Properties at http://kbs-properties.com");
        $tcpdf->SetAutoPageBreak(true);
        //$tcpdf->setHeaderFont(array($textfont,'',40));
        $tcpdf->xheadercolor = array(255, 255, 255);
        //	$tcpdf->xheadertext = '';
        $tcpdf->xfootertext = 'DreamShapers';
        $tcpdf->AddPage();
        //$tcpdf->SetTextColor(0, 0, 0);
        $tcpdf->SetFont($textfont, 'N', 12);
        $html = '<table>
            <tr><td  style="background-color:#F1F1F1; color:rgba(28, 62, 143, 0.51);  padding-left:10%">Personal Information </td></tr>
            </table>';
        foreach ($registrations as $view_data) {
            $id = $view_data['registration']['id'];
            $name = $view_data['registration']['name'];
            $swd_of = $view_data['registration']['swd_of'];
            $p_address = $view_data['registration']['p_address'];
            $p_phone = $view_data['registration']['p_phone'];
            $fax = $view_data['registration']['fax'];
            $c_address = $view_data['registration']['c_address'];
            $phone_home = $view_data['registration']['phone_home'];
            $office = $view_data['registration']['office'];
            $mobile_no = $view_data['registration']['mobile_no'];
            $email = $view_data['registration']['email'];
            $marital_status = $view_data['registration']['marital_status'];
            $residential_status = $view_data['registration']['residential_status'];
            $nationality = $view_data['registration']['nationality'];
            $occupation = $view_data['registration']['occupation'];
            $tax_ac_no = $view_data['registration']['tax_ac_no'];
            $guest_type = $view_data['registration']['guest_type'];
            if ($guest_type == 'life time') {
                $wing_name = $view_data['registration']['wing_name'];
                $flat_no = $view_data['registration']['flat_no'];
                $floor = $view_data['registration']['floor'];
            }
            $card_id_no = $view_data['registration']['card_id_no'];
            $dob = $view_data['registration']['dob'];
            $date_of_anniversary = $view_data['registration']['date_of_anniversary'];
            $reg_type = $view_data['registration']['reg_type'];
            if ($reg_type == 'dependant') {
                $cardholder = $view_data['registration']['cardholder'];
                if (!empty($cardholder)) {
                    $cardholder = explode("-", $cardholder);
                }
            }
        }
        $html .= '			
				<br>
				<table style="line-height:5px">
				<tr><td><strong>Name &nbsp; :</strong></td><td>' . ucwords($name) . '</td></tr>
				<tr><td><strong>S/W/D of &nbsp; :</strong></td><td>' . ucwords($swd_of) . '</td></tr>
				<tr><th><strong>Permanent Adderss &nbsp; :</strong></th><td>' . ucwords($p_address) . '</td></tr>
				<tr><th><strong>Phone No. &nbsp; :</strong></th><td>' . $p_phone . '</td></tr>
				<tr><th><strong>Fax &nbsp; :</strong></th><td>' . ucwords($fax) . '</td></tr>
				<tr><th><strong>Correspondence Adderss &nbsp; :</strong></th><td>' . ucwords($c_address) . '</td></tr>
				<tr><th><strong>Phone No. (Home) &nbsp; :</strong></th><td>' . ucwords($phone_home) . '</td></tr>
				<tr><th><strong>Office &nbsp; :</strong></th><td>' . ucwords($office) . '</td></tr>
				<tr><th><strong>Mobile No.  &nbsp; :</strong></th><td>' . ucwords($mobile_no) . '</td></tr>
				<tr><th><strong>Email &nbsp; :</strong></th><td>' . $email . '</td></tr>
				
				<tr><th><strong>Marital Status :</strong></th><td>' . ucwords($marital_status) . '</td></tr>
				<tr><td><strong>Residential Status &nbsp; :</strong></td><td>' . ucwords($residential_status) . '</td></tr>
				<tr><td><strong>Nationality &nbsp; :</strong></td><td>' . ucwords($nationality) . '</td></tr>
				<tr><th><strong>Occupation &nbsp; :</strong></th><td>' . ucwords($occupation) . '</td></tr>
				<tr><th><strong>Card Id No. &nbsp; :</strong></th><td>' . $card_id_no . '</td></tr>
				<tr><th><strong>Income Tax Permanent Account No &nbsp; :</strong></th><td>' . $tax_ac_no . '</td></tr>
				<tr><th><strong>Date Of Birth &nbsp; :</strong></th><td>' . date("d-m-Y", strtotime($dob)) . '</td></tr>
				<tr><th><strong>Date of Anniversary:</strong></th><td>' . date("d-m-Y", strtotime($date_of_anniversary)) . '</td></tr>
				<tr><th><strong>Guest Type &nbsp; :</strong></th><td>' . ucwords($guest_type) . '</td></tr>
				<tr><th><strong>Registration Type &nbsp; :</strong></th><td>' . ucwords($reg_type) . '</td></tr>
				
				</table>';
        if ($guest_type == 'life time') {
            $html .= '<table width="100%" style="margin-top:1%;">
				<tr><td colspan="10" style="background-color:#F1F1F1; color:rgba(28, 62, 143, 0.51);  padding-left:10%">Details of The Flat </td></tr>
				</table>
				<table style="line-height:5px">
				
				<tr><th><strong>Wing Name &nbsp; :</strong></th><td>' . ucwords($wing_name) . '</td></tr>
				<tr><th><strong>Flat No. &nbsp; :</strong></th><td>' . ucwords($flat_no) . '</td></tr>
				<tr><th><strong>Floor &nbsp; :</strong></th><td>' . ucwords($floor) . '</td></tr>
				</table>';
        }
        if ($reg_type == 'dependant') {
            $html .= '<table width="100%" style="margin-top:1%;">
				<tr><td colspan="10" style="background-color:#F1F1F1; color:rgba(28, 62, 143, 0.51);  padding-left:10%">Name of Cardholder </td>
				<td colspan="10" style="background-color:#F1F1F1; color:rgba(28, 62, 143, 0.51); ">Relation with Applicant  </td></tr>
				</table><table style="line-height:5px">';
            foreach ($cardholder as $data_store) {
                $data_exp = explode(',', $data_store);
                $html .= '<tr><td>' . $data_exp[0] . '</td><td>' . $data_exp[1] . '</td></tr>';
            }
            $html .= '</table>';
        }
        $tcpdf->writeHTML($html);
        ob_clean();
        echo $tcpdf->Output('html.pdf', 'D');
        return $this->redirect(array('action' => 'registration_view'));
    }