Пример #1
0
 function agotados()
 {
     $fecha = $_REQUEST['fecha'];
     $fechaInicio = $_REQUEST['fechaInicio'];
     $fechaFinal = $_REQUEST['fechaFinal'];
     $idProducto = $_REQUEST['idProducto'];
     $repote = new Reporte();
     $ordenCompra = new Ordencompra();
     $linea = new Linea();
     $cantidadDoc = 0;
     $rutaImagen = $this->rutaImagenesProducto();
     $data = $repote->reporteAgotados($fecha, $fechaInicio, $fechaFinal, $idProducto);
     //$data=$repote->reporteAgotados('','','','');
     $unidadMedida = $this->unidadMedida();
     $cantidadData = count($data);
     for ($i = 0; $i < $cantidadData; $i++) {
         $fu = '';
         //Fecha ultima compra
         $fp = '';
         //Fecha penultima compra
         $c1 = 0;
         //Cantidad 1
         $c2 = 0;
         //Cantidad 2
         $doc = $ordenCompra->lista2UltimasCompras($data[$i]['idproducto']);
         $cantidadDoc = count($doc);
         //Data orden compra
         if ($cantidadDoc) {
             if ($cantidadDoc == 2) {
                 $fu = $doc[0]['fordencompra'];
                 $fp = $doc[1]['fordencompra'];
                 $c1 = $doc[0]['cantidadsolicitadaoc'];
                 $c2 = $doc[1]['cantidadsolicitadaoc'];
             } else {
                 $fu = $doc[0]['fordencompra'];
                 $c1 = $doc[0]['cantidadsolicitadaoc'];
             }
         }
         //><img src="'.$rutaImagen.$data[$i]['codigo'].'/'.$data[$i]['imagen'].'"></td>';
         $data[$i]['codigo'] = $data[$i]['codigop'];
         $data[$i]['nompro'] = $data[$i]['nompro'];
         $data[$i]['fechaultima'] = date("d/m/Y", strtotime($fu));
         $data[$i]['cantidadultima'] = $c1;
         $data[$i]['fechapenultima'] = date("d/m/Y", strtotime($fp));
         $data[$i]['cantidadpenultima'] = $c2;
         $data[$i]['nomlin'] = $linea->nombrexid($data[$i]['idlinea']);
     }
     $pdf = new PDF_Mc_Table("L", "mm", "A4");
     $titulos = array('Penultima', 'C.Penul', 'Ultima', 'C. Ultima', 'codigo', 'Descripcion', 'Sublinea');
     $columnas = array('fechapenultima', 'cantidadpenultima', 'fechaultima', 'cantidadultima', 'codigo', 'nompro', 'nomlin');
     $ancho = array(20, 15, 25, 18, 22, 110, 70);
     $orientacion = array('C', 'C', 'C', 'C', 'C', '', '');
     $pdf->_titulo = "Reporte de Agotados";
     $pdf->AddPage();
     $relleno = true;
     $pdf->SetFillColor(202, 232, 234);
     $pdf->SetTextColor(12, 78, 139);
     $pdf->SetDrawColor(12, 78, 139);
     $pdf->SetLineWidth(0.3);
     $pdf->SetFont('Helvetica', 'B', 8);
     $pdf->fill($relleno);
     //un arreglo con su medida  a lo ancho
     $pdf->SetWidths($ancho);
     $valor = "Reporte de Ventas";
     $pdf->titlees($valor);
     //un arreglo con alineacion de cada celda
     $pdf->SetAligns($orientacion);
     for ($i = 0; $i < count($titulos); $i++) {
         $pdf->Cell($ancho[$i], 7, $titulos[$i], 1, 0, 'C', true);
     }
     $pdf->Ln();
     $pdf->SetFillColor(224, 235, 255);
     $pdf->SetTextColor(0);
     $pdf->SetFont('');
     for ($i = 0; $i < $cantidadData; $i++) {
         $fila = array($data[$i]['fechapenultima'], $data[$i]['cantidadpenultima'], utf8_decode($data[$i]['fechaultima']), $data[$i]['cantidadultima'], $data[$i]['codigo'], utf8_decode($data[$i]['nompro']), $data[$i]['nomlin']);
         $pdf->Row($fila);
         $relleno = !$relleno;
         $pdf->fill($relleno);
     }
     $pdf->AliasNbPages();
     $pdf->Output();
 }
Пример #2
0
 function agotados()
 {
     if (count($_REQUEST) == 6) {
         $linea = new Linea();
         $almacen = new Almacen();
         $data['Linea'] = $linea->listadoLineas('idpadre=0');
         $data['Almacen'] = $almacen->listadoAlmacen();
         $this->view->show('/reporte/agotados.phtml', $data);
     } else {
         if (!empty($_REQUEST['fecha'])) {
             $fecha = date('d-m-Y', strtotime($_REQUEST['fecha']));
         }
         if (!empty($_REQUEST['fechaInicio'])) {
             $fechaInicio = date('d-m-Y', strtotime($_REQUEST['fechaInicio']));
         }
         if (!empty($_REQUEST['fechaFinal'])) {
             $fechaFinal = date('d-m-Y', strtotime($_REQUEST['fechaFinal']));
         }
         $idProducto = $_REQUEST['idProducto'];
         $repote = new Reporte();
         $ordenCompra = new Ordencompra();
         $linea = new Linea();
         //$rutaImagen=$this->rutaImagenesProducto();
         $data = $repote->reporteAgotados($fecha, $fechaInicio, $fechaFinal, $idProducto);
         //$data=$repote->reporteAgotados('','','','');
         $unidadMedida = $this->unidadMedida();
         for ($i = 0; $i < count($data); $i++) {
             $fu = '';
             //Fecha ultima compra
             $fp = '';
             //Fecha penultima compra
             $c1 = 0;
             //Cantidad 1
             $c2 = 0;
             //Cantidad 2
             $doc = $ordenCompra->lista2UltimasCompras($data[$i]['idproducto']);
             //Data orden compra
             $cantidadDoc = count($doc);
             if ($cantidadDoc) {
                 if ($cantidadDoc == 2) {
                     $fu = $doc[0]['fordencompra'];
                     $fp = $doc[1]['fordencompra'];
                     $c1 = $doc[0]['cantidadsolicitadaoc'];
                     $c2 = $doc[1]['cantidadsolicitadaoc'];
                 } else {
                     $fu = $doc[0]['fordencompra'];
                     $c1 = $doc[0]['cantidadsolicitadaoc'];
                 }
             }
             //><img src="'.$rutaImagen.$data[$i]['codigo'].'/'.$data[$i]['imagen'].'"></td>';
             $arreglo[$i]['codigo'] = $data[$i]['codigop'];
             $arreglo[$i]['nompro'] = $data[$i]['nompro'];
             $arreglo[$i]['fechaultima'] = date("d/m/Y", strtotime($fu));
             $arreglo[$i]['cantidadultima'] = $c1;
             $arreglo[$i]['fechapenultima'] = date("d/m/Y", strtotime($fp));
             $arreglo[$i]['cantidadpenultima'] = $c2;
             $arreglo[$i]['nomlin'] = $linea->nombrexid($data[$i]['idlinea']);
         }
         $dataAgotados = $this->formatearparakui($arreglo);
         header("Content-type: application/json");
         echo json_encode($dataAgotados);
     }
 }