<div class="modal-body">	
    <h4 class="text-center">Click the button below to generate the daily sales report and inventory system</h4>
  </div>
       <?php 
$pdf = new Pdf();
$pdf->AddPage();
$pdf->SetFont('Arial', '', 12);
$pdf->SetY(40);
$pdf->SetFont('Arial', '');
$pdf->SetY(60);
$pdf->MultiCell(0, 15, "Cashier: " . $data->get_fullname($_SESSION['id']));
$pdf->MultiCell(0, 15, "Date: " . date('F j,Y'));
$pdf->MultiCell(0, 15, "Shift: " . $_SESSION['shift']);
$y_axis_initial = 110;
$pdf->SetY($y_axis_initial);
$pdf->SetX(45);
//print column titles
$pdf->SetFillColor(252, 124, 5);
$pdf->SetLineWidth(1);
$pdf->SetFont('Arial', '', 11);
$pdf->Cell(265, 16, 'Item Name', 1, 0, 'C', 1);
$pdf->Cell(60, 16, 'Beg. In.', 1, 0, 'C', 1);
$pdf->Cell(50, 16, 'Add. In.', 1, 0, 'C', 1);
$pdf->Cell(50, 16, 'Add. Out.', 1, 0, 'C', 1);
$pdf->Cell(50, 16, 'End. In.', 1, 0, 'C', 1);
$pdf->Cell(50, 16, 'Sold', 1, 0, 'C', 1);
$row_height = 16;
$y_axis = $y_axis_initial + $row_height;
$connect = new mysqli('localhost', 'root', '', 'dsr');
$resultX = mysqli_query($connect, "SELECT * FROM particulars");
$x = 0;
Example #2
0
 public function generarPermiso()
 {
     if ($this->input->get("fechades") == '' || $this->input->get("fechahas") == '') {
         $desde = date('Y-m-d');
         $hasta = date('Y-m-d');
     } else {
         $desde = $this->input->get("fechades");
         $hasta = $this->input->get("fechahas");
     }
     $departamento = $this->input->get("departamento") != 'null' ? '=' . $this->input->get("departamento") : 'LIKE "%"';
     $motivoautorizacion = $this->input->get("motivoautorizacion") != 'null' ? '=' . $this->input->get("motivoautorizacion") : 'LIKE "%"';
     $tipoautorizacion = $this->input->get("tipoautorizacion") != 'null' ? '=' . $this->input->get("tipoautorizacion") : 'LIKE "%"';
     $pdf = new Pdf('l', 'mm', 'A4', true, 'UTF-8', false);
     $pdf->SetCreator(PDF_CREATOR);
     $pdf->SetSubject('Tutorial TCPDF');
     $pdf->SetKeywords('TCPDF, PDF, example, test, guide');
     $pdf->SetHeaderData(PDF_HEADER_LOGO, PDF_HEADER_LOGO_WIDTH1, PDF_HEADER_TITLE, PDF_HEADER_STRING);
     $pdf->setFooterData($tc = array(0, 64, 0), $lc = array(0, 64, 128));
     // datos por defecto de cabecera, se pueden modificar en el archivo tcpdf_config.php de libraries/config
     $pdf->setHeaderFont(array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
     $pdf->setFooterFont(array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));
     $pdf->SetPageOrientation('p');
     // se pueden modificar en el archivo tcpdf_config.php de libraries/config
     $pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);
     // se pueden modificar en el archivo tcpdf_config.php de libraries/config
     $pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
     $pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
     $pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
     // se pueden modificar en el archivo tcpdf_config.php de libraries/config
     $pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
     //relación utilizada para ajustar la conversión de los píxeles
     $pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
     // establecer el modo de fuente por defecto
     $pdf->setFontSubsetting(true);
     $pdf->SetFont('times', '', 9, '', true);
     $pdf->AddPage();
     $html = null;
     $nombre_archivo = null;
     $username = $this->session->userdata('datasession');
     if ($username['idusuario'] == 13) {
         $resultado2 = $this->ReporteGeneral_model->getpermisos($motivoautorizacion, $tipoautorizacion, $desde, $hasta, $departamento);
         $depa = $this->empleado_model->ReporteGeneral_model->getdptodos($departamento, $desde, $hasta);
     } else {
         $resultado2 = $this->ReporteGeneral_model->getpermisodos($motivoautorizacion, $tipoautorizacion, $username['idusuario'], $desde, $hasta);
         $depa = $this->empleado_model->buscarDepartamentoUsuario($username['cedula'], $username['nacionalidad']);
     }
     //echo json_encode($resultado2);
     if ($resultado2->num_rows() > 0) {
         foreach ($depa->result_array() as $fila2) {
             if ($username['idusuario'] == 13) {
                 $resultado = $this->ReporteGeneral_model->getpermiso($motivoautorizacion, $tipoautorizacion, $desde, $hasta, $fila2['departamento']);
             } else {
                 $resultado = $resultado2;
             }
             $pdf->SetFont('Times', 'B', 14);
             $pdf->Text(14, 25, 'Departamento: ' . $fila2['nombre']);
             $pdf->SetFont('Times', 'B', 12);
             $pdf->Text(50, 35, 'Listado de autorización(es) de empleado(s) con permiso.');
             $pdf->Ln(20);
             $pdf->Text(70, 40, 'Para la fecha: ' . $desde . ' al ' . $hasta);
             $pdf->Ln(15);
             $pdf->SetFont('times', '', 11, '', true);
             $pdf->SetFillColor('150', '210', '255');
             $pdf->Cell(20, 0, 'Cédula', 1, 0, 'C', 1);
             $pdf->Cell(50, 0, 'Nombres y Apellidos', 1, 0, 'C', 1);
             $pdf->Cell(32, 0, 'Fecha autorización', 1, 0, 'C', 1);
             $pdf->Cell(42, 0, 'Motivo de la autorización', 1, 0, 'C', 1);
             $pdf->Cell(45, 0, 'Tipo de autorización', 1, 1, 'C', 1);
             $cedemp = 'null';
             $permiso = array();
             $tot = 0;
             foreach ($resultado->result_array() as $fila) {
                 $tot = $tot + 1;
                 if ($cedemp != $fila['cedula']) {
                     if ($cedemp != 'null') {
                         $l = 1;
                         $e = 0;
                         $r = count($permiso);
                         if ($r > 3) {
                             $pdf->Cell(32, 0, $permiso[0], 1, 0, 'C', 0, '', 0);
                             while ($l < $r - 1) {
                                 if ($e != $l) {
                                     $pdf->Cell(42, 0, $permiso[$l], 1, 0, 'C', 0, '', 0);
                                     $pdf->Cell(45, 0, $permiso[$l + 1], 1, 1, 'C', 0, '', 0);
                                 } else {
                                     $l = $l + 2;
                                     if ($l < $r) {
                                         $pdf->SetX(85);
                                         $pdf->Cell(32, 0, $permiso[$l - 1], 1, 0, 'C', 0, '', 0);
                                         $pdf->Cell(42, 0, $permiso[$l], 1, 0, 'C', 0, '', 0);
                                         $pdf->Cell(45, 0, $permiso[$l + 1], 1, 1, 'C', 0, '', 0);
                                     }
                                 }
                                 $l = $l + 1;
                                 $e = $l;
                             }
                         } else {
                             $pdf->Cell(32, 0, $permiso[0], 1, 0, 'C', 0, '', 0);
                             $pdf->Cell(42, 0, $permiso[1], 1, 0, 'C', 0, '', 0);
                             $pdf->Cell(45, 0, $permiso[2], 1, 1, 'C', 0, '', 0);
                         }
                         unset($permiso);
                         $permiso = array();
                         $pdf->Cell(20, 0, $fila['cedula'], 1, 0, 'C', 0, '', 1);
                         $pdf->Cell(50, 0, $fila['nombre'] . ' ' . $fila['apellido'], 1, 0, 'C', 0, '', 1);
                         $fecha = $fila["fechaautorizacion"];
                         $motivo = $fila["motivoautorizacion"];
                         $tipo = $fila["tipoautorizacion"];
                         array_push($permiso, $fecha, $motivo, $tipo);
                         $cedemp = $fila['cedula'];
                     } else {
                         if ($tot == 1) {
                             $pdf->Cell(20, 0, $fila['cedula'], 1, 0, 'C', 0, '', 1);
                             $pdf->Cell(50, 0, $fila['nombre'] . ' ' . $fila['apellido'], 1, 0, 'C', 0, '', 1);
                             $fecha = $fila["fechaautorizacion"];
                             $motivo = $fila["motivoautorizacion"];
                             $tipo = $fila["tipoautorizacion"];
                             array_push($permiso, $fecha, $motivo, $tipo);
                             $cedemp = $fila['cedula'];
                         }
                     }
                 } else {
                     $fecha = $fila["fechaautorizacion"];
                     $motivo = $fila["motivoautorizacion"];
                     $tipo = $fila["tipoautorizacion"];
                     array_push($permiso, $fecha, $motivo, $tipo);
                 }
             }
             $l = 1;
             $e = 0;
             $r = count($permiso);
             if ($r > 3) {
                 $pdf->Cell(32, 0, $permiso[0], 1, 0, 'C', 0, '', 0);
                 while ($l < $r - 1) {
                     if ($e != $l) {
                         $pdf->Cell(42, 0, $permiso[$l], 1, 0, 'C', 0, '', 0);
                         $pdf->Cell(45, 0, $permiso[$l + 1], 1, 1, 'C', 0, '', 0);
                     } else {
                         $l = $l + 2;
                         if ($l < $r) {
                             $pdf->SetX(85);
                             $pdf->Cell(32, 0, $permiso[$l - 1], 1, 0, 'C', 0, '', 0);
                             $pdf->Cell(42, 0, $permiso[$l], 1, 0, 'C', 0, '', 0);
                             $pdf->Cell(45, 0, $permiso[$l + 1], 1, 1, 'C', 0, '', 0);
                         }
                     }
                     $l = $l + 1;
                     $e = $l;
                 }
             } else {
                 $pdf->Cell(32, 0, $permiso[0], 1, 0, 'C', 0, '', 0);
                 $pdf->Cell(42, 0, $permiso[1], 1, 0, 'C', 0, '', 0);
                 $pdf->Cell(45, 0, $permiso[2], 1, 1, 'C', 0, '', 0);
             }
             $pdf->AddPage();
         }
     } else {
         $pdf->SetFont('Times', 'B', 18);
         $pdf->Text(50, 25, 'Para la fecha: ' . $desde . ' al ' . $hasta);
         $pdf->Ln(15);
         $pdf->Text(14, 40, 'No se encuentran autorización(es) con las características indicadas.');
     }
     $pdf->Output('resumengeneral.pdf', 'I');
 }