コード例 #1
0
 public function guardar_ncf($idempresa, $factura, $tipo_comprobante, $numero_ncf, $motivo = false)
 {
     if ($numero_ncf['NCF'] == 'NO_DISPONIBLE') {
         return $this->new_error_msg('No hay números NCF disponibles del tipo ' . $tipo_comprobante . ', la factura ' . $factura->idfactura . ' se creo sin NCF.');
     } else {
         $ncf_factura = new ncf_ventas();
         $ncf_factura->idempresa = $idempresa;
         $ncf_factura->codalmacen = $factura->codalmacen;
         $ncf_factura->entidad = $factura->codcliente;
         $ncf_factura->cifnif = $factura->cifnif;
         $ncf_factura->documento = $factura->idfactura;
         $ncf_factura->fecha = $factura->fecha;
         $ncf_factura->tipo_comprobante = $tipo_comprobante;
         $ncf_factura->ncf = $numero_ncf['NCF'];
         $ncf_factura->usuario_creacion = $this->user->nick;
         $ncf_factura->fecha_creacion = Date('d-m-Y H:i:s');
         $ncf_factura->estado = TRUE;
         if ($factura->idfacturarect) {
             $ncf_orig = new ncf_ventas();
             $val_ncf = $ncf_orig->get_ncf($this->empresa->id, $factura->idfacturarect, $factura->codcliente);
             $ncf_factura->documento_modifica = $factura->idfacturarect;
             $ncf_factura->ncf_modifica = $val_ncf->ncf;
             $ncf_factura->motivo = $motivo;
         }
         if (!$ncf_factura->save()) {
             return $this->new_error_msg('Ocurrió un error al grabar la factura ' . $factura->idfactura . ' con el NCF: ' . $numero_ncf['NCF'] . ' Anule la factura e intentelo nuevamente.');
         } else {
             $this->ncf_rango->update($ncf_factura->idempresa, $ncf_factura->codalmacen, $numero_ncf['SOLICITUD'], $numero_ncf['NCF'], $this->user->nick);
         }
     }
 }
コード例 #2
0
 public function dgii608()
 {
     $facturas = new ncf_ventas();
     $this->resultados_608 = $facturas->all_anulado_desde_hasta($this->empresa->id, \date("Y-m-d", strtotime($this->fecha_inicio)), \date("Y-m-d", strtotime($this->fecha_fin)));
     $this->total_resultados_608 = count($this->resultados_608);
 }
コード例 #3
0
 public function procesar_facturas($valores_id, $archivo = FALSE)
 {
     if (!empty($valores_id)) {
         if (ob_get_status()) {
             ob_end_clean();
         }
         $pdf_doc = new PDF_MC_Table('P', 'mm', 'letter');
         $pdf_doc->SetTitle('Facturas de Venta');
         $pdf_doc->SetSubject('Facturas de Venta para clientes');
         $pdf_doc->SetAuthor($this->empresa->nombre);
         $pdf_doc->SetCreator('FacturaSctipts V_' . $this->version());
         $this->archivo = $archivo;
         $contador = 0;
         $this->factura = FALSE;
         foreach ($valores_id as $id) {
             $factura = new factura_cliente();
             $this->factura = $factura->get($id);
             if ($this->factura) {
                 $ncf_datos = new ncf_ventas();
                 $valores = $ncf_datos->get_ncf($this->empresa->id, $this->factura->idfactura, $this->factura->codcliente, $this->factura->fecha);
                 $ncf_tipo = new ncf_tipo();
                 $tipo_comprobante = $ncf_tipo->get($valores->tipo_comprobante);
                 $this->factura->ncf = $valores->ncf;
                 $this->factura->ncf_afecta = $valores->ncf_modifica;
                 $this->factura->estado = $valores->estado;
                 $this->factura->tipo_comprobante = $tipo_comprobante->descripcion;
                 if ($this->distrib_transporte) {
                     $transporte = $this->distrib_transporte->get($this->empresa->id, $this->factura->idfactura, $this->factura->codalmacen);
                     $this->idtransporte = isset($transporte[0]->idtransporte) ? str_pad($transporte[0]->idtransporte, 10, "0", STR_PAD_LEFT) : false;
                 }
                 $cliente = new cliente();
                 $this->cliente = $cliente->get($this->factura->codcliente);
                 $this->generar_pdf($pdf_doc);
                 $contador++;
             }
         }
         // Damos salida al archivo PDF
         if ($this->archivo) {
             if (!file_exists('tmp/' . FS_TMP_NAME . 'enviar')) {
                 mkdir('tmp/' . FS_TMP_NAME . 'enviar');
             }
             $pdf_doc->Output('tmp/' . FS_TMP_NAME . 'enviar/' . $archivo, 'F');
         } else {
             $pdf_doc->Output();
         }
         if (!$this->factura) {
             $this->new_error_msg("¡Factura de cliente no encontrada!");
         }
     }
 }