# -*- coding: utf-8 -*-
from __future__ import absolute_import
from import_export import resources
from import_export.fields import Field

class ProductionPlanResource(resources.Resource):

    def __init__(self):
        super(ProductionPlanResource, self).__init__()
        self.fields['no'] = Field(attribute='no')
        self.fields['name'] = Field(attribute='name')
        self.fields['total_count'] = Field(attribute='total_count')
        self.fields['create_user_text'] = Field(attribute='create_user_text')
        self.fields['create_time'] = Field(attribute='create_time')
        self.fields['status_text'] = Field(attribute='status_text')
        self.fields['check_time'] = Field(attribute='check_time')
        self.fields['check_user_text'] = Field(attribute='check_user_text')
        self.fields['notes'] = Field(attribute='notes')

    def get_export_headers(self):
        return [u'单号', u'名称', u'合计数量', u'创建时间', u'创建人', u'审核状态', u'审核时间', u'审核人', u'备注',]

    class Meta:
        fields = ('no', 'name', 'total_count', 'create_time', 'create_user_text', 'status_text', 'check_time', 'check_user_text',
                  'notes',)
        export_order = fields


class ProductionPlanDetailResource(resources.Resource):

    def __init__(self):
        super(ProductionPlanDetailResource, self).__init__()
        self.fields['name'] = Field(attribute='name')
        self.fields['model'] = Field(attribute='model')
        self.fields['quality_request_text'] = Field(attribute='quality_request_text')
        self.fields['count'] = Field(attribute='count')
        self.fields['p_department_text'] = Field(attribute='p_department_text')
        self.fields['product_time'] = Field(attribute='product_time')
        self.fields['product_user_text'] = Field(attribute='product_user_text')
        self.fields['notes'] = Field(attribute='notes')

    def get_export_headers(self):
        return [u'产品名称', u'产品代码', u'质量要求', u'数量', u'生产车间', u'生产时间', u'负责人', u'备注',]

    class Meta:
        fields = ('name', 'model', 'quality_request_text', 'count', 'p_department_text', 'product_time',
                  'product_user_text', 'notes',)
        export_order = fields


class SalePlanResource(resources.Resource):

    def __init__(self):
        super(SalePlanResource, self).__init__()
        self.fields['no'] = Field(attribute='no')
        self.fields['create_time'] = Field(attribute='create_time')
        self.fields['customer_text'] = Field(attribute='customer_text')
        self.fields['goods_text'] = Field(attribute='goods_text')
        self.fields['total_count'] = Field(attribute='total_count')
        self.fields['total_amount'] = Field(attribute='total_amount')
        self.fields['status_text'] = Field(attribute='status_text')
        self.fields['create_user_text'] = Field(attribute='create_user_text')
        self.fields['department_text'] = Field(attribute='department_text')
        self.fields['check_user_text'] = Field(attribute='check_user_text')
        self.fields['check_time'] = Field(attribute='check_time')
        self.fields['notes'] = Field(attribute='notes')

    def get_export_headers(self):
        return [u'单号', u'客户', u'产品', u'合计数量', u'合计金额', u'创建时间', u'创建人', u'所属部门', u'审核状态', u'审核时间', u'审核人', u'备注']

    class Meta:
        fields = ('no', 'customer_text', 'goods_text','total_count', 'total_amount', 'create_time', 'create_user_text', 'department_text', 'status_text',
                  'check_time', 'check_user_text', 'notes')
        export_order = fields

class SalePlanDetailResource(resources.Resource):

    def __init__(self):
        super(SalePlanDetailResource, self).__init__()
        self.fields['goods_text'] = Field(attribute='goods_text')
        self.fields['goods_model'] = Field(attribute='goods_model')
        self.fields['quality_request_text'] = Field(attribute='quality_request_text')
        self.fields['require_count'] = Field(attribute='require_count')
        self.fields['price'] = Field(attribute='price')
        self.fields['require_time'] = Field(attribute='require_time')
        self.fields['current_count'] = Field(attribute='current_count')
        self.fields['require_production_count'] = Field(attribute='require_production_count')

    def get_export_headers(self):
        return [u'产品名称', u'产品代码', u'质量要求', u'数量', u'单价', u'需求时间', u'当前库存', u'需生产']

    class Meta:
        fields = ('goods_text', 'goods_model', 'quality_request_text', 'require_count', 'price', 'require_time', 'current_count',
                  'require_production_count')
        export_order = fields
