// Created with MonoDevelop
//
//    QuickStep: Acquire, view and identify spectra 
//    Copyright (C) 2017 Thomas Klose & Torsten Schache, Hiperscan GmbH Dresden, Germany
//
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see <http://www.gnu.org/licenses/>.

using System;
using System.Globalization;
using System.Runtime.Serialization;

using Hiperscan.I18n;


namespace Hiperscan.Extensions.ApoIdent
{
    [DataContract]
	public class Label
	{
		
		public Label(ReportInfo info) : this(info, false)
		{
			
		}

		public Label(ReportInfo info, bool is_test)
		{
			this.IsTest	= is_test;
			this.Info	= info;

			switch (info.ReportCountry)
			{

			case ReportCountryType.Austria:
				this.CreateAustriaLabel();
				break;

			case ReportCountryType.Germany:
				this.CreateGermanyLabel();
				break;

			case ReportCountryType.GreatBritain:
				this.CreateGreatBritainLabel();
				break;

			case ReportCountryType.Switzerland:
				this.CreateSwitzerlandLabel();
				break;

			default:
				this.CreateGreatBritainLabel();
				break;

			}
		}

		private void CreateGermanyLabel()
		{
			this.Header = "Identprüfung nach §§ 6,11 ApBetrO";

			if (this.IsTest == true)
			{
				this.UseByDate = "Verfallsdatum:";
			}
			else
			{
				switch(this.Info.DeadLine)
				{
                    case BatchDeadLine.DeadLineType.UseByDate:
					this.UseByDate = "Verfallsdatum:";
					break;

                    case BatchDeadLine.DeadLineType.ShelfLife:
					this.UseByDate = "Verwendbar bis:";
					break;

				default:
					this.UseByDate = "Verfallsdatum:";
					break;
				}	
			}

			this.Substance = "Substanz:";
            this.Identified = "Entspricht:";
            this.Date = "Datum:";
            this.TestId = "Prüfnummer:";
            this.PPN = "PZN:";
            this.Batch = "Charge:";
            this.CorrectionFactor = "Einwaagekorrektur:";
            this.Supplier = "Hersteller/Lieferant:";
            this.Comment = "Bemerkung:";
            this.EvalYes = "Ja";
            this.EvalNo = "Nein";

            this.DateContent		= Locale.LocalizedDate(this.Info.Date, new CultureInfo("de-DE"));
            this.ExpiryDateContent	= Locale.LocalizedDate(this.Info.ExpireDate, new CultureInfo("de-DE"));
		}

		private void CreateAustriaLabel()
		{
			this.Header = "Identprüfung nach § 8 (2 Z 8) ABO 2005";

			if (this.IsTest == true)
			{
				this.UseByDate = "Verfallsdatum:";
			}
			else
			{
				switch(this.Info.DeadLine)
				{
                    case BatchDeadLine.DeadLineType.UseByDate:
					this.UseByDate = "Verfallsdatum:";
					break;

                    case BatchDeadLine.DeadLineType.ShelfLife:
					this.UseByDate = "Verwendbar bis:";
					break;

				default:
					this.UseByDate = "Verfallsdatum:";
					break;
				}	
			}

			this.Substance = "Substanz:";
            this.Identified = "Entspricht:";
            this.Date = "Datum:";
            this.TestId = "Prüfnummer:";
            this.PPN = "PZN:";
            this.Batch = "Charge:";
            this.CorrectionFactor = "Einwaagekorrektur:";
            this.Supplier = "Hersteller/Lieferant:";
            this.Comment = "Bemerkung:";
            this.EvalYes = "Ja";
            this.EvalNo = "Nein";

            this.DateContent		= Locale.LocalizedDate(this.Info.Date, new CultureInfo("de-AT"));
            this.ExpiryDateContent	= Locale.LocalizedDate(this.Info.ExpireDate, new CultureInfo("de-AT"));
		}

		private void CreateGreatBritainLabel()
		{
			this.Header = "Declaration of identity";

			if (this.IsTest == true)
			{
				this.UseByDate = "Use-by date:";
			}
			else
			{
				switch(this.Info.DeadLine)
				{
                    case BatchDeadLine.DeadLineType.UseByDate:
					this.UseByDate = "Use-by date:";
					break;

                    case BatchDeadLine.DeadLineType.ShelfLife:
					this.UseByDate = "Shelf life:";
					break;

				default:
					this.UseByDate = "Use-by date:";
					break;
				}
			}

			this.Substance = "Substance:";
            this.Identified = "Identified:";
            this.Date = "Date:";
            this.TestId = "Test ID:";
            this.PPN = "PPN:";
            this.Batch = "Batch:";
            this.CorrectionFactor = "Corr. weighing:";
            this.Supplier = "Manufacturer/supplier:";
            this.Comment = "Comment:";
            this.EvalYes = "Yes";
            this.EvalNo = "No";

            this.DateContent		= Locale.LocalizedDate(this.Info.Date, new CultureInfo("en-GB"));
            this.ExpiryDateContent	= Locale.LocalizedDate(this.Info.ExpireDate, new CultureInfo("en-GB"));
		}

		private void CreateSwitzerlandLabel()
		{
			this.Header = "Identprüfung Ausgangsstoffe";

			if (this.IsTest == true)
			{
				this.UseByDate = "Verfallsdatum:";
			}
			else
			{
				switch(this.Info.DeadLine)
				{
                    case BatchDeadLine.DeadLineType.UseByDate:
					this.UseByDate = "Verfallsdatum:";
					break;

                    case BatchDeadLine.DeadLineType.ShelfLife:
					this.UseByDate = "Verwendbar bis:";
					break;

				default:
					this.UseByDate = "Verfallsdatum:";
					break;
				}	
			}

			this.Substance = "Substanz:";
            this.Identified = "Entspricht:";
            this.Date = "Datum:";
            this.TestId = "Prüfnummer:";
            this.PPN = "PZN:";
            this.Batch = "Charge:";
            this.CorrectionFactor = "Einwaagekorrektur:";
            this.Supplier = "Hersteller/Lieferant:";
            this.Comment = "Bemerkung:";
            this.EvalYes = "Ja";
            this.EvalNo = "Nein";

            this.DateContent		= Locale.LocalizedDate(this.Info.Date, new CultureInfo("de-CH"));
            this.ExpiryDateContent	= Locale.LocalizedDate(this.Info.ExpireDate, new CultureInfo("de-CH"));
		}

        [DataMember] public string Header				{get; private set;}
        [DataMember] public string Substance 			{get; private set;}
        [DataMember] public string Identified 			{get; private set;}
        [DataMember] public string Date					{get; private set;}
        [DataMember] public string PPN					{get; private set;}
        [DataMember] public string TestId				{get; private set;}
        [DataMember] public string UseByDate			{get; private set;}
        [DataMember] public string Batch				{get; private set;}
		[DataMember] public string CorrectionFactor     {get; private set;}
        [DataMember] public string Supplier				{get; private set;}
        [DataMember] public string Comment				{get; private set;}
        [DataMember] public string EvalYes				{get; private set;}
        [DataMember] public string EvalNo				{get; private set;}
        [DataMember] public string DateContent			{get; private set;}
        [DataMember] public string ExpiryDateContent	{get; private set;}

		private bool IsTest					{get; set;}

		private ReportInfo Info				{get; set;}
	}
}