#include #include #include #include #include #include #include #include #include "c:\program\src_dos\libs\make_bot\make_bot.h" #include "c:\program\src_dos\libs\bdatos\bdatos.hh" #include "tpv_def.h" #define NLineas_PVendidos 16 BDatos B_IVentas1; // Archivo de Ventas 1 de 3 ( Datos Globales ) BDatos B_IVentas2; // Archivo de Ventas 2 de 3 ( Productos Vendidos ) BDatos B_IVentas3; // Archivo de Ventas 3 de 3 ( Ventas Empleados ) INFORME1_VENTAS S_IVentas1; // Datos Generales ( 1 de 3 ) INFORME2_VENTAS S_IVentas2; // Productos Vendidos ( 2 de 3 ) INFORME3_VENTAS S_IVentas3; // Ventas Empleados ( 3 de 3 ) extern BDatos BVentas; // Base de datos de Ventaserencias extern VENTAS SVentas[100]; // 100 productos ( distintos ) maximo por ticket // Datos sobre la venta del dia extern INFORMACION_VENTAS S_IVentas; extern char EmpresaActual[9]; // Empresa a la que se le realizan las gestiones extern BDatos BCmp; // Base de datos de Cmperencias extern COMPRAS SCmp; // Estructura de referencias extern long RegCompras[31 + 2];// Indice para cado uno de los dias del mes + 2 extern BDatos BEmpl; // Base de datos de Empleados extern INFO_EMPLEADOS SEmpl; // Estructura de Empleados extern BDatos BProv; // Base de datos de Proveedores extern INFO_PROVEEDORES SProv; // Estructura de Proveedores extern BDatos BRef; // Base de datos de Referencias extern INFO_PRODUCTOS SRef; // Estructura de referencias // Para guardar las posiciones de los c¢digos extern BUSQUEDA_REF far *BusquedaRef; extern struct date FechaGestionActual; // Dia y mes actual para la gestion extern char DiaActual, MesActual; extern char AjusteCalendario; // Ajuste para los dias del calendario extern char DiasMes; // Dias que tiene el mes actual char TablaHoraria[24]; // Tabla horaria de ventas /*************************************\ | | | M¢dulo de muestro del Balance | | | \*************************************/ void DespliegaCalendario( void ); void MuestraDatosVentas( char DiaBalance ); long SumaGastosCompras( char DiaSuma, char MesSuma ); char MuestraBalanceDiario( char DiaBalance, char MesActual ); void MuestraVentasEmpleados( long Pagina, char DiaMostrar ); void MuestraProductosVendidos( long Pagina, char DiaMostrar ); void ImprimeBalance( char DiaMes, char DiaMostrar ); /*************************************\ | | | Parte de enlace de gestion | | | | Secci¢n para generar el balance | | | | Enlaces, a TPV_VENT.CPP | | | \*************************************/ void MuestraHoraVenta( void ); void GeneraBalanceDiario( void ); void ConstruyeTablaHoraria( void ); int MatchVendedor( long CodigoVendedor ); void NuevoRegistroInforme1( INFORME1_VENTAS *S_IVentas1 ); void NuevoRegistroInforme2( INFORME2_VENTAS *S_IVentas2 ); void NuevoRegistroInforme3( INFORME3_VENTAS *S_IVentas3 ); int ActualizaDatosGlobales( void ); void ActualizaVentasProductos( char DiaGestion, char HoraVenta ); void ActualizaVentasEmpleados( char DiaGestion, char MesGestion ); /*************************************\ | | | Parte Cuarta del M¢dulo | | | | Secci¢n para cargar los elementos | | | | Enlaces, a TPV_VENT.CPP | | | \*************************************/ extern int PosicionDia( char Dia ); extern int CargaProductos( void ); extern int MatchRef( unsigned long Codigo, char NormalBarras ); extern int P_Sec(int numero); extern void RellenaCalendario( int IncX, int IncY ); extern void MarcaDiaActual( int Sec, int Boton, char como ); unsigned long GastosCompras; // Gastos del dia a evaluar unsigned long GastosComprasD[32]; unsigned long VentasD[32]; char HoraMostrar; // Hora "codificada" a mostrar // Linea de productos vendidos unsigned int CurrProductosVendidos = 0; // Linea de productos vendidos unsigned int CurrProductosEmpleados = 0; void GraficaMostrada( int grafica ); // ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß // Û Parte principal del m¢dulo Û // ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ /**************************************************************************\ |* *| |* ConfigurarMensajes *| |* *| |* Descripci¢n: *| |* Gestiona los mensajes que se mostraran en el protector *| |* *| |* Entradas: (ninguna) *| |* Salidas: (ninguna) *| |* *| \**************************************************************************/ void BalanceDiario_Mensual( char DiarioMensual ) { char ok, BPush; // Dia y mes de balance a gestionar char old_DiaActual, i; char old_MesActual; char CurrGraf; char MES[12+1][15] = {"","Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"}; char buffer[80]; CurrProductosVendidos = 0; // Linea de productos vendidos CurrProductosEmpleados = 0; // Linea de productos vendidos // Rellenamos la pantalla con un fondo atractivo... setfillstyle( Config.FillBgS, Config.FillBgC ); bar( 0, 0, 640, 480 ); old_DiaActual = DiaActual = FechaGestionActual.da_day; old_MesActual = MesActual = FechaGestionActual.da_mon; // Calculamos los dias que tiene el mes y el ajuste necesario CalculaAjusteDias( &AjusteCalendario, &DiasMes, MesActual, FechaGestionActual.da_year ); HoraMostrar = -1; if ( MuestraBalanceDiario( ( DiarioMensual == DIARIO ? DiaActual : -1 ), MesActual ) == 1 ) { for ( i = 12; i > 0; i-- ) { sprintf( buffer, "datos\\%s\\VT1-%04d.M%02d", NEmpresa, FechaGestionActual.da_year, i ); // Miramos si este mes est  inicializado if ( access( buffer, 0) == 0 ) { MesActual = i; break; } } sprintf( buffer, "datos\\%s\\VT1-%04d.M%02d", NEmpresa, FechaGestionActual.da_year, i ); if ( access( buffer, 0) != 0 ) return; sprintf( buffer, "mes de: %s", MES[MesActual] ); Optar( 0, "ACCEDIENDO A OTRO MES", "Se ha movido el acceso al", buffer, NULL ); MuestraBalanceDiario( ( DiarioMensual == DIARIO ? DiaActual : -1 ), MesActual ); } ok = 0; CurrGraf = 0; do { BPush = Comprueba_Secuencia( 9, NULL ); switch ( BPush ) { case -2: while( kbhit() ) getch(); break; case -1: while( kbhit() ) getch(); break; case 0: while( kbhit() ) getch(); break; // Imprimir case 1: ImprimeBalance( DiarioMensual, ( DiarioMensual == DIARIO ? DiaActual : -1 ) ); break; // Dia / Mes a visionar case 2: if ( DiarioMensual == DIARIO ) { old_DiaActual = DiaActual; old_MesActual = MesActual; DespliegaCalendario(); if ( MuestraBalanceDiario( DiaActual, MesActual ) == 1 ) { DiaActual = old_DiaActual; MesActual = old_MesActual; MuestraBalanceDiario( DiaActual, MesActual ); } } else { old_DiaActual = DiaActual; old_MesActual = MesActual; DespliegaCalendario(); // Calculamos los dias que tiene el mes y el ajuste necesario CalculaAjusteDias( &AjusteCalendario, &DiasMes, MesActual, FechaGestionActual.da_year ); if ( MuestraBalanceDiario( -1, MesActual ) == 1 ) { DiaActual = old_DiaActual; MesActual = old_MesActual; // Calculamos los dias que tiene el mes y el ajuste necesario CalculaAjusteDias( &AjusteCalendario, &DiasMes, MesActual, FechaGestionActual.da_year ); MuestraBalanceDiario( -1, MesActual ); } } break; // Menu Principal case 3: ok = 1; break; // Notas case 4: if ( DiarioMensual == DIARIO ) { if ( VisualMode == ERROR ) { settextstyle( SMALL_FONT, HORIZ_DIR, 5 ); EditComentario( (char *)(&S_IVentas1.Notas[0][0]), 6, 50, Config.TxtBgN, Config.TxtFgN, 34, 369, 446, 471, 15 ); // leemos los datos de este dia B_IVentas1.EscribeReg( (void *)&S_IVentas1, ( DiaActual - 1 ) ); setfillstyle( SOLID_FILL, Config.TxtBgN ); bar( 34, 369, 446, 471 ); setcolor ( Config.TxtFgN ); for ( i = 0; i < 7; i++ ) outtextxy( 32+2, 367 + 15*i , S_IVentas1.Notas[i] ); } } else { CurrGraf++; if ( CurrGraf > 2 ) CurrGraf = 0; GraficaMostrada( CurrGraf ); } break; // Empleados: pagina anterior case 5: MuestraVentasEmpleados( -1, ( DiarioMensual == DIARIO ? DiaActual : -1 ) ); break; // Empleados: pagina posterior case 6: MuestraVentasEmpleados( 1, ( DiarioMensual == DIARIO ? DiaActual : -1 ) ); break; // Productos: pagina anterior case 7: MuestraProductosVendidos( -1, ( DiarioMensual == DIARIO ? DiaActual : -1 ) ); break; // Productos: pagina posterior case 8: MuestraProductosVendidos( 1, ( DiarioMensual == DIARIO ? DiaActual : -1 ) ); break; // Horas de ventas a visualizar case 9: if ( DiarioMensual == DIARIO ) { HoraMostrar++; if ( HoraMostrar == 6 ) HoraMostrar = -1; MuestraHoraVenta(); MuestraProductosVendidos( 0, DiaActual ); } break; } } while ( !ok ); B_IVentas1.CerrarReg(); B_IVentas2.CerrarReg(); B_IVentas3.CerrarReg(); } /**************************************************************************\ |* *| |* MuestraHoraVenta *| |* *| |* Descripci¢n: *| |* Muestra en pantalla las cotas de horas de ventas a mostrar *| |* *| |* Entradas: *| |* *| |* Salidas: (ninguna) *| |* *| \**************************************************************************/ void MuestraHoraVenta( void ) { char buffer[80]; settextstyle( SMALL_FONT, HORIZ_DIR, 5 ); setfillstyle( SOLID_FILL, Config.TxtBgN ); bar( 82, 24, 108, 38 ); bar( 177, 24, 203, 38 ); setcolor ( Config.TxtFgN ); if ( HoraMostrar == -1 ) sprintf( buffer, " þþ" ); else sprintf( buffer, "%02d", S_IVentas1.Hora[HoraMostrar] ); outtextxy( 82, 24, buffer ); if ( HoraMostrar == -1 ) sprintf( buffer, " þþ" ); else sprintf( buffer, "%02d", S_IVentas1.Hora[(HoraMostrar + 1)%6] ); outtextxy( 177, 24, buffer ); } /**************************************************************************\ |* *| |* MuestraProductosVendidos *| |* *| |* Descripci¢n: *| |* Redibuja toda la pantalla, y muestra el balance del dia *| |* que se le pasa como par metro... *| |* *| |* *| |* Entradas: Dia y mes a mostrar *| |* *| |* Salidas: (ninguna) *| |* *| \**************************************************************************/ char MuestraBalanceDiario( char DiaActual, char MesActual ) { static char ArchivoAbierto = ERROR; char buffer[80], i; // Rellenamos la pantalla con un fondo atractivo... setfillstyle( Config.FillBgS, Config.FillBgC ); bar( 0, 0, 640, 480 ); // Borramos toda la pantalla Imprime_Estaticos( ( DiaActual != -1 ? 60 : 61 ), "systm\\Tpv.img"); // Imprime botones estaticos 'Seccion 1' if ( DiaActual != -1 ) MuestraHoraVenta(); // Archivo de datos generales ( 1 de 3 ) sprintf( buffer, "datos\\%s\\VT1-%04d.M%02d", NEmpresa, FechaGestionActual.da_year, MesActual ); // Miramos si este mes est  inicializado if ( access( buffer, 0) != 0 ) { Optar( 0, "ERROR DE ACCESO", "Este mes no tiene ventas", "venda algo, para acceder.", "­­­ No hay ventas !!!", NULL ); return 1; } if ( ArchivoAbierto == OK ) { B_IVentas1.CerrarReg(); B_IVentas2.CerrarReg(); B_IVentas3.CerrarReg(); ArchivoAbierto = ERROR; } if ( B_IVentas1.AbrirReg( buffer, sizeof( INFORME1_VENTAS ) ) == ERROR ) Error( 0x01, "Imposible abrir archivo, Ventas diarias 1 de 3" ); // Archivo de productos vendidos ( 2 de 3 ) sprintf( buffer, "datos\\%s\\VT2-%04d.M%02d", NEmpresa, FechaGestionActual.da_year, MesActual ); if ( B_IVentas2.AbrirReg( buffer, sizeof( INFORME2_VENTAS ) ) == ERROR ) Error( 0x01, "Imposible abrir archivo, Ventas diarias 2 de 3" ); // Archivo de ventas por empleados ( 3 de 3 ) sprintf( buffer, "datos\\%s\\VT3-%04d.M--", NEmpresa, FechaGestionActual.da_year/*, MesActual*/ ); if ( B_IVentas3.AbrirReg( buffer, sizeof( INFORME3_VENTAS ) ) == ERROR ) Error( 0x01, "Imposible abrir archivo, Ventas diarias 3 de 3" ); ArchivoAbierto = OK; // El balance diario ya est  hecho, asi que solo tenemos que: // - Rastrear las compras del dia de balance a evaluar GastosCompras = 0; if ( DiaActual != -1 ) { GastosCompras = SumaGastosCompras( DiaActual, MesActual ); } else { for ( i = 1; i <= DiasMes && i <= 31; i++ ) { GastosComprasD[i] = SumaGastosCompras( i, MesActual ); GastosCompras += GastosComprasD[i]; } } // - mostar datos sobre las ventas, incluyendo el comentario MuestraDatosVentas( DiaActual ); // - listar los productos vendidos MuestraProductosVendidos( 0, DiaActual ); // - listar ventas por empleados MuestraVentasEmpleados( 0, DiaActual ); if ( DiaActual == -1 ) GraficaMostrada( 0 ); /* // Una vez cargado sus datos, ya no necesita seguir abierto B_IVentas1.CerrarReg(); */ return 0; } /**************************************************************************\ |* *| |* SumaGastosCompras *| |* *| |* Descripci¢n: *| |* Suma todos los gastos del mes y dia que se le pasan *| |* como par metros... *| |* *| |* *| |* Entradas: Dia y mes a sumar *| |* *| |* Salidas: La suma total de compras *| |* *| \**************************************************************************/ long SumaGastosCompras( char DiaSuma, char MesSuma ) { long SumaTotal, i; char buffer[80]; // ¨ Que archivo hay que abrir ? sprintf( buffer, "datos\\%s\\Cmp-%04d.M%02d", NEmpresa, FechaGestionActual.da_year, MesSuma ); // Si no existe el archivo; NO HAY GASTOS if ( access( buffer, 0 ) != 0 ) return 0; // Abrimos el archivo if ( BCmp.AbrirReg( buffer, sizeof( COMPRAS ) ) == ERROR ) Error(0x01, BCmp.cError ); // Recuperamos los datos de usuario BCmp.CargaDatosUsuario( (void *)&RegCompras, sizeof(long)*32 ); SumaTotal = 0; for ( i=0; i < RegCompras[ DiaSuma ]; i++ ) { BCmp.LeeReg( (void *)&SCmp, i + PosicionDia( DiaSuma ) ); SumaTotal += SCmp.PrecioCosto /** SCmp.Cantidad*/; } BCmp.CerrarReg(); return SumaTotal; } /**************************************************************************\ |* *| |* MuestraDatosVentas *| |* *| |* Descripci¢n: *| |* Muestra los datos generales del dia que se le pasa *| |* como parametro... *| |* *| |* *| |* Entradas: Dia a mostrar *| |* *| |* Salidas: (ninguna) *| |* *| \**************************************************************************/ void MuestraDatosVentas( char DiaActual ) { char buffer[80], buffer1[80]; char i, j; INFORME1_VENTAS S_IVentasTmp; long AperturaCajaTemph, AperturaCajaTempm, CierreCajaTemph, CierreCajaTempm; if ( DiaActual != -1 ) { // leemos los datos de este dia B_IVentas1.LeeReg( (void *)&S_IVentas1, ( DiaActual - 1 ) ); } else { j = 0; NuevoRegistroInforme1( &S_IVentas1 ); for ( i=0; i < DiasMes; i++ ) { B_IVentas1.LeeReg( (void *)&S_IVentasTmp, i ); S_IVentas1.Tickets += S_IVentasTmp.Tickets; S_IVentas1.Cambio += S_IVentasTmp.Cambio; S_IVentas1.IntentosSalir += S_IVentasTmp.IntentosSalir; S_IVentas1.SalidasExito += S_IVentasTmp.SalidasExito; S_IVentas1.TotalVentas += S_IVentasTmp.TotalVentas; S_IVentas1.CosteTotal += S_IVentasTmp.CosteTotal; VentasD[i] = S_IVentasTmp.TotalVentas; if ( S_IVentasTmp.AperturaCaja.hora != -1 ) { AperturaCajaTemph += S_IVentasTmp.AperturaCaja.hora; AperturaCajaTempm += S_IVentasTmp.AperturaCaja.min; CierreCajaTemph += S_IVentasTmp.CierreCaja.hora; CierreCajaTempm += S_IVentasTmp.CierreCaja.min; j ++; } } if ( j > 0 ) { S_IVentas1.AperturaCaja.hora = AperturaCajaTemph / j; S_IVentas1.AperturaCaja.min = AperturaCajaTempm / j; S_IVentas1.CierreCaja.hora = CierreCajaTemph / j; S_IVentas1.CierreCaja.min = CierreCajaTempm / j; } } settextstyle( SMALL_FONT, HORIZ_DIR, 5 ); // # de tickets emitidos hoy / mensuales formatea_long( (long)S_IVentas1.Tickets, buffer1 ); sprintf( buffer, " %6s", buffer1 ); TextoDoble( 245, 5, buffer ); // # de cambio / mensuales formatea_long( (long)S_IVentas1.Cambio, buffer1 ); sprintf( buffer, " %6s", buffer1 ); TextoDoble( 245, 20, buffer ); // # intentos de salir / mensuales formatea_long( (long)S_IVentas1.IntentosSalir, buffer1 ); sprintf( buffer, " %6s", buffer1 ); TextoDoble( 245, 35, buffer ); // # salidas con exito / mensuales formatea_long( (long)S_IVentas1.SalidasExito, buffer1 ); sprintf( buffer, " %6s", buffer1 ); TextoDoble( 245, 50, buffer ); // Inicio de la caja / media sprintf( buffer, " %02d:%02d", S_IVentas1.AperturaCaja.hora, S_IVentas1.AperturaCaja.min ); TextoDoble( 245, 65, buffer ); // Cierre de la caja / media sprintf( buffer, " %02d:%02d", S_IVentas1.CierreCaja.hora, S_IVentas1.CierreCaja.min ); TextoDoble( 245, 80, buffer ); if ( DiaActual != -1 ) { // Horas de venta y Total vendido por horas for ( i = 0; i < 6; i++ ) { formatea_long( (long)S_IVentas1.TotalVendido[i], buffer1 ); sprintf( buffer, " %2d:00 - %2d:00 %8s", S_IVentas1.Hora[i], S_IVentas1.Hora[(i+1)%6], buffer1 ); TextoDoble( 245, 110 + 20*i, buffer ); } // Total vendido formatea_long( (long)S_IVentas1.TotalVentas, buffer1 ); sprintf( buffer, " %7s", buffer1 ); TextoDoble( 245, 290, buffer ); // Gastos/Compras totales formatea_long( (long)GastosCompras, buffer1 ); sprintf( buffer, " %7s", buffer1 ); TextoDoble( 245, 310, buffer ); // Beneficio bruto formatea_long( (long)( S_IVentas1.TotalVentas - GastosCompras ), buffer1 ); sprintf( buffer, " %7s", buffer1 ); TextoDoble( 245, 335, buffer ); // Comentario setfillstyle( SOLID_FILL, Config.TxtBgN ); bar( 34, 369, 446, 471 ); setcolor ( Config.TxtFgN ); for ( i = 0; i < 7; i++ ) outtextxy( 32+2, 367 + 15*i , S_IVentas1.Notas[i] ); } else { // Total Ventas formatea_long( (long)( S_IVentas1.TotalVentas ), buffer1 ); sprintf( buffer, " %9s", buffer1 ); TextoDoble( 245, 120, buffer ); // Total Gastos formatea_long( (long)( GastosCompras ), buffer1 ); sprintf( buffer, " %9s", buffer1 ); TextoDoble( 245, 140, buffer ); // Beneficio Bruto formatea_long( (long)( S_IVentas1.TotalVentas - GastosCompras ), buffer1 ); sprintf( buffer, " %9s", buffer1 ); TextoDoble( 245, 180, buffer ); // Beneficio Neto formatea_long( (long)( S_IVentas1.TotalVentas - GastosCompras - S_IVentas1.CosteTotal ), buffer1 ); sprintf( buffer, " %9s", buffer1 ); TextoDoble( 245, 200, buffer ); } } /**************************************************************************\ |* *| |* MuestraVentasEmpleados *| |* *| |* Descripci¢n: *| |* Muestra una lista con los vendedores que han vendido algo *| |* en el dia actual, empezando por el registro dado *| |* *| |* *| |* Entradas: Pagina a mostrar: 0 primera -1 anterior 1 siguiente *| |* Dia a tratar *| |* *| |* Salidas: (ninguna) *| |* *| \**************************************************************************/ void MuestraVentasEmpleados( long Pagina, char DiaMostrar ) { #ifndef DEMOSTRACION #else Optar( 0, "VERSION DEMOSTRACION", "En esta versi¢n no se", "permite ver las ventas", "de cada empleado...", NULL ); #endif } /**************************************************************************\ |* *| |* MuestraProductosVendidos *| |* *| |* Descripci¢n: *| |* Muestra una lista con los productos vendidos ( segun hora *| |* de muestreo ). *| |* *| |* *| |* Entradas: Pagina a mostrar: 0 primera -1 anterior 1 siguiente *| |* Dia y mes tratar *| |* *| |* Salidas: (ninguna) *| |* *| \**************************************************************************/ void MuestraProductosVendidos( long Pagina, char DiaMostrar ) { static long i, oldPos; char inc, j, Row, buffer[80], buffer1[80], lok; long buffTmp; char Dia; oldPos = i; switch( Pagina ) { case -1: /* if ( i < 0 ) return; inc = -1; i = oldPos; break; */ case 0: inc = 1; Pagina = 1; i = 0; oldPos = 0; break; case 1: if ( i >= B_IVentas2.Registros() ) return; oldPos = i; inc = 1; break; } settextstyle( SMALL_FONT, HORIZ_DIR, 4 ); setfillstyle( SOLID_FILL, Config.TxtBgN ); bar( 9, 79, 236, 335 ); setcolor ( Config.TxtFgN ); for ( Row = 0; i < B_IVentas2.Registros() && Row < NLineas_PVendidos; i += inc, Row ++ ) { lok = B_IVentas2.LeeReg( (void *)&S_IVentas2, i ); if ( DiaMostrar != -1 ) while( i <= B_IVentas2.Registros() && ( HoraMostrar == -1 ? S_IVentas2.VentaTotal[DiaMostrar-1] == 0 : S_IVentas2.Cantidad[DiaMostrar-1][HoraMostrar] == 0 ) ) { i += inc; lok = B_IVentas2.LeeReg( (void *)&S_IVentas2, i ); }; if ( lok == OK ) { outtextxy( 10, 80 + ( Pagina != -1 ? 15*Row : ( 15 * (NLineas_PVendidos - Row) ) ), S_IVentas2.Nombre ); if ( DiaMostrar != -1 ) { if ( HoraMostrar != -1 ) { buffTmp = (long)S_IVentas2.Cantidad[DiaMostrar-1][HoraMostrar]; } else { buffTmp = 0; for ( j = 0; j < 6; j++ ) buffTmp += (long)S_IVentas2.Cantidad[DiaMostrar-1][j]; } } else { // Total unidades en el mes buffTmp = 0; for ( Dia = 0; Dia < DiasMes; Dia++ ) for ( j = 0; j < 6; j++ ) buffTmp += (long)S_IVentas2.Cantidad[Dia][j]; } formatea_long( buffTmp, buffer1 ); sprintf( buffer, "%6s", buffer1 ); outtextxy( 188, 80 + ( Pagina != -1 ? 15*Row : ( 15 * (NLineas_PVendidos - Row) ) ), buffer ); } } if ( Pagina == -1 ) oldPos = i; } /**************************************************************************\ |* *| |* GraficaMostrada *| |* *| |* Descripci¢n: *| |* Muestra que tipo de grafica estamos visualizando... *| |* y redibuja el mismo... *| |* *| |* Entradas: C¢digo numerico de la gr fica... *| |* *| |* Salidas: (ninguna) *| |* *| \**************************************************************************/ void GraficaMostrada( int grafica ) { char Mensajes[][12] = { "1", "2", "3", "4", "5", "6", "7", "8", "9","10", "11","12","13","14","15","16","17","18","19","20", "21","22","23","24","25","26","27","28","29","30", "1" }; int i; long TMP[32]; char buffer[80], buffer1[80]; setfillstyle( SOLID_FILL, EGA_LIGHTGRAY ); bar( 7, 367, 23, 473 ); bar( 250, 227, 632, 357 ); settextstyle( SMALL_FONT, HORIZ_DIR, 4 ); switch( grafica ) { // Total compras case 0: for ( i = 0; i < DiasMes; i++ ) { formatea_long( GastosComprasD[i+1], buffer1 ); sprintf( buffer, "%2d: %10s", (i+1), buffer1 ); TextoDoble( 250 + 97*(i%4), 235 + 15*(i/4), buffer ); } sprintf( buffer, " Compras " ); MuestraGraficas( 35, 370, 410, 95, DiasMes, (long *)GastosComprasD, Mensajes ); break; // Total ventas case 1: for ( i = 0; i < DiasMes; i++ ) { formatea_long( VentasD[i], buffer1 ); sprintf( buffer, "%2d: %10s", (i+1), buffer1 ); TextoDoble( 250 + 97*(i%4), 235 + 15*(i/4), buffer ); } sprintf( buffer, " Ventas " ); MuestraGraficas( 35, 370, 410, 95, DiasMes, (long *)VentasD, Mensajes ); break; // Beneficio Bruto case 2: for ( i = 0; i < 32; i++ ) TMP[i] = VentasD[i] - GastosComprasD[i+1]; for ( i = 0; i < DiasMes; i++ ) { formatea_long( TMP[i], buffer1 ); sprintf( buffer, "%2d: %10s", (i+1), buffer1 ); TextoDoble( 250 + 97*(i%4), 235 + 15*(i/4), buffer ); } sprintf( buffer, " Ben. Bruto " ); MuestraGraficas( 35, 370, 410, 95, DiasMes, (long *)TMP, Mensajes ); break; } settextstyle( SMALL_FONT, VERT_DIR, 5 ); TextoDoble( 5, 365, buffer ); settextstyle( SMALL_FONT, HORIZ_DIR, 5 ); } // ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß // ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß Û // ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß Û // ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß Û Û // ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß Û Û // ßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßßß Û Û // Û Parte enlace al m¢dulo TPV_VENT.CPP Û Û Û // Û Û Û // Û Secci¢n de Balance del dia Û // ÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜÜ /**************************************************************************\ |* *| |* GeneraBalanceDiario *| |* *| |* Descripci¢n: *| |* Cierra el dia actual, actualizando todas las ventas del dia *| |* incluso si el fichero se ha abierto varias veces en el *| |* mismo dia. *| |* *| |* Entradas:(ninguna) *| |* Salidas: (ninguna) *| |* *| \**************************************************************************/ void GeneraBalanceDiario( void ) { char buffer[100]; int HoraVenta; long i; // Todo esto se puede hacer si hay ventas if ( BVentas.Registros() == 0 ) return; // Con lo que abrimos a continuacion ya iran 6 ficheros abiertos al mismo tiempo // Abrimos los ficheros en Bloque // Cargamos los datos existentes en el archivo temporal de ventas BVentas.CargaDatosUsuario( (void *)&S_IVentas, sizeof( INFORMACION_VENTAS ) ); // Abrimos el archivo de empleados para poder realizar las busquedas sprintf( buffer, "datos\\%s\\info_emp.dbf", NEmpresa ); if ( BEmpl.AbrirReg( buffer, sizeof( INFO_EMPLEADOS ) ) == ERROR ) Error(0x01, BEmpl.cError); // Archivo de datos generales ( 1 de 3 ) sprintf( buffer, "datos\\%s\\VT1-%04d.M%02d", NEmpresa, S_IVentas.Anyo, (int)S_IVentas.Mes ); if ( B_IVentas1.AbrirReg( buffer, sizeof( INFORME1_VENTAS ) ) == ERROR ) Error( 0x01, "Imposible abrir archivo, Ventas diarias 1 de 3" ); // Archivo de productos vendidos ( 2 de 3 ) sprintf( buffer, "datos\\%s\\VT2-%04d.M%02d", NEmpresa, S_IVentas.Anyo, (int)S_IVentas.Mes ); if ( B_IVentas2.AbrirReg( buffer, sizeof( INFORME2_VENTAS ) ) == ERROR ) Error( 0x01, "Imposible abrir archivo, Ventas diarias 2 de 3" ); // Archivo de ventas por empleados ( 3 de 3 ) sprintf( buffer, "datos\\%s\\VT3-%04d.M--"/*%02d"*/, NEmpresa, S_IVentas.Anyo/*, (int)S_IVentas.Mes*/ ); if ( B_IVentas3.AbrirReg( buffer, sizeof( INFORME3_VENTAS ) ) == ERROR ) Error( 0x01, "Imposible abrir archivo, Ventas diarias 3 de 3" ); // Mostramos el mensaje de lo que estamos haciendo... Optar( ENCUADRE, "Cerrando caja", "Se esta cerrando la caja", "y generando el balance diario.", "Por favor, espere....", NULL ); // Si es la primera vez que se abren los ficheros, los inicializo // Fichero 1 de 3 if ( B_IVentas1.Registros() == 0 ) { NuevoRegistroInforme1( &S_IVentas1 ); for ( i = 0; i < 31; i++ ) B_IVentas1.InsReg( (void *)&S_IVentas1, B_IVentas1.Registros(), ARRIBA ); } // Cargamos los datos globales por si este no es el primer balance del dia B_IVentas1.LeeReg( (void *)&S_IVentas1, ( S_IVentas.Dia - 1 ) ); // Datos iniciales para las busquedas if ( B_IVentas2.Registros() == 0 ) { NuevoRegistroInforme2( &S_IVentas2 ); B_IVentas2.InsReg( (void *)&S_IVentas2, B_IVentas2.Registros(), ARRIBA ); } B_IVentas2.LeeReg( (void *)&S_IVentas2, 0 ); #ifndef DEMOSTRACION if ( B_IVentas3.Registros() == 0 ) { NuevoRegistroInforme3( &S_IVentas3 ); B_IVentas3.InsReg( (void *)&S_IVentas3, B_IVentas3.Registros(), ARRIBA ); } B_IVentas3.LeeReg( (void *)&S_IVentas3, 0 ); #endif // Miro si ya tenemos asignadas las horas a inspeccionar if ( S_IVentas1.Hora[0] == -1 ) { for ( i = 0; i < 6; i++ ) S_IVentas1.Hora[(int)i] = Config.HorasMedicion[(int)i]; } // ¨ Esta fijada la hora de apertura de caja ? if ( S_IVentas1.AperturaCaja.hora == -1 ) S_IVentas1.AperturaCaja = S_IVentas.AperturaCaja; // Fichero 2 de 3 ¿ // Ã> Los ficheros de productos y empleados // Fichero 3 de 3 Ù no necesitan ser inicializados. // Actualizamos los datos globales mas externos. S_IVentas1.CierreCaja = S_IVentas.CierreCaja; S_IVentas1.Tickets += S_IVentas.Tickets; S_IVentas1.Cambio += S_IVentas.Cambio; S_IVentas1.SalidasExito += S_IVentas.SalidasExito; S_IVentas1.IntentosSalir += S_IVentas.IntentosSalir; DiaActual = S_IVentas.Dia; MesActual = S_IVentas.Mes; // Construimos la tabla de horas a discriminar ConstruyeTablaHoraria(); // Recorremos todo el archivo de ventas, reorganizando los datos for ( i = 0; i < BVentas.Registros(); i++ ) { // Leemos el registro a tratar BVentas.LeeReg( (void *)&SVentas[0], i ); // Actualizamos los datos globales ( 1 de 3 ) HoraVenta = ActualizaDatosGlobales(); // Actualizamos los datos relativos a productos vendidos ( 2 de 3 ) ActualizaVentasProductos( S_IVentas.Dia, HoraVenta ); #ifndef DEMOSTRACION // Actualizamos las ventas de cada empleado ( 3 de 3 ) ActualizaVentasEmpleados( S_IVentas.Dia, S_IVentas.Mes ); #endif } // Salvamos los datos Globales B_IVentas1.EscribeReg( (void *)&S_IVentas1, ( S_IVentas.Dia - 1 ) ); Optar( ENCUADRE, NULL ); BEmpl.CerrarReg(); B_IVentas1.CerrarReg(); B_IVentas2.CerrarReg(); B_IVentas3.CerrarReg(); } /**************************************************************************\ |* *| |* ActualizaDatosGlobales *| |* *| |* Descripci¢n: *| |* Recalcula los datos globales, a razon de los datos antiguos *| |* y los nuevos, teniendo en cuenta, las horas a examinar... *| |* mismo dia. *| |* SVentas[0] Contiene los datos con los que actualizar *| |* *| |* Entradas:(ninguna) *| |* *| |* Salidas: (ninguna) *| |* *| \**************************************************************************/ int ActualizaDatosGlobales( void ) { char j; // Tabla horaria: // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 00 // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 // 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 00 // // //char TablaHoraria[24] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23 }; // Actualizamos los datos mas directos, (dentro de lo que cabe) S_IVentas1.CosteTotal += SVentas[0].PrecioC /** SVentas[0].Cantidad*/; S_IVentas1.TotalVentas += SVentas[0].PrecioV * SVentas[0].Cantidad; if ( SVentas[0].BarraMesa ) S_IVentas1.TotalVentas += ( (S_IVentas1.TotalVentas) * Config.OpcionesCaja.PorcentajeMesa ) / 100; // Recorremos las horas que nos interesan inspeccionar j = TablaHoraria[ (int)( SVentas[0].HoraV.hora % 24) ]; // for ( j=0; j < 6; j++ ) // if ( SVentas[0].HoraV.hora >= S_IVentas1.Hora[j] && SVentas[0].HoraV.hora < S_IVentas1.Hora[ (j+1)%6 ] ) // { S_IVentas1.TotalVendido[j] += SVentas[0].PrecioV * SVentas[0].Cantidad; if ( SVentas[0].BarraMesa ) S_IVentas1.TotalVendido[j] += ( (SVentas[0].PrecioV * SVentas[0].Cantidad/*S_IVentas1.TotalVendido[j]*/) * Config.OpcionesCaja.PorcentajeMesa ) / 100; // break; // } return (int)j; } void ConstruyeTablaHoraria(void) { int i, j, k; // Por defecto la tabla horaria esta toda a cero for ( i = 0; i < 6; i++ ) TablaHoraria[i] = 0; // Revisamos las 24 horas posibles: 00 - 1 - 2 - ... - 22 - 23 for ( i = 0; i < 24; i ++ ) // Por cada hora verificamos el rango donde pueda estar ( 0 - 5 ) for ( j = 0; j < 6; j ++ ) { for ( k = ( S_IVentas1.Hora[j] % 24); k != (S_IVentas1.Hora[(j+1)%6]%24); k = (++k)%24 ) { if ( i == k ) { TablaHoraria[i] = j; break; } } if ( k != (S_IVentas1.Hora[(j+1)%6]%24) ) break; } } /*************************************************************************\ |* *| |* ActualizaVentasProductos *| |* *| |* Descripci¢n: *| |* Busca y actualiza el producto, en el dia que corresponda, *| |* en caso de no encontrarlo, lo a¤ade. *| |* SVentas[0] Contiene los datos con los que actualizar *| |* *| |* Entradas: *| |* Puntero donde guardar la actualizacion ( 2 de 3 ) *| |* Dia a actualizar *| |* *| |* Salidas: (ninguna) *| |* *| \*************************************************************************/ void ActualizaVentasProductos( char DiaGestion, char HoraVenta ) { char enc; long i; if ( DiaGestion != S_IVentas.Dia ) Error( 0x00, "Sincronismo erroneo en ActualizaVentaProductos" ); // Quizas estamos situados sobre ella if ( S_IVentas2.CodigoR == SVentas[0].CodigoR ) { // Asi que ya lo hemos encontrado enc = OK; } else { enc = ERROR; B_IVentas2.LeeReg( (void *)&S_IVentas2, 0 ); // No estabamos sobre ella. Buscamos la referencia del producto for ( i = 0; i < B_IVentas2.Registros() && enc == ERROR; i ++ ) { if ( S_IVentas2.CodigoR == SVentas[0].CodigoR ) { enc = OK; } else { B_IVentas2.LeeReg( (void *)&S_IVentas2, i ); } } if ( S_IVentas2.CodigoR == SVentas[0].CodigoR ) enc = OK; } // Llegado a este punto, ya se si se encuentra en el fichero o no, // asi que si no se encuentra en el fichero, lo inserto. if ( enc == ERROR ) { NuevoRegistroInforme2( &S_IVentas2 ); S_IVentas2.CodigoR = SVentas[0].CodigoR; // 1§ Obtenemos el nombre del producto ( si el Cod. 0.Tickets Varios ) if ( MatchRef( SVentas[0].CodigoR, NORMAL ) == OK ) { strcpy ( S_IVentas2.Nombre, SRef.Descripcion ); } else { strcpy ( S_IVentas2.Nombre, "Tickets Varios" ); } S_IVentas2.CantUnitaria = SRef.CantUnitaria; B_IVentas2.InsReg( (void *)&S_IVentas2, B_IVentas2.Registros(), ARRIBA ); } // Para acabar, ya estoy situado sobre la referencia que tengo que actualizar // asi que solo actualizo sus datos... S_IVentas2.Cantidad[DiaGestion-1][HoraVenta] += SVentas[0].Cantidad; S_IVentas2.VentaTotal[DiaGestion-1] += SVentas[0].PrecioV*SVentas[0].Cantidad; S_IVentas2.PrecioCosto[DiaGestion-1] += SVentas[0].PrecioC/*SVentas[0].Cantidad*/; // ... y grabo la informacion. B_IVentas2.EscribeReg( (void *)&S_IVentas2, B_IVentas2.RegActual() ); } #ifndef DEMOSTRACION /*************************************************************************\ |* *| |* ActualizaVentasEmpleados *| |* *| |* Descripci¢n: *| |* Busca y actualiza las ventas de cada proveedor, *| |* en caso de no encontrarlo, lo a¤ade. *| |* SVentas[0] Contiene los datos con los que actualizar *| |* *| |* Entradas: *| |* Dia a actualizar *| |* Mes a actualizar *| |* *| |* Salidas: (ninguna) *| |* *| \*************************************************************************/ void ActualizaVentasEmpleados( char DiaGestion, char MesGestion ) { char enc, buffer[100]; long i; DiaGestion = S_IVentas.Dia; MesGestion = S_IVentas.Mes; // Quizas estamos situados sobre ella if ( S_IVentas3.CodigoR == SVentas[0].CodigoVendedor ) { // Asi que ya lo hemos encontrado enc = OK; } else { enc = ERROR; B_IVentas3.LeeReg( (void *)&S_IVentas3, 0 ); // No estabamos sobre ella. Buscamos la referencia del producto for ( i = 0; i < B_IVentas3.Registros() && enc == ERROR; i ++ ) { if ( S_IVentas3.CodigoR == SVentas[0].CodigoVendedor ) { enc = OK; } else { B_IVentas3.LeeReg( (void *)&S_IVentas3, i ); } } } // Llegado a este punto, ya se si se encuentra en el fichero o no, // asi que si no se encuentra en el fichero, lo inserto. if ( enc == ERROR ) { NuevoRegistroInforme3( &S_IVentas3 ); // 1§ Obtenemos el nombre del producto ( si el Cod. 0.Tickets Varios ) S_IVentas3.CodigoR = SVentas[0].CodigoVendedor; strcpy ( S_IVentas3.Vendedor, "Vendedor Varios" ); if ( SVentas[0].CodigoVendedor != 0 ) { if ( MatchVendedor( SVentas[0].CodigoVendedor ) == OK ) { sprintf( buffer, "%s %s %s", SEmpl.Nombre, SEmpl.Apellido1, SEmpl.Apellido2 ); buffer[30] = '\0'; strcpy ( S_IVentas3.Vendedor, buffer ); } } B_IVentas3.InsReg( (void *)&S_IVentas3, B_IVentas3.Registros(), ARRIBA ); } // Para acabar, ya estoy situado sobre la referencia que tengo que actualizar // asi que solo actualizo sus datos... S_IVentas3.TotalVendido[DiaGestion-1][MesGestion-1] += SVentas[0].PrecioV; // ... y grabo la informacion. B_IVentas3.EscribeReg( (void *)&S_IVentas3, B_IVentas3.RegActual() ); } #endif /*************************************************************************\ |* *| |* NuevoRegistroInforme1 *| |* *| |* Descripci¢n: *| |* Actualiza los datos para un nuevo registro del tipo 1. *| |* *| |* *| |* Entradas: *| |* Puntero donde guardar el nuevo Reg. ( 1 de 3 ) *| |* *| |* Salidas: (ninguna) *| |* *| \*************************************************************************/ void NuevoRegistroInforme1( INFORME1_VENTAS *S_IVentas1 ) { char i; for ( i = 0; i < 6; i++ ) S_IVentas1 -> Hora[i] = -1; for ( i = 0; i < 6; i++ ) S_IVentas1 -> TotalVendido[i] = 0; S_IVentas1 -> CosteTotal = 0; S_IVentas1 -> TotalVentas = 0; S_IVentas1 -> Tickets = 0; S_IVentas1 -> Cambio = 0; S_IVentas1 -> AperturaCaja.hora = -1; S_IVentas1 -> CierreCaja.hora = -1; S_IVentas1 -> Tickets = 0; S_IVentas1 -> Cambio = 0; S_IVentas1 -> SalidasExito = 0; S_IVentas1 -> IntentosSalir = 0; } /*************************************************************************\ |* *| |* NuevoRegistroInforme2 *| |* *| |* Descripci¢n: *| |* Actualiza los datos para un nuevo registro del tipo 2. *| |* *| |* *| |* Entradas: *| |* Puntero donde guardar el nuevo Reg. ( 2 de 3 ) *| |* *| |* Salidas: (ninguna) *| |* *| \*************************************************************************/ void NuevoRegistroInforme2( INFORME2_VENTAS *S_IVentas2 ) { char i, j; // No // Codigo Real del Producto // necesitan // Nombre del Producto // ser // Cantidad de producto vendida segun horas, // inicializados // y dia de venta ( 1, 2, ..., 31 ) for ( i = 0; i < 31; i++ ) { S_IVentas2 -> VentaTotal[i] = 0; S_IVentas2 -> PrecioCosto[i] = 0; for ( j = 0; j < 6; j++ ) S_IVentas2 -> Cantidad[i][j] = 0; } } #ifndef DEMOSTRACION /*************************************************************************\ |* *| |* NuevoRegistroInforme3 *| |* *| |* Descripci¢n: *| |* Actualiza los datos para un nuevo registro del tipo 3. *| |* *| |* *| |* Entradas: *| |* Puntero donde guardar el nuevo Reg. ( 3 de 3 ) *| |* *| |* Salidas: (ninguna) *| |* *| \*************************************************************************/ void NuevoRegistroInforme3( INFORME3_VENTAS *S_IVentas3 ) { char i, j; // No necesitan // Codigo Real del Vendedor // ser inicializados // Nombre del Vendedor // Total que Vendi¢ por dia de cada mes for ( i = 0; i < 31; i++ ) for ( j = 0; j < 12; j ++ ) S_IVentas3 -> TotalVendido[i][j] = 0; } #endif /*************************************************************************\ |* *| |* MatchVendedor *| |* *| |* Descripci¢n: *| |* Busca al vendedor requerido. *| |* *| |* *| |* Entradas: *| |* Codigo del Vendedor *| |* *| |* Salidas: (ninguna) *| |* *| \*************************************************************************/ int MatchVendedor( long CodigoVendedor ) { char enc; long i; if ( SEmpl.CodigoR == CodigoVendedor ) return OK; enc = ERROR; BEmpl.LeeReg( (void *)&SEmpl, 0 ); for ( i = 0; i < BEmpl.Registros() && enc == ERROR; i++ ) { if ( SEmpl.CodigoR == CodigoVendedor ) { enc = OK; } else { BEmpl.LeeReg( (void *)&SEmpl, i ); } } return enc; } /*************************************************************************\ |* *| |* DespliegaCalendario *| |* *| |* Descripci¢n: *| |* Despliega un calendario y permite seleccionar el dia *| |* y el mes a investigar. *| |* *| |* Entradas: *| |* Punteros a donde guardar la seleccion *| |* *| |* Salidas: (ninguna) *| |* *| \*************************************************************************/ void DespliegaCalendario( void ) { void far *fondo_pantalla; struct Make_Boton { int Up, Left, Down, Right; unsigned char Cdf, Cb1, Cb2; unsigned char Ab, Pb; unsigned char Isc, Sc; }; extern struct Make_Boton far *Botones; int i, IniSec; char ok, BPush; IniSec = P_Sec( 4 - 1 ); #define DesplX 100 #define DesplY 100 if ( (fondo_pantalla = (void far *)farmalloc( JD_imagesize( 120 + DesplX, 5 + DesplY, 380 + DesplX, 125 + DesplY ) ) ) != NULL ) { // Recolocamos los botones para que esten centrados en la pantalla for ( i = 0; i < 45; i++ ) { Botones[ i + IniSec ].Up += DesplY; Botones[ i + IniSec ].Down += DesplY; Botones[ i + IniSec ].Left += DesplX; Botones[ i + IniSec ].Right += DesplX; } getimage( 120 + DesplX, 5 + DesplY, 380 + DesplX, 125 + DesplY, fondo_pantalla ); RellenaCalendario( DesplX, DesplY ); // Tratamiento de los pulsadores ok = 0; do { MarcaDiaActual( 4, DiaActual + AjusteCalendario, INTENSO ); switch ( BPush = Comprueba_Secuencia( 4, NULL ) ) { case 0: case -2: case -1: while( kbhit() ) getch(); // Limpiamos posibles teclas en BUFFER break; // Retrocede un mes case 43: if ( MesActual > 1 ) { MarcaDiaActual( 4, DiaActual + AjusteCalendario, NORMAL ); MesActual--; DiaActual = 1; RellenaCalendario( DesplX, DesplY ); MarcaDiaActual( 4, DiaActual + AjusteCalendario, INTENSO ); } break; // Avanza un mes case 44: if ( MesActual < 12 ) { MarcaDiaActual( 4, DiaActual + AjusteCalendario, NORMAL ); MesActual++; DiaActual = 1; RellenaCalendario( DesplX, DesplY ); MarcaDiaActual( 4, DiaActual + AjusteCalendario, INTENSO ); } break; // Salir case 45: ok = 1; break; default: if ( ( BPush - AjusteCalendario ) > 0 && ( BPush - AjusteCalendario ) <= DiasMes ) { MarcaDiaActual( 4, DiaActual + AjusteCalendario, NORMAL ); DiaActual = BPush - AjusteCalendario; MarcaDiaActual( 4, DiaActual + AjusteCalendario, INTENSO ); // Marcamos el dia y reconfiguramos todos los par metros // para dicho dia... // Mostramos datos hasta que se nos acabe la pantalla // para el dia dado. ok = 1; } break; } } while ( !ok ); // Recolocamos los botones a su posici¢n inicial for ( i = 0; i < 45; i++ ) { Botones[ i + IniSec ].Up -= DesplY; Botones[ i + IniSec ].Down -= DesplY; Botones[ i + IniSec ].Left -= DesplX; Botones[ i + IniSec ].Right -= DesplX; } putimage( 120 + DesplX, 5 + DesplY, fondo_pantalla, COPY_PUT ); farfree( fondo_pantalla ); } } void ImprimeBalance( char DiaMes, char DiaMostrar ) { FILE *file_out; long i, j, buffTmp, buffTmp1, buffTmp2; char Dia, lok; char buffer1[80], MejorHora; char B1[15], B2[15], B3[15], B4[15]; char Mes[12][10+1] = { "Enero","Febrero","Marzo","Abril","Mayo","Junio", "Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre" }; // ¨ Donde debemos imprimir ? if ( !Config.Impresora.Printer ) { if ( ( file_out = fopen( Config.Impresora.PrintTo, "w" ) ) == NULL ) return; } else file_out = stdprn; if ( DiaMes == DIARIO ) { fprintf( file_out, " ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿\n\r"); fprintf( file_out, "ÚÄ´ Balance de caja: %02d-%02d-%04d ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿\n\r", DiaActual, MesActual, FechaGestionActual.da_year); fprintf( file_out, "³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³±\n\r"); fprintf( file_out, "³ ³±\n\r"); formatea_long( (long)S_IVentas1.Tickets, buffer1 ); fprintf( file_out, "³ N§ de tickets: %-10s ³±\n\r", buffer1 ); formatea_long( (long)S_IVentas1.Cambio, buffer1 ); fprintf( file_out, "³ Cambios efect: %-10s ³±\n\r", buffer1 ); fprintf( file_out, "³ Inicio de caja: %02d:%02d ³±\n\r", S_IVentas1.AperturaCaja.hora, S_IVentas1.AperturaCaja.min ); fprintf( file_out, "³ Fin de caja: %02d:%02d ³±\n\r", S_IVentas1.CierreCaja.hora, S_IVentas1.CierreCaja.min ); formatea_long( (long)S_IVentas1.TotalVendido[0], buffer1 ); fprintf( file_out, "³ %02d:00 - %02d:00 %11s ³±\n\r", S_IVentas1.Hora[0], S_IVentas1.Hora[(0+1)%6], buffer1 ); formatea_long( (long)S_IVentas1.TotalVendido[1], buffer1 ); fprintf( file_out, "³ Intentos de salir: %6ld %02d:00 - %02d:00 %11s ³±\n\r", (long)S_IVentas1.IntentosSalir, S_IVentas1.Hora[1], S_IVentas1.Hora[(1+1)%6], buffer1 ); formatea_long( (long)S_IVentas1.TotalVendido[2], buffer1 ); fprintf( file_out, "³ Salidas con exito: %6ld %02d:00 - %02d:00 %11s ³±\n\r", (long)S_IVentas1.SalidasExito, S_IVentas1.Hora[2], S_IVentas1.Hora[(2+1)%6], buffer1 ); formatea_long( (long)S_IVentas1.TotalVendido[3], buffer1 ); fprintf( file_out, "³ %02d:00 - %02d:00 %11s ³±\n\r", S_IVentas1.Hora[3], S_IVentas1.Hora[(3+1)%6], buffer1 ); formatea_long( (long)S_IVentas1.TotalVendido[4], buffer1 ); fprintf( file_out, "³ %02d:00 - %02d:00 %11s ³±\n\r", S_IVentas1.Hora[4], S_IVentas1.Hora[(4+1)%6], buffer1 ); formatea_long( (long)S_IVentas1.TotalVendido[5], buffer1 ); fprintf( file_out, "³ %02d:00 - %02d:00 %11s ³±\n\r", S_IVentas1.Hora[5], S_IVentas1.Hora[(5+1)%6], buffer1 ); fprintf( file_out, "³ +_____________ ³±\n\r"); formatea_long( (long)S_IVentas1.TotalVentas, buffer1 ); fprintf( file_out, "³ Total Ventas: %11s ³±\n\r", buffer1 ); formatea_long( (long)GastosCompras, buffer1 ); fprintf( file_out, "³ Total Gastos: - %11s ³±\n\r", buffer1 ); fprintf( file_out, "³ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -------------- ³±\n\r"); formatea_long( (long)( S_IVentas1.TotalVentas - GastosCompras ), buffer1 ); fprintf( file_out, "³ ³ Incidencias del dia: ³ Benef. Bruto: %11s ³±\n\r", buffer1 ); fprintf( file_out, "³ ³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³±\n\r"); fprintf( file_out, "ÀÄ´ ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ±\n\r"); fprintf( file_out, " ³ %-50s ³±\n\r", S_IVentas1.Notas[0] ); fprintf( file_out, " ³ %-50s ³±\n\r", S_IVentas1.Notas[1] ); fprintf( file_out, " ³ %-50s ³±\n\r", S_IVentas1.Notas[2] ); fprintf( file_out, " ³ %-50s ³±\n\r", S_IVentas1.Notas[3] ); fprintf( file_out, " ³ %-50s ³±\n\r", S_IVentas1.Notas[4] ); fprintf( file_out, " ³ %-50s ³±\n\r", S_IVentas1.Notas[5] ); fprintf( file_out, " ³ %-50s ³±\n\r", S_IVentas1.Notas[6] ); fprintf( file_out, " ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ±\n\r"); } else { fprintf( file_out, " ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿\n\r"); fprintf( file_out, "ÚÄ´ Balance Mensual: %10s %04d ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿\n\r", Mes[MesActual-1], FechaGestionActual.da_year); fprintf( file_out, "³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ ³±\n\r"); fprintf( file_out, "³ ³±\n\r"); formatea_long( (long)S_IVentas1.Tickets, buffer1 ); fprintf( file_out, "³ N§ de tickets: %-10s ³±\n\r", buffer1 ); formatea_long( (long)S_IVentas1.Cambio, buffer1 ); fprintf( file_out, "³ Cambios efect: %-10s ³±\n\r", buffer1 ); fprintf( file_out, "³ Inicio de caja: %02d:%02d ³±\n\r", (int)S_IVentas1.AperturaCaja.hora, (int)S_IVentas1.AperturaCaja.min ); fprintf( file_out, "³ Fin de caja: %02d:%02d ³±\n\r", (int)S_IVentas1.CierreCaja.hora, (int)S_IVentas1.CierreCaja.min ); formatea_long( (long)S_IVentas1.TotalVendido[0], buffer1 ); fprintf( file_out, "³ %02d:00 - %02d:00 %11s ³±\n\r", S_IVentas1.Hora[0], S_IVentas1.Hora[(0+1)%6], buffer1 ); formatea_long( (long)S_IVentas1.TotalVendido[1], buffer1 ); fprintf( file_out, "³ Intentos de salir: %6ld %02d:00 - %02d:00 %11s ³±\n\r", (long)S_IVentas1.IntentosSalir, S_IVentas1.Hora[1], S_IVentas1.Hora[(1+1)%6], buffer1 ); formatea_long( (long)S_IVentas1.TotalVendido[2], buffer1 ); fprintf( file_out, "³ Salidas con exito: %6ld %02d:00 - %02d:00 %11s ³±\n\r", (long)S_IVentas1.SalidasExito, S_IVentas1.Hora[2], S_IVentas1.Hora[(2+1)%6], buffer1 ); formatea_long( (long)S_IVentas1.TotalVendido[3], buffer1 ); fprintf( file_out, "³ %02d:00 - %02d:00 %11s ³±\n\r", S_IVentas1.Hora[3], S_IVentas1.Hora[(3+1)%6], buffer1 ); formatea_long( (long)S_IVentas1.TotalVendido[4], buffer1 ); fprintf( file_out, "³ %02d:00 - %02d:00 %11s ³±\n\r", S_IVentas1.Hora[4], S_IVentas1.Hora[(4+1)%6], buffer1 ); formatea_long( (long)S_IVentas1.TotalVendido[5], buffer1 ); fprintf( file_out, "³ %02d:00 - %02d:00 %11s ³±\n\r", S_IVentas1.Hora[5], S_IVentas1.Hora[(5+1)%6], buffer1 ); fprintf( file_out, "³ +_____________ ³±\n\r"); formatea_long( (long)S_IVentas1.TotalVentas, buffer1 ); fprintf( file_out, "³ Total Ventas: %11s ³±\n\r", buffer1 ); formatea_long( (long)GastosCompras, buffer1 ); fprintf( file_out, "³ Total Gastos: - %11s ³±\n\r", buffer1 ); fprintf( file_out, "³ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ -------------- ³±\n\r"); formatea_long( (long)( S_IVentas1.TotalVentas - GastosCompras ), buffer1 ); fprintf( file_out, "³ ³ Ventas desglosadas en DIAS ³ Benef. Bruto: %11s ³±\n\r", buffer1 ); fprintf( file_out, "³ ³----------------------------ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿³±\n\r"); fprintf( file_out, "Àij ³Ù±\n\r"); formatea_long( VentasD[0], B1 ); formatea_long( VentasD[1], B2 ); formatea_long( VentasD[2], B3 ); formatea_long( VentasD[3], B4 ); fprintf( file_out, " ³ 1: %10s 2: %10s 3: %10s 4: %10s ³±±\n\r", B1, B2, B3, B4 ); formatea_long( VentasD[4], B1 ); formatea_long( VentasD[5], B2 ); formatea_long( VentasD[6], B3 ); formatea_long( VentasD[7], B4 ); fprintf( file_out, " ³ 5: %10s 6: %10s 7: %10s 8: %10s ³±±\n\r", B1, B2, B3, B4 ); formatea_long( VentasD[8], B1 ); formatea_long( VentasD[9], B2 ); formatea_long( VentasD[10], B3 ); formatea_long( VentasD[11], B4 ); fprintf( file_out, " ³ 9: %10s 10: %10s 11: %10s 12: %10s ³±±\n\r", B1, B2, B3, B4 ); formatea_long( VentasD[12], B1 ); formatea_long( VentasD[13], B2 ); formatea_long( VentasD[14], B3 ); formatea_long( VentasD[15], B4 ); fprintf( file_out, " ³ 13: %10s 14: %10s 15: %10s 16: %10s ³±±\n\r", B1, B2, B3, B4 ); formatea_long( VentasD[16], B1 ); formatea_long( VentasD[17], B2 ); formatea_long( VentasD[18], B3 ); formatea_long( VentasD[19], B4 ); fprintf( file_out, " ³ 17: %10s 18: %10s 19: %10s 20: %10s ³±±\n\r", B1, B2, B3, B4 ); formatea_long( VentasD[20], B1 ); formatea_long( VentasD[21], B2 ); formatea_long( VentasD[22], B3 ); formatea_long( VentasD[23], B4 ); fprintf( file_out, " ³ 21: %10s 22: %10s 23: %10s 24: %10s ³±±\n\r", B1, B2, B3, B4 ); formatea_long( VentasD[24], B1 ); formatea_long( VentasD[25], B2 ); formatea_long( VentasD[26], B3 ); formatea_long( VentasD[27], B4 ); fprintf( file_out, " ³ 25: %10s 26: %10s 27: %10s 28: %10s ³±±\n\r", B1, B2, B3, B4 ); formatea_long( VentasD[28], B1 ); formatea_long( VentasD[29], B2 ); formatea_long( VentasD[30], B3 ); fprintf( file_out, "Úij 29: %10s 30: %10s 31: %10s ³¿±\n\r", B1, B2, B3 ); fprintf( file_out, "³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ³±\n\r"); fprintf( file_out, "³ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³±\n\r"); fprintf( file_out, "³ ³ Compras desglosadas / DIAS ³ ³±\n\r"); fprintf( file_out, "³ ³----------------------------ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿³±\n\r"); fprintf( file_out, "Àij ³Ù±\n\r"); formatea_long( GastosComprasD[0+1], B1 ); formatea_long( GastosComprasD[1+1], B2 ); formatea_long( GastosComprasD[2+1], B3 ); formatea_long( GastosComprasD[3+1], B4 ); fprintf( file_out, " ³ 1: %10s 2: %10s 3: %10s 4: %10s ³±±\n\r", B1, B2, B3, B4 ); formatea_long( GastosComprasD[4+1], B1 ); formatea_long( GastosComprasD[5+1], B2 ); formatea_long( GastosComprasD[6+1], B3 ); formatea_long( GastosComprasD[7+1], B4 ); fprintf( file_out, " ³ 5: %10s 6: %10s 7: %10s 8: %10s ³±±\n\r", B1, B2, B3, B4 ); formatea_long( GastosComprasD[8+1], B1 ); formatea_long( GastosComprasD[9+1], B2 ); formatea_long( GastosComprasD[10+1], B3 ); formatea_long( GastosComprasD[11+1], B4 ); fprintf( file_out, " ³ 9: %10s 10: %10s 11: %10s 12: %10s ³±±\n\r", B1, B2, B3, B4 ); formatea_long( GastosComprasD[12+1], B1 ); formatea_long( GastosComprasD[13+1], B2 ); formatea_long( GastosComprasD[14+1], B3 ); formatea_long( GastosComprasD[15+1], B4 ); fprintf( file_out, " ³ 13: %10s 14: %10s 15: %10s 16: %10s ³±±\n\r", B1, B2, B3, B4 ); formatea_long( GastosComprasD[16+1], B1 ); formatea_long( GastosComprasD[17+1], B2 ); formatea_long( GastosComprasD[18+1], B3 ); formatea_long( GastosComprasD[19+1], B4 ); fprintf( file_out, " ³ 17: %10s 18: %10s 19: %10s 20: %10s ³±±\n\r", B1, B2, B3, B4 ); formatea_long( GastosComprasD[20+1], B1 ); formatea_long( GastosComprasD[21+1], B2 ); formatea_long( GastosComprasD[22+1], B3 ); formatea_long( GastosComprasD[23+1], B4 ); fprintf( file_out, " ³ 21: %10s 22: %10s 23: %10s 24: %10s ³±±\n\r", B1, B2, B3, B4 ); formatea_long( GastosComprasD[24+1], B1 ); formatea_long( GastosComprasD[25+1], B2 ); formatea_long( GastosComprasD[26+1], B3 ); formatea_long( GastosComprasD[27+1], B4 ); fprintf( file_out, " ³ 25: %10s 26: %10s 27: %10s 28: %10s ³±±\n\r", B1, B2, B3, B4 ); formatea_long( GastosComprasD[28+1], B1 ); formatea_long( GastosComprasD[29+1], B2 ); formatea_long( GastosComprasD[30+1], B3 ); fprintf( file_out, "Úij 29: %10s 30: %10s 31: %10s ³¿±\n\r", B1, B2, B3 ); fprintf( file_out, "³ ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ³±\n\r"); fprintf( file_out, "³ ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿ ³±\n\r"); fprintf( file_out, "³ ³ Beneficios / DIA ³ ³±\n\r"); fprintf( file_out, "³ ³----------------------------ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿³±\n\r"); fprintf( file_out, "Àij ³Ù±\n\r"); formatea_long( VentasD[0] - GastosComprasD[0+1], B1 ); formatea_long( VentasD[1] - GastosComprasD[1+1], B2 ); formatea_long( VentasD[2] - GastosComprasD[2+1], B3 ); formatea_long( VentasD[3] - GastosComprasD[3+1], B4 ); fprintf( file_out, " ³ 1: %10s 2: %10s 3: %10s 4: %10s ³±±\n\r", B1, B2, B3, B4 ); formatea_long( VentasD[4] - GastosComprasD[4+1], B1 ); formatea_long( VentasD[5] - GastosComprasD[5+1], B2 ); formatea_long( VentasD[6] - GastosComprasD[6+1], B3 ); formatea_long( VentasD[7] - GastosComprasD[7+1], B4 ); fprintf( file_out, " ³ 5: %10s 6: %10s 7: %10s 8: %10s ³±±\n\r", B1, B2, B3, B4 ); formatea_long( VentasD[8] - GastosComprasD[8+1], B1 ); formatea_long( VentasD[9] - GastosComprasD[9+1], B2 ); formatea_long( VentasD[10] - GastosComprasD[10+1], B3 ); formatea_long( VentasD[11] - GastosComprasD[11+1], B4 ); fprintf( file_out, " ³ 9: %10s 10: %10s 11: %10s 12: %10s ³±±\n\r", B1, B2, B3, B4 ); formatea_long( VentasD[12] - GastosComprasD[12+1], B1 ); formatea_long( VentasD[13] - GastosComprasD[13+1], B2 ); formatea_long( VentasD[14] - GastosComprasD[14+1], B3 ); formatea_long( VentasD[15] - GastosComprasD[15+1], B4 ); fprintf( file_out, " ³ 13: %10s 14: %10s 15: %10s 16: %10s ³±±\n\r", B1, B2, B3, B4 ); formatea_long( VentasD[16] - GastosComprasD[16+1], B1 ); formatea_long( VentasD[17] - GastosComprasD[17+1], B2 ); formatea_long( VentasD[18] - GastosComprasD[18+1], B3 ); formatea_long( VentasD[19] - GastosComprasD[19+1], B4 ); fprintf( file_out, " ³ 17: %10s 18: %10s 19: %10s 20: %10s ³±±\n\r", B1, B2, B3, B4 ); formatea_long( VentasD[20] - GastosComprasD[20+1], B1 ); formatea_long( VentasD[21] - GastosComprasD[21+1], B2 ); formatea_long( VentasD[22] - GastosComprasD[22+1], B3 ); formatea_long( VentasD[23] - GastosComprasD[23+1], B4 ); fprintf( file_out, " ³ 21: %10s 22: %10s 23: %10s 24: %10s ³±±\n\r", B1, B2, B3, B4 ); formatea_long( VentasD[24] - GastosComprasD[24+1], B1 ); formatea_long( VentasD[25] - GastosComprasD[25+1], B2 ); formatea_long( VentasD[26] - GastosComprasD[26+1], B3 ); formatea_long( VentasD[27] - GastosComprasD[27+1], B4 ); fprintf( file_out, " ³ 25: %10s 26: %10s 27: %10s 28: %10s ³±±\n\r", B1, B2, B3, B4 ); formatea_long( VentasD[28] - GastosComprasD[28+1], B1 ); formatea_long( VentasD[29] - GastosComprasD[29+1], B2 ); formatea_long( VentasD[30] - GastosComprasD[30+1], B3 ); fprintf( file_out, " ³ 29: %10s 30: %10s 31: %10s ³±±\n\r", B1, B2, B3 ); fprintf( file_out, " ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ±\n\r"); } fputc( 12, file_out ); // Salto de p gina if ( Optar( 1, "¨ Continuar imprimiendo ?", "Si desea imprimir el listado", "de productos vendidos:", "­ Presione ACEPTAR !", NULL ) ) { fprintf( file_out, "\n\r-> Listado de productos vendidos: \n\r" ); if ( DiaMostrar != -1 ) { fprintf( file_out, " ÚÄÄÄÄÄÂÄÄÄÄÄÄ¿\n\r" ); fprintf( file_out, "C¢digo Descripci¢n Unds. Total Benef.B ³Hora ³ Cant ³\n\r" ); fprintf( file_out, " ÃÄÄÄÄÄÅÄÄÄÄÄÄ´\n\r" ); } else { fprintf( file_out, " ÚÄÄÄÂÄÄÄÄÄÄÄ¿\n\r" ); fprintf( file_out, "C¢digo Descripci¢n Unds. Total Benef.B ³Dia³ Cant ³\n\r" ); fprintf( file_out, " ÃÄÄÄÅÄÄÄÄÄÄÄ´\n\r" ); } //ÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛÛ for ( i = 0; i < B_IVentas2.Registros(); i ++ ) { lok = B_IVentas2.LeeReg( (void *)&S_IVentas2, i ); if ( DiaMostrar != -1 ) while( i <= B_IVentas2.Registros() && S_IVentas2.VentaTotal[DiaMostrar-1] == 0 ) { i ++; lok = B_IVentas2.LeeReg( (void *)&S_IVentas2, i ); }; if ( lok == OK ) { if ( DiaMostrar != -1 ) { // Cantidad total / ( Busqueda mejor cantidad ) { buffTmp = MejorHora = 0; for ( j = 0; j < 6; j++ ) { buffTmp += (long)S_IVentas2.Cantidad[DiaMostrar-1][j]; if ( S_IVentas2.Cantidad[DiaMostrar-1][MejorHora] < S_IVentas2.Cantidad[DiaMostrar-1][j] ) MejorHora = j; } } } else { // Total unidades en el mes ( Mejor Dia ) buffTmp = 0; buffTmp2 = 0; for ( Dia = 0; Dia < DiasMes; Dia++ ) { buffTmp1 = 0; for ( j = 0; j < 6; j++ ) { buffTmp += (long)S_IVentas2.Cantidad[Dia][j]; buffTmp1+= (long)S_IVentas2.Cantidad[Dia][j]; } if ( buffTmp2 < buffTmp1 ) { MejorHora = Dia; buffTmp2 = buffTmp1; } } } formatea_long( buffTmp, buffer1 ); fprintf( file_out, "%7ld %30s %6s ", S_IVentas2.CodigoR, S_IVentas2.Nombre, buffer1 ); formatea_long( S_IVentas2.VentaTotal[DiaMostrar-1], buffer1 ); fprintf( file_out, "%9s ", buffer1 ); if ( DiaMostrar != -1 ) { formatea_long( S_IVentas2.VentaTotal[DiaMostrar-1] - S_IVentas2.PrecioCosto[DiaMostrar-1], buffer1 ); fprintf( file_out, "%9s ³%02d-%02d³", buffer1, (int)S_IVentas1.Hora[MejorHora], (int)S_IVentas1.Hora[(MejorHora+1)%6] ); formatea_long( S_IVentas2.Cantidad[DiaMostrar-1][MejorHora], buffer1 ); fprintf( file_out, "%6s³\n\r", buffer1 ); } else { formatea_long( S_IVentas2.VentaTotal[DiaMostrar-1] - S_IVentas2.PrecioCosto[DiaMostrar-1], buffer1 ); fprintf( file_out, "%9s ³ %02d ³", buffer1, MejorHora ); formatea_long( buffTmp2, buffer1 ); fprintf( file_out, "%8s³\n\r", buffer1 ); } } } if ( DiaMostrar != -1 ) fprintf( file_out, " ÀÄÄÄÄÄÁÄÄÄÄÄÄÙ\n\r" ); else fprintf( file_out, " ÀÄÄÄÁÄÄÄÄÄÄÄÙ\n\r" ); } fputc( 12, file_out ); // Salto de p gina if ( !Config.Impresora.Printer ) fclose( file_out ); }