## $Id: contracts.py 12803 2015-03-20 18:51:29Z henrik $
##
## Copyright (C) 2014 Uli Fouquet & Henrik Bettermann
## 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 2 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, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##
"""
Customer contract components.
"""

import grok
from zope.component.interfaces import IFactory
from zope.interface import implementedBy
from waeup.ikoba.utils.helpers import attrs_to_fields
from waeup.ikoba.customers.interfaces import ICustomerNavigation
from waeup.ikoba.customers.contracts import ContractBase
from ikobacustom.pcn.interfaces import MessageFactory as _
from ikobacustom.pcn.customers.interfaces import (
    IRONContract,
    IRONContractEdit,
    IRONContractProcess,
    IRONContractOfficialUse,
    IROPContract,
    IROPContractEdit,
    IROPContractProcess, 
    IROPContractOfficialUse,
    IRPRContract,
    IRPRContractEdit,
    IRPRContractProcess,
    IRPRContractOfficialUse,
    IRPCContract,
    IRPCContractEdit,
    IRPCContractProcess,
    IRPCContractOfficialUse,
    IIPPMVLContract,
    IIPPMVLContractEdit,
    IIPPMVLContractProcess,
    IIPPMVLContractOfficialUse,
    IRPPMVLContract,
    IRPPMVLContractEdit,
    IRPPMVLContractProcess,
    IRPPMVLContractOfficialUse,
    IAPPITContract,
    IAPPITContractEdit,
    IAPPITContractProcess,
    IAPPITContractOfficialUse,
    IRPTContract,
    IRPTContractEdit,
    IRPTContractProcess,
    IRPTContractOfficialUse,
    IAPPTContract,
    IAPPTContractEdit,
    IAPPTContractProcess,
    IAPPTContractOfficialUse,
    )


class PCNContract(ContractBase):
    """This is a sample contract.
    """

    def __init__(self):
        super(PCNContract, self).__init__()
        # The site doesn't exist in unit tests
        self.contract_year = None
        return


class RONContract(PCNContract):
    """This is a sample contract.
    """

    grok.implements(
        IRONContractProcess,
        IRONContract,
        IRONContractEdit,
        ICustomerNavigation)

    contract_category = 'ron'

    form_fields_interface = IRONContract

    edit_form_fields_interface = IRONContractEdit

    ou_form_fields_interface = IRONContractOfficialUse

    check_docs_interface = IRONContract

RONContract = attrs_to_fields(RONContract)


class RONContractFactory(grok.GlobalUtility):
    """A factory for contracts.
    """
    grok.implements(IFactory)
    grok.name(u'waeup.RONContract')
    title = u"Create a new license contract.",
    description = u"This factory instantiates new contract instances."

    def __call__(self, *args, **kw):
        return RONContract(*args, **kw)

    def getInterfaces(self):
        return implementedBy(RONContract)


class ROPContract(PCNContract):
    """This is a sample contract.
    """

    grok.implements(
        IROPContractProcess,
        IROPContract,
        IROPContractEdit,
        ICustomerNavigation)

    contract_category = 'rop'

    form_fields_interface = IROPContract

    edit_form_fields_interface = IROPContractEdit

    ou_form_fields_interface = IROPContractOfficialUse

    check_docs_interface = IROPContract

ROPContract = attrs_to_fields(ROPContract)


class ROPContractFactory(grok.GlobalUtility):
    """A factory for contracts.
    """
    grok.implements(IFactory)
    grok.name(u'waeup.ROPContract')
    title = u"Create a new license contract.",
    description = u"This factory instantiates new contract instances."

    def __call__(self, *args, **kw):
        return ROPContract(*args, **kw)

    def getInterfaces(self):
        return implementedBy(ROPContract)


class RPRContract(PCNContract):
    """Registration in the Provisional Register contract.
    """

    grok.implements(
        IRPRContractProcess,
        IRPRContract,
        IRPRContractEdit,
        ICustomerNavigation)

    contract_category = 'rpr'

    form_fields_interface = IRPRContract

    edit_form_fields_interface = IRPRContractEdit

    ou_form_fields_interface = IRPRContractOfficialUse

    check_docs_interface = IRPRContract

RPRContract = attrs_to_fields(RPRContract)


class RPRContractFactory(grok.GlobalUtility):
    """A factory for contracts.
    """
    grok.implements(IFactory)
    grok.name(u'waeup.RPRContract')
    title = u"Create a new license contract.",
    description = u"This factory instantiates new contract instances."

    def __call__(self, *args, **kw):
        return RPRContract(*args, **kw)

    def getInterfaces(self):
        return implementedBy(RPRContract)


class RPCContract(PCNContract):
    """Registration as Pharmaceutical Chemist contract.
    """

    grok.implements(
        IRPCContractProcess,
        IRPCContract,
        IRPCContractEdit,
        ICustomerNavigation)

    contract_category = 'rpc'

    form_fields_interface = IRPCContract

    edit_form_fields_interface = IRPCContractEdit

    ou_form_fields_interface = IRPCContractOfficialUse

    check_docs_interface = IRPCContract

RPCContract = attrs_to_fields(RPCContract)


class RPCContractFactory(grok.GlobalUtility):
    """A factory for contracts.
    """
    grok.implements(IFactory)
    grok.name(u'waeup.RPCContract')
    title = u"Create a new license contract.",
    description = u"This factory instantiates new contract instances."

    def __call__(self, *args, **kw):
        return RPCContract(*args, **kw)

    def getInterfaces(self):
        return implementedBy(RPCContract)


class IPPMVLContract(PCNContract):
    """Issuance of Patent and Proprietary Medicines Vendors License contract.
    """

    grok.implements(
        IIPPMVLContractProcess,
        IIPPMVLContract,
        IIPPMVLContractEdit,
        ICustomerNavigation)

    contract_category = 'ippmvl'

    form_fields_interface = IIPPMVLContract

    edit_form_fields_interface = IIPPMVLContractEdit

    ou_form_fields_interface = IIPPMVLContractOfficialUse

    check_docs_interface = IIPPMVLContract

IPPMVLContract = attrs_to_fields(IPPMVLContract)


class IPPMVLContractFactory(grok.GlobalUtility):
    """A factory for contracts.
    """
    grok.implements(IFactory)
    grok.name(u'waeup.IPPMVLContract')
    title = u"Create a new license contract.",
    description = u"This factory instantiates new contract instances."

    def __call__(self, *args, **kw):
        return IPPMVLContract(*args, **kw)

    def getInterfaces(self):
        return implementedBy(IPPMVLContract)


class RPPMVLContract(PCNContract):
    """Renewal of Patent and Proprietary Medicines Vendors License contract.
    """

    grok.implements(
        IRPPMVLContractProcess,
        IRPPMVLContract,
        IRPPMVLContractEdit,
        ICustomerNavigation)

    contract_category = 'rppmvl'

    form_fields_interface = IRPPMVLContract

    edit_form_fields_interface = IRPPMVLContractEdit

    ou_form_fields_interface = IRPPMVLContractOfficialUse

    check_docs_interface = IRPPMVLContract

RPPMVLContract = attrs_to_fields(RPPMVLContract)


class RPPMVLContractFactory(grok.GlobalUtility):
    """A factory for contracts.
    """
    grok.implements(IFactory)
    grok.name(u'waeup.RPPMVLContract')
    title = u"Create a new license contract.",
    description = u"This factory instantiates new contract instances."

    def __call__(self, *args, **kw):
        return RPPMVLContract(*args, **kw)

    def getInterfaces(self):
        return implementedBy(RPPMVLContract)


class APPITContract(PCNContract):
    """Accepting Pupil Pharmacist for Internship Training contract.
    """

    grok.implements(
        IAPPITContractProcess,
        IAPPITContract,
        IAPPITContractEdit,
        ICustomerNavigation)

    contract_category = 'appit'

    form_fields_interface = IAPPITContract

    edit_form_fields_interface = IAPPITContractEdit

    ou_form_fields_interface = IAPPITContractOfficialUse

    check_docs_interface = IAPPITContract

APPITContract = attrs_to_fields(APPITContract)


class APPITContractFactory(grok.GlobalUtility):
    """A factory for contracts.
    """
    grok.implements(IFactory)
    grok.name(u'waeup.APPITContract')
    title = u"Create a new license contract.",
    description = u"This factory instantiates new contract instances."

    def __call__(self, *args, **kw):
        return APPITContract(*args, **kw)

    def getInterfaces(self):
        return implementedBy(APPITContract)


class RPTContract(PCNContract):
    """Registration as a Pharmacy Technician contract.
    """

    grok.implements(
        IRPTContractProcess,
        IRPTContract,
        IRPTContractEdit,
        ICustomerNavigation)

    contract_category = 'rpt'

    form_fields_interface = IRPTContract

    edit_form_fields_interface = IRPTContractEdit

    ou_form_fields_interface = IRPTContractOfficialUse

    check_docs_interface = IRPTContract

RPTContract = attrs_to_fields(RPTContract)


class RPTContractFactory(grok.GlobalUtility):
    """A factory for contracts.
    """
    grok.implements(IFactory)
    grok.name(u'waeup.RPTContract')
    title = u"Create a new license contract.",
    description = u"This factory instantiates new contract instances."

    def __call__(self, *args, **kw):
        return RPTContract(*args, **kw)

    def getInterfaces(self):
        return implementedBy(RPTContract)


class APPTContract(PCNContract):
    """Annual Permit for Pharmacy Technician contract.
    """

    grok.implements(
        IAPPTContractProcess,
        IAPPTContract,
        IAPPTContractEdit,
        ICustomerNavigation)

    contract_category = 'appt'

    form_fields_interface = IAPPTContract

    edit_form_fields_interface = IAPPTContractEdit

    ou_form_fields_interface = IAPPTContractOfficialUse

    check_docs_interface = IAPPTContract

APPTContract = attrs_to_fields(APPTContract)


class APPTContractFactory(grok.GlobalUtility):
    """A factory for contracts.
    """
    grok.implements(IFactory)
    grok.name(u'waeup.APPTContract')
    title = u"Create a new license contract.",
    description = u"This factory instantiates new contract instances."

    def __call__(self, *args, **kw):
        return APPTContract(*args, **kw)

    def getInterfaces(self):
        return implementedBy(APPTContract)

