/*
** Verwaltung der Kunden
**
** Copyright (C) 1996 by Stefan Scherer.
**
** Permission to use, copy, modify, and distribute this software and its
** documentation for non-commerical use and without fee is hereby granted,
** provided that the above copyright notice appear in all copies and that
** both that copyright notice and this permission notice appear in
** supporting documentation.  This software is provided "as is" without
** express or implied warranty.
*/

#ifndef KUNDEN_H
#define KUNDEN_H

#include <exec/types.h>

#define MAX_CUST_LEN 100

/*
** Jeder Kunde wird mit folgender Struktur geführt
*/

struct Customer
  {
    char Adresse1[MAX_CUST_LEN + 1];
    char Adresse2[MAX_CUST_LEN + 1];
    char Adresse3[MAX_CUST_LEN + 1];
    char Adresse4[MAX_CUST_LEN + 1];
    char Adresse5[MAX_CUST_LEN + 1];
    char Zeichen[MAX_CUST_LEN + 1];
    UWORD KundenNummer;
#ifdef KFZ
    char Kennzeichen[MAX_CUST_LEN + 1];
    char FahrzeugNr[MAX_CUST_LEN + 1];
    char KfzZusatz[MAX_CUST_LEN + 1];
#endif

    char Telefon[MAX_CUST_LEN + 1];
    char Fax[MAX_CUST_LEN + 1];
    char Kommentar1[MAX_CUST_LEN + 1];
    char Kommentar2[MAX_CUST_LEN + 1];
    char Kategorie[MAX_CUST_LEN + 1];	/* welche Art von 'Kunde' ist es */
  };

/* manchmal werden nur wichtige Daten benötigt. Deshalb gibt es
** eine abgespeckte Struktur.
*/

struct MinCustomer
  {
    char Adresse1[MAX_CUST_LEN + 1];
    char Adresse2[MAX_CUST_LEN + 1];
    char Adresse3[MAX_CUST_LEN + 1];
    char Adresse4[MAX_CUST_LEN + 1];
    char Adresse5[MAX_CUST_LEN + 1];
    char Zeichen[MAX_CUST_LEN + 1];
    UWORD KundenNummer;
#ifdef KFZ
    char Kennzeichen[MAX_CUST_LEN + 1];
    char FahrzeugNr[MAX_CUST_LEN + 1];
    char KfzZusatz[MAX_CUST_LEN + 1];
#endif
  };

/* o-functions */

int ConstructCustomer (void);
void DestructCustomer (void);
void C_SetExceptions (STRPTR except);

int C_LoadCustomerList (void);
int C_SaveCustomerList (void);

int C_AddCustomer (struct Customer *cust);
int C_DelCustomer (void);
int C_ChangeCustomer (struct Customer *cust);
int C_SetCurrentCustomerNumber (UWORD number);
void C_PrintCustLine (struct MinCustomer *cust, STRPTR line);
void C_PrintName (struct MinCustomer *cust, STRPTR line);
int C_SetCurrentCustomer (UWORD custnumber);


/* v-functions */

void C_GetExceptions (STRPTR except);

int C_GetCurrentCustomerNumberCat (void);
int C_GetCurrentCustomer (struct Customer *cust);
int C_GetCustomer (UWORD num, struct Customer *cust);
int C_GetCurrentCustomerNumber (void);
int C_GetCustomerCount (void);
int C_GetNearestCustomerNumber (struct Customer *cust);
BOOL C_GetStatus (void);
STRPTR C_GetErrorMsg (void);
BOOL C_ComparePattern (UWORD number, struct Customer *cust);

int C_AddCategory (STRPTR category);
int C_DelCategory (void);
int C_ChangeCategory (STRPTR category);
int C_GetCategory (UWORD num, STRPTR category);
int C_GetCategoryCount (void);
int C_SetCurrentCategory (UWORD number);
int C_GetCurrentCategoryNumber (void);


/* Fehlercodes der Funktionen */

enum
  {
    ERR_CUST_OK,		/* kein Fehler */
    ERR_CUST_NOPOOL,		/* kein Memory-Pool vorhanden */
    ERR_CUST_NOMEM,		/* nicht genügend Speicher */
    ERR_CUST_FILENOTFOUND,	/* Datei nicht gefunden */
    ERR_CUST_LISTEMPTY,		/* Kunden-Liste ist leer */
    ERR_CUST_CANTCREATEFILE,	/* File konnte nicht erzeugt werden */
    ERR_CUST_NOITEM,		/* Eintrag nicht in der Liste vorhanden */
    ERR_CUST_SAVE,		/* Fehler beim speichern */
  };

#endif /* KUNDEN_H */
