U
    i                    @   s  d dl mZ d dlmZ dd Zdd Zdd Zd	d
 Zdd Zdd Z	dd Z
dd Zdd Zdd Zdd Zdd Zdd Zdd Zdd  Zd!d" Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Zd-d. Zd/d0 Zd1d2 Zd3d4 Zd5d6 Zd7d8 Zd9d: Zd;d< Z d=d> Z!d?d@ Z"dAdB Z#dCdD Z$dEdF Z%e&ee& dGdHdIZ'dJdK Z(ddLdMZ)dNdO Z*ddPdQZ+ddRdSZ,dTdU Z-dVdW Z.ddXdYZ/dZd[ Z0dd\d]Z1dd^d_Z2dd`daZ3dbdc Z4ddde Z5dfdg Z6ddhdiZ7djdk Z8dldm Z9dndo Z:dpdq Z;ddrdsZ<dtdu Z=ddvdwZ>ddydzZ?dd{d|Z@dd}d~ZAdd ZBdd ZCdddZDdddZEdd ZFdddZGdddZHdd ZIdd ZJdddZKdd ZLdddZMdddZNdddZOdd ZPdd ZQdddZRdddZSdd ZTdd ZUdd ZVdd ZWdd ZXdd ZYdd ZZdS )    )get_connection)Listc               
   C   s   d} zz@t }|std| }||  | }dd |D W W BS  tk
r } ztd|  g  W Y W S d}~X Y nX W 5 |r|   X dS )zeObtiene los tipos de combustibles disponibles.
    Retorna una lista de diccionarios con ID y Nombre.aP  
    SELECT DISTINCT
        CZE_FuelType.FuelTypeID,
        CZE_FuelType.Front
    FROM 
        CZE_Genset
    JOIN 
        CZE_EngineModel ON CZE_Genset.EngineModel = CZE_EngineModel.EngineModel
    JOIN 
        CZE_FuelType ON CZE_EngineModel.FuelTypeBack = CZE_FuelType.Back
    JOIN 
        CZE_GensetConfig ON CZE_Genset.GensetModel = CZE_GensetConfig.GensetModel
    JOIN 
        CZE_GensetCost ON CZE_GensetConfig.ConfigID = CZE_GensetCost.ConfigID
    WHERE
        CZE_Genset.Active = 1
        AND CZE_FuelType.Front IS NOT NULL
        AND CZE_GensetCost.Evaluator >= 1
    4   No se pudo establecer conexión con la base de datosc                 S   s   g | ]}|d  |d dqS )r      )idZFueltype .0rowr   r   jC:\Users\victor.barrera\Documents\proyectos\elepV3\Elep\src\Consultas_SQL\Ventas\VentasEUA\CotizadorSQL.py
<listcomp>'   s     z get_fueltype.<locals>.<listcomp>z:[Error inesperado] Error obteniendo tipos de combustible: N)closer   ConnectionErrorcursorexecutefetchall	Exceptionprint)queryconnr   resultser   r   r   get_fueltype   s    
"r   c               
   C   s   d} zDt  4}| }||  dd | D W  5 Q R  W S Q R X W n8 tk
r } ztd|  g  W Y S d }~X Y nX d S )Nz(select * from StopButtonEnclosureOptionsc                 S   s*   g | ]"}|d  |d |d |d dqS )r   r         )stop_idZstop_decriptionZ
stop_priceZstop_technicalSheetr   r   r   r   r   r   6   s     z.getAll_StopButtonEnclosure.<locals>.<listcomp>"Error obteniendo marcas de motor: r   r   r   r   r   r   r   r   r   r   r   r   r   getAll_StopButtonEnclosure0   s    
*r   c               
   C   s   d} zDt  4}| }||  dd | D W  5 Q R  W S Q R X W n8 tk
r } ztd|  g  W Y S d }~X Y nX d S )Nzselect * from louvers_inc                 S   s*   g | ]"}|d  |d |d |d dqS )r   r   r   r   )Zlouvers_in_idZlouvers_in_decriptionlouvers_in_priceZlouvers_in_technicalSheetr   r   r   r   r   r   B   s     z%getAll_louvers_in.<locals>.<listcomp>r   r   r   r   r   r   getAll_louvers_in<   s    
*r!   c               
   C   s   d} zDt  4}| }||  dd | D W  5 Q R  W S Q R X W n8 tk
r } ztd|  g  W Y S d }~X Y nX d S )Nzselect * from louvers_outc                 S   s*   g | ]"}|d  |d |d |d dqS )r   r   r   r   )Zlouvers_out_idZlouvers_out_decriptionlouvers_out_priceZlouvers_out_technicalSheetr   r   r   r   r   r   N   s     z&getAll_louvers_out.<locals>.<listcomp>r   r   r   r   r   r   getAll_louvers_outH   s    
*r#   c              
   C   s   d}zJt  :}| }|||  | }dd |D W  5 Q R  W S Q R X W n8 tk
r } ztd|  g  W Y S d}~X Y nX dS )zObtiene las capacidades KW disponibles para un tipo de combustible.
    Args:
        fuel_type (str): Tipo de combustible seleccionado
    Returns:
        list: Lista de diccionarios con las capacidades KW disponibles
    aS  
    SELECT DISTINCT
        CZE_Genset.KWOutput
    FROM 
        CZE_Genset
    JOIN 
        CZE_EngineModel ON CZE_Genset.EngineModel = CZE_EngineModel.EngineModel
    JOIN 
        CZE_FuelType ON CZE_EngineModel.FuelTypeBack = CZE_FuelType.Back
    JOIN 
        CZE_GensetConfig ON CZE_Genset.GensetModel = CZE_GensetConfig.GensetModel
    JOIN 
        CZE_GensetCost ON CZE_GensetConfig.ConfigID = CZE_GensetCost.ConfigID
    WHERE
        CZE_Genset.Active = 1
        AND CZE_FuelType.Front = ?
        AND CZE_GensetCost.Evaluator >= 1
    ORDER BY 
        CZE_Genset.KWOutput;
    c                 S   s   g | ]}d |d iqS )ZKWr   r   r   r   r   r   r   w   s     z"get_kw_by_fuel.<locals>.<listcomp>z!Error obteniendo capacidades KW: Nr   )	fuel_typer   r   r   r   r   r   r   r   get_kw_by_fuelV   s    &r%   c              
   C   s   d}zJt  :}| }||| |f dd | D W  5 Q R  W S Q R X W n8 tk
r } ztd|  g  W Y S d}~X Y nX dS )u0  Obtiene las marcas de motor disponibles según el tipo de combustible y KW seleccionados.
    Args:
        fuel_type (str): Tipo de combustible seleccionado
        kw_output (int): Capacidad KW seleccionada
    Returns:
        list: Lista de diccionarios con id y marca de los motores disponibles
    a7  
    SELECT DISTINCT
        CZE_EngineBrand.EngineBrandID,
        CZE_EngineBrand.EngineBrand
    FROM 
        CZE_Genset
    JOIN 
        CZE_EngineModel ON CZE_Genset.EngineModel = CZE_EngineModel.EngineModel
    JOIN 
        CZE_FuelType ON CZE_EngineModel.FuelTypeBack = CZE_FuelType.Back
    JOIN 
        CZE_EngineBrand ON CZE_EngineModel.EngineBrandID = CZE_EngineBrand.EngineBrandID
    JOIN 
        CZE_GensetConfig ON CZE_Genset.GensetModel = CZE_GensetConfig.GensetModel
    JOIN 
        CZE_GensetCost ON CZE_GensetConfig.ConfigID = CZE_GensetCost.ConfigID
    WHERE
        CZE_Genset.Active = 1
        AND CZE_EngineBrand.Active = 1
        AND CZE_FuelType.Front = ?
        AND CZE_Genset.KWOutput = ?
        AND CZE_GensetCost.Evaluator >= 1
    ORDER BY 
        CZE_EngineBrand.EngineBrand
    c                 S   s   g | ]}|d  |d dqS r   r   )r   Zbrandr   r   r   r   r   r      s     z%get_engine_brands.<locals>.<listcomp>r   Nr   )r$   	kw_outputr   r   r   r   r   r   r   get_engine_brands|   s    *r(   c              
   C   s   d}zLt  <}| }||| ||f dd | D W  5 Q R  W S Q R X W n8 tk
r } ztd|  g  W Y S d}~X Y nX dS )us  Obtiene las marcas de alternador disponibles según los parámetros seleccionados.
    Args:
        fuel_type (str): Tipo de combustible seleccionado
        kw_output (int): Capacidad KW seleccionada
        engine_brand_id (str): ID de la marca del motor seleccionado
    Returns:
        list: Lista de diccionarios con id y marca de los alternadores disponibles
    a  
    SELECT DISTINCT
        CZE_AlternatorBrand.AlternatorBrandID,
        CZE_AlternatorBrand.AlternatorBrand
    FROM 
        CZE_Genset
    JOIN 
        CZE_EngineModel ON CZE_Genset.EngineModel = CZE_EngineModel.EngineModel
    JOIN 
        CZE_FuelType ON CZE_EngineModel.FuelTypeBack = CZE_FuelType.Back
    JOIN 
        CZE_EngineBrand ON CZE_EngineModel.EngineBrandID = CZE_EngineBrand.EngineBrandID
    JOIN 
        CZE_AlternatorBrand ON CZE_Genset.AlternatorBrandID = CZE_AlternatorBrand.AlternatorBrandID
    JOIN 
        CZE_GensetConfig ON CZE_Genset.GensetModel = CZE_GensetConfig.GensetModel
    JOIN 
        CZE_GensetCost ON CZE_GensetConfig.ConfigID = CZE_GensetCost.ConfigID
    WHERE
        CZE_Genset.Active = 1
        AND CZE_EngineBrand.Active = 1
        AND CZE_AlternatorBrand.Active = 1
        AND CZE_FuelType.Front = ?
        AND CZE_Genset.KWOutput = ?
        AND CZE_EngineBrand.EngineBrandID = ?
        AND CZE_GensetCost.Evaluator >= 1
    ORDER BY 
        CZE_AlternatorBrand.AlternatorBrand
    c                 S   s   g | ]}|d  |d dqS r&   r   r   r   r   r   r      s     z)get_alternator_brands.<locals>.<listcomp>z'Error obteniendo marcas de alternador: Nr   )r$   r'   engine_brand_idr   r   r   r   r   r   r   get_alternator_brands   s    	*r*   c              
   C   s   d}zNt  >}| }||| |||f dd | D W  5 Q R  W S Q R X W n8 tk
r } ztd|  g  W Y S d}~X Y nX dS )u  Obtiene los voltajes disponibles según los parámetros seleccionados.
    Args:
        fuel_type (str): Tipo de combustible seleccionado
        kw_output (int): Capacidad KW seleccionada
        engine_brand_id (str): ID de la marca del motor seleccionado
        alternator_brand_id (str): ID de la marca del alternador seleccionado
    Returns:
        list: Lista de diccionarios con id y voltaje disponibles
    a|  
    SELECT DISTINCT
        CZE_Voltage.VoltageID,
        CZE_Voltage.Voltage_Front
    FROM 
        CZE_Genset
    JOIN 
        CZE_EngineModel ON CZE_Genset.EngineModel = CZE_EngineModel.EngineModel
    JOIN 
        CZE_FuelType ON CZE_EngineModel.FuelTypeBack = CZE_FuelType.Back
    JOIN 
        CZE_EngineBrand ON CZE_EngineModel.EngineBrandID = CZE_EngineBrand.EngineBrandID
    JOIN 
        CZE_AlternatorBrand ON CZE_Genset.AlternatorBrandID = CZE_AlternatorBrand.AlternatorBrandID
    JOIN 
        CZE_GensetConfig ON CZE_Genset.GensetModel = CZE_GensetConfig.GensetModel
    JOIN 
        CZE_Voltage ON CZE_GensetConfig.VoltageID = CZE_Voltage.VoltageID
    JOIN 
        CZE_GensetCost ON CZE_GensetConfig.ConfigID = CZE_GensetCost.ConfigID
    WHERE
        CZE_Genset.Active = 1
        AND CZE_EngineBrand.Active = 1
        AND CZE_AlternatorBrand.Active = 1
        AND CZE_FuelType.Front = ?
        AND CZE_Genset.KWOutput = ?
        AND CZE_EngineBrand.EngineBrandID = ?
        AND CZE_AlternatorBrand.AlternatorBrandID = ?
        AND CZE_GensetCost.Evaluator >= 1
    ORDER BY 
        CZE_Voltage.Voltage_Front
    c                 S   s   g | ]}|d  |d dqS )r   r   )r   Zvoltager   r   r   r   r   r     s     z get_voltages.<locals>.<listcomp>zError obteniendo voltajes: Nr   )r$   r'   r)   alternator_brand_idr   r   r   r   r   r   r   get_voltages   s    
 *r,   c           	   
   C   s   d}zPt  @}| }||| ||||f dd | D W  5 Q R  W S Q R X W n8 tk
r } ztd|  g  W Y S d}~X Y nX dS )u  Obtiene las certificaciones disponibles según los parámetros seleccionados.
    Args:
        fuel_type (str): Tipo de combustible seleccionado
        kw_output (int): Capacidad KW seleccionada
        engine_brand_id (str): ID de la marca del motor seleccionado
        alternator_brand_id (str): ID de la marca del alternador seleccionado
        voltage_id (int): ID del voltaje seleccionado
    Returns:
        list: Lista de diccionarios con id y certificación disponibles
    a&  
    SELECT DISTINCT
        CZE_Certification.CertificationID,
        CZE_Certification.Certification
    FROM 
        CZE_Genset
    JOIN 
        CZE_EngineModel ON CZE_Genset.EngineModel = CZE_EngineModel.EngineModel
    JOIN 
        CZE_FuelType ON CZE_EngineModel.FuelTypeBack = CZE_FuelType.Back
    JOIN 
        CZE_EngineBrand ON CZE_EngineModel.EngineBrandID = CZE_EngineBrand.EngineBrandID
    JOIN 
        CZE_AlternatorBrand ON CZE_Genset.AlternatorBrandID = CZE_AlternatorBrand.AlternatorBrandID
    JOIN 
        CZE_GensetConfig ON CZE_Genset.GensetModel = CZE_GensetConfig.GensetModel
    JOIN 
        CZE_Voltage ON CZE_GensetConfig.VoltageID = CZE_Voltage.VoltageID
    JOIN 
        CZE_Certification ON CZE_GensetConfig.CertificationID = CZE_Certification.CertificationID
    JOIN 
        CZE_GensetCost ON CZE_GensetConfig.ConfigID = CZE_GensetCost.ConfigID
    WHERE
        CZE_Genset.Active = 1
        AND CZE_EngineBrand.Active = 1
        AND CZE_AlternatorBrand.Active = 1
        AND CZE_FuelType.Front = ?
        AND CZE_Genset.KWOutput = ?
        AND CZE_EngineBrand.EngineBrandID = ?
        AND CZE_AlternatorBrand.AlternatorBrandID = ?
        AND CZE_Voltage.VoltageID = ?
        AND CZE_GensetCost.Evaluator >= 1
    ORDER BY 
        CZE_Certification.Certification
    c                 S   s   g | ]}|d  |d dqS )r   r   )r   Zcertificationr   r   r   r   r   r   :  s     z&get_certifications.<locals>.<listcomp>z"Error obteniendo certificaciones: Nr   )	r$   r'   r)   r+   
voltage_idr   r   r   r   r   r   r   get_certifications  s    #*r.   c               
   C   sF   d} t  2}| }||  dd | D W  5 Q R  S Q R X d S )Na.  
    SELECT 
        [CZE_BreakersCatalog].[Item_breaker],
        [CZE_BreakersCatalog].[description],
        ISNULL([CZE_BreakersCatalog].[price], 0) AS price,
        [CZE_BreakersCatalog].[type]
    FROM 
        [CZE_BreakersCatalog]
    ORDER BY 
        [CZE_BreakersCatalog].[description]
    c                 S   s*   g | ]"}|d  |d |d |d dqS )r   r   r   r   )r   descriptionpricetyper   r   r   r   r   r   N  s     z'get_breaker_catalog.<locals>.<listcomp>r   r   r   r   )r   r   r   r   r   r   get_breaker_catalog?  s
    
r3   c              
   C   sH   d}t  4}| }|||  dd | D W  5 Q R  S Q R X d S )Na  
    SELECT 
        [CZE_BreakerProtectionType].[Item_breaker_Protection],
        [CZE_BreakerProtectionType].[description],
        ISNULL([CZE_BreakerProtectionType].[price], 0) AS price
    FROM 
        [CZE_BreakerProtectionType]
    WHERE
        [CZE_BreakerProtectionType].[TypeBreaker] = ?
    ORDER BY 
        [CZE_BreakerProtectionType].[Item_breaker_Protection] asc
    c                 S   s$   g | ]}|d  |d |d dqS )r   r   r   )r   r/   r0   r   r   r   r   r   r   `  s     z(get_protection_types.<locals>.<listcomp>r2   )breaker_typer   r   r   r   r   r   get_protection_typesP  s
    r5   c           
   
   C   s   d}zRt  B}| }||| |||||f dd | D W  5 Q R  W S Q R X W n8 tk
r }	 ztd|	  g  W Y S d}	~	X Y nX dS )u>  Obtiene las marcas de controlador disponibles según los parámetros seleccionados.
    Args:
        fuel_type (str): Tipo de combustible seleccionado
        kw_output (int): Capacidad KW seleccionada
        engine_brand_id (str): ID de la marca del motor seleccionado
        alternator_brand_id (str): ID de la marca del alternador seleccionado
        voltage_id (int): ID del voltaje seleccionado
        certification_id (str): ID de la certificación seleccionada
    Returns:
        list: Lista de diccionarios con id y marca de los controladores disponibles
    a  
    SELECT DISTINCT
        CZE_ControllerBrand.BrandID,
        CZE_ControllerBrand.Brand
    FROM 
        CZE_Genset
    JOIN 
        CZE_EngineModel ON CZE_Genset.EngineModel = CZE_EngineModel.EngineModel
    JOIN 
        CZE_FuelType ON CZE_EngineModel.FuelTypeBack = CZE_FuelType.Back
    JOIN 
        CZE_EngineBrand ON CZE_EngineModel.EngineBrandID = CZE_EngineBrand.EngineBrandID
    JOIN 
        CZE_AlternatorBrand ON CZE_Genset.AlternatorBrandID = CZE_AlternatorBrand.AlternatorBrandID
    JOIN 
        CZE_GensetConfig ON CZE_Genset.GensetModel = CZE_GensetConfig.GensetModel
    JOIN 
        CZE_Voltage ON CZE_GensetConfig.VoltageID = CZE_Voltage.VoltageID
    JOIN 
        CZE_Certification ON CZE_GensetConfig.CertificationID = CZE_Certification.CertificationID
    JOIN 
        CZE_GensetCost ON CZE_GensetConfig.ConfigID = CZE_GensetCost.ConfigID
    JOIN 
        CZE_ControllerBrand ON CZE_GensetCost.ControllerBrandID = CZE_ControllerBrand.BrandID
    WHERE
        CZE_Genset.Active = 1
        AND CZE_EngineBrand.Active = 1
        AND CZE_AlternatorBrand.Active = 1
        AND CZE_FuelType.Front = ?
        AND CZE_Genset.KWOutput = ?
        AND CZE_EngineBrand.EngineBrandID = ?
        AND CZE_AlternatorBrand.AlternatorBrandID = ?
        AND CZE_Voltage.VoltageID = ?
        AND CZE_Certification.CertificationID = ?
        AND CZE_GensetCost.Evaluator >= 1
    ORDER BY 
        CZE_ControllerBrand.Brand
    c                 S   s   g | ]}|d  |d dqS r&   r   r   r   r   r   r     s     z&get_control_brands.<locals>.<listcomp>z(Error obteniendo marcas de controlador: Nr   )
r$   r'   r)   r+   r-   certification_idr   r   r   r   r   r   r   get_control_brandsb  s    &*r7   c              
   C   s   d}zFt  6}| }|||  dd | D W  5 Q R  W S Q R X W n8 tk
r } ztd|  g  W Y S d}~X Y nX dS )u   Obtiene los modelos de controlador disponibles para una marca específica.
    Args:
        control_brand_id (str): ID de la marca del controlador
    Returns:
        list: Lista de diccionarios con item y descripción de los modelos
    a  
    SELECT DISTINCT
        CZE_ControllerCatalog.Item_controller,
        CZE_ControllerCatalog.description
    FROM 
        CZE_ControllerCatalog
    WHERE
        CZE_ControllerCatalog.BrandID = ?
    ORDER BY 
        CZE_ControllerCatalog.description
    c                 S   s   g | ]}|d  |d dqS r   r   )itemr/   r   r   r   r   r   r     s     z&get_control_models.<locals>.<listcomp>z)Error obteniendo modelos de controlador: Nr   )control_brand_idr   r   r   r   r   r   r   get_control_models  s    *r;   c               
   C   s   d} zDt  4}| }||  dd | D W  5 Q R  W S Q R X W n8 tk
r } ztd|  g  W Y S d }~X Y nX d S )Na#  
    SELECT 
        [CZE_ControllerPreheater].[Item_preheater_volt],
        [CZE_ControllerPreheater].[description],
        ISNULL([CZE_ControllerPreheater].[price], 0) AS price
    FROM 
        [CZE_ControllerPreheater]
    ORDER BY 
        [CZE_ControllerPreheater].[description]
    c                 S   s4   g | ],}|d  |d |d r(t |d nd dqS r   r   r   )r9   r/   r0   floatr   r   r   r   r     s
   z*get_preheater_voltages.<locals>.<listcomp>z,Error obteniendo voltajes de precalentador: r   r   r   r   r   get_preheater_voltages  s    

r?   c               
   C   s   d} zDt  4}| }||  dd | D W  5 Q R  W S Q R X W n8 tk
r } ztd|  g  W Y S d }~X Y nX d S )Na-  
    SELECT 
        [CZE_ControllerBattCharger].[Item_batterycharger],
        [CZE_ControllerBattCharger].[description],
        ISNULL([CZE_ControllerBattCharger].[price], 0) AS price
    FROM 
        [CZE_ControllerBattCharger]
    ORDER BY 
        [CZE_ControllerBattCharger].[description]
    c                 S   s4   g | ],}|d  |d |d r(t |d nd dqS r<   r=   r   r   r   r   r     s
   z(get_battery_chargers.<locals>.<listcomp>u)   Error obteniendo cargadores de batería: r   r   r   r   r   get_battery_chargers  s    

r@   c              
   C   s   d}zLt  <}| }||| ||f dd | D W  5 Q R  W S Q R X W n8 tk
r } ztd|  g  W Y S d}~X Y nX dS )uM   Obtiene los tipos de caseta disponibles según los parámetros seleccionados.a  
    SELECT DISTINCT
        CZE_EnclosureType.Item_Enclosuree_type,
        CZE_EnclosureType.Front
    FROM
        CZE_EnclosureType
    JOIN 
        CZE_EnclosureConfig ON CZE_EnclosureType.Item_Enclosuree_type = CZE_EnclosureConfig.Item_Enclosure_type
    JOIN 
        CZE_FuelType ON CZE_EnclosureConfig.FuelType = CZE_FuelType.Back

    WHERE
        CZE_FuelType.Front = ?
        AND CZE_EnclosureConfig.KWOutput = ?
        AND CZE_EnclosureConfig.CertificationID = ?
        AND CZE_EnclosureConfig.Evaluator >= 1
    c                 S   s   g | ]}|d  |d dqS r8   r   r   r   r   r   r     s     z'get_enclosure_types.<locals>.<listcomp>z"Error obteniendo tipos de caseta: Nr   )r$   r'   r6   r   r   r   r   r   r   r   get_enclosure_types  s    *rA   c              
   C   s   d}zNt  >}| }||| |||f dd | D W  5 Q R  W S Q R X W n8 tk
r } ztd|  g  W Y S d}~X Y nX dS )uR   Obtiene los materiales de caseta disponibles según los parámetros seleccionados.ac  
    SELECT DISTINCT
        CZE_EnclosureMaterial.Item_Eclousure_Mat,
        CZE_EnclosureMaterial.description
    FROM
        CZE_EnclosureMaterial
    JOIN 
        CZE_EnclosureConfig ON CZE_EnclosureMaterial.Item_Eclousure_Mat = CZE_EnclosureConfig.Item_Enclosure_Mat
    JOIN 
        CZE_FuelType ON CZE_EnclosureConfig.FuelType = CZE_FuelType.Back        
    WHERE
        CZE_FuelType.Front = ?
        AND CZE_EnclosureConfig.KWOutput = ?
        AND CZE_EnclosureConfig.CertificationID = ?
        AND CZE_EnclosureConfig.Item_Enclosure_type = ?
        AND CZE_EnclosureConfig.Evaluator >= 1
    c                 S   s   g | ]}|d  |d dqS r8   r   r   r   r   r   r     s     z+get_enclosure_materials.<locals>.<listcomp>z'Error obteniendo materiales de caseta: Nr   )r$   r'   r6   enclosure_typer   r   r   r   r   r   r   get_enclosure_materials  s    *rC   c               
   C   s   d} zDt  4}| }||  dd | D W  5 Q R  W S Q R X W n8 tk
r } ztd|  g  W Y S d }~X Y nX d S )Nz
    SELECT DISTINCT
        [CZE_EnclosureLight].[Item_Enclosure_ligth],
        [CZE_EnclosureLight].[description]
    FROM
        [CZE_EnclosureLight]
    WHERE
        [CZE_EnclosureLight].[type] = 'AC'
    c                 S   s   g | ]}|d  |d dqS r8   r   r   r   r   r   r   .  s   z+get_enclosure_lights_ac.<locals>.<listcomp>z%Error obteniendo luces AC de caseta: r   r   r   r   r   get_enclosure_lights_ac   s    	
rD   c               
   C   s   d} zDt  4}| }||  dd | D W  5 Q R  W S Q R X W n8 tk
r } ztd|  g  W Y S d }~X Y nX d S )Nz
    SELECT DISTINCT
        [CZE_EnclosureLight].[Item_Enclosure_ligth],
        [CZE_EnclosureLight].[description]
    FROM
        [CZE_EnclosureLight]
    WHERE
        [CZE_EnclosureLight].[type] = 'DC'
    c                 S   s   g | ]}|d  |d dqS r8   r   r   r   r   r   r   D  s   z+get_enclosure_lights_dc.<locals>.<listcomp>z%Error obteniendo luces DC de caseta: r   r   r   r   r   get_enclosure_lights_dc6  s    	
rE   c               
   C   s   d} zDt  4}| }||  dd | D W  5 Q R  W S Q R X W n8 tk
r } ztd|  g  W Y S d }~X Y nX d S )Nz
    SELECT DISTINCT
        [CZE_EnclosureSpaceHeater].[Item_Enclosure_SHeater],
        [CZE_EnclosureSpaceHeater].[description]
    FROM
        [CZE_EnclosureSpaceHeater]
    c                 S   s   g | ]}|d  |d dqS r8   r   r   r   r   r   r   X  s   z/get_enclosure_space_heaters.<locals>.<listcomp>z*Error obteniendo calentadores de espacio: r   r   r   r   r   get_enclosure_space_heatersL  s    
rF   c               
   C   s   d} zDt  4}| }||  dd | D W  5 Q R  W S Q R X W n8 tk
r } ztd|  g  W Y S d }~X Y nX d S )Nz
    SELECT DISTINCT
        [CZE_EnclosureLoadCenter].[Item_Enclosure_LCenter],
        [CZE_EnclosureLoadCenter].[description]
    FROM
        [CZE_EnclosureLoadCenter]
    c                 S   s   g | ]}|d  |d dqS r8   r   r   r   r   r   r   l  s   z.get_enclosure_load_centers.<locals>.<listcomp>z#Error obteniendo centros de carga: r   r   r   r   r   get_enclosure_load_centers`  s    
rG   c               
   C   s   d} zDt  4}| }||  dd | D W  5 Q R  W S Q R X W n8 tk
r } ztd|  g  W Y S d}~X Y nX dS )uq   Obtiene las opciones de paro de emergencia remoto.
    Retorna una lista de diccionarios con item y descripción.z
    SELECT DISTINCT
        [CZE_AddAccesory_Estop].[Item_AddAccesory_Estop],
        [CZE_AddAccesory_Estop].[description]
    FROM
        [CZE_AddAccesory_Estop]
    c                 S   s   g | ]}|d  |d dqS r8   r   r   r   r   r   r     s   z%get_estop_catalog.<locals>.<listcomp>z1Error obteniendo opciones de paro de emergencia: Nr   r   r   r   r   get_estop_catalogt  s    
rH   c               
   C   s   d} zDt  4}| }||  dd | D W  5 Q R  W S Q R X W n8 tk
r } ztd|  g  W Y S d}~X Y nX dS )uk   Obtiene las opciones de resorte de aislador.
    Retorna una lista de diccionarios con item y descripción.z
    SELECT DISTINCT
        [CZE_AddAccesory_Spring].[Item_AddAccesory_Spring],
        [CZE_AddAccesory_Spring].[description]
    FROM
        [CZE_AddAccesory_Spring]
    c                 S   s   g | ]}|d  |d dqS r8   r   r   r   r   r   r     s   z&get_spring_catalog.<locals>.<listcomp>z2Error obteniendo opciones de resorte de aislador: Nr   r   r   r   r   get_spring_catalog  s    
rI   c              
   C   s   d}zFt  6}| }|||  dd | D W  5 Q R  W S Q R X W n8 tk
r } ztd|  g  W Y S d}~X Y nX dS )zFObtiene las capacidades de tanque disponibles para el KW seleccionado.aQ  
    SELECT DISTINCT
        CZE_TankAutonomy.Item_Tank_Autonomy,
        CZE_TankAutonomy.description
    FROM
        CZE_TankAutonomy
    JOIN 
        CZE_TankConfig ON CZE_TankAutonomy.Item_Tank_Autonomy = CZE_TankConfig.Item_Tank_Autonomy
    WHERE
        CZE_TankConfig.KWOutput = ?
        AND CZE_TankConfig.Evaluator >= 1
    c                 S   s   g | ]}|d  |d dqS r8   r   r   r   r   r   r     s     z-get_tank_capacity_catalog.<locals>.<listcomp>z(Error obteniendo capacidades de tanque: Nr   r'   r   r   r   r   r   r   r   get_tank_capacity_catalog  s    *rK   c              
   C   s   d}zJt  :}| }||| |f dd | D W  5 Q R  W S Q R X W n8 tk
r } ztd|  g  W Y S d}~X Y nX dS )uM   Obtiene los tipos de tanque disponibles según los parámetros seleccionados.ag  
    SELECT DISTINCT
        CZE_TankType.Item_Tank_type,
        CZE_TankType.description
    FROM
        CZE_TankType
    JOIN 
        CZE_TankConfig ON CZE_TankType.Item_Tank_type = CZE_TankConfig.Item_Tank_type
    WHERE
        CZE_TankConfig.KWOutput = ?
        AND CZE_TankConfig.Item_Tank_Autonomy = ?
        AND CZE_TankConfig.Evaluator >= 1
    c                 S   s   g | ]}|d  |d dqS r8   r   r   r   r   r   r     s     z)get_tank_type_catalog.<locals>.<listcomp>z"Error obteniendo tipos de tanque: Nr   )r'   tank_autonomyr   r   r   r   r   r   r   get_tank_type_catalog  s    *rM   c               
   C   s   d} zDt  4}| }||  dd | D W  5 Q R  W S Q R X W n8 tk
r } ztd|  g  W Y S d}~X Y nX dS )uo   Obtiene las opciones de contención de derrames.
    Retorna una lista de diccionarios con item y descripción.z
    SELECT DISTINCT
        [CZE_TankSpillCont].[Item_Tank_SpillCont],
        [CZE_TankSpillCont].[description]
    FROM
        [CZE_TankSpillCont]
    c                 S   s   g | ]}|d  |d dqS r8   r   r   r   r   r   r     s   z1get_spill_containment_catalog.<locals>.<listcomp>u6   Error obteniendo opciones de contención de derrames: Nr   r   r   r   r   get_spill_containment_catalog  s    
rN   c               
   C   s   d} zDt  4}| }||  dd | D W  5 Q R  W S Q R X W n8 tk
r } ztd|  g  W Y S d}~X Y nX dS )n   Obtiene las opciones de garantías disponibles.
    Retorna una lista de diccionarios con item y descripción.z
    SELECT DISTINCT
        [CZE_PrjWarCountry].[Item_PrjWar_Country],
        [CZE_PrjWarCountry].[description]
    FROM
        [CZE_PrjWarCountry]
    c                 S   s   g | ]}|d  |d dqS r8   r   r   r   r   r   r     s   z get_countrys.<locals>.<listcomp>(   Error obteniendo opciones de garantía: Nr   r   r   r   r   get_countrys  s    
rQ   c               
   C   s   d} zDt  4}| }||  dd | D W  5 Q R  W S Q R X W n8 tk
r } ztd|  g  W Y S d}~X Y nX dS )rO   z
    SELECT DISTINCT
        [CZE_PrjWarWarranty].[Item_PrjWar_Warranty],
        [CZE_PrjWarWarranty].[description]
    FROM
        [CZE_PrjWarWarranty]
    c                 S   s   g | ]}|d  |d dqS r8   r   r   r   r   r   r     s   z(get_warranty_catalog.<locals>.<listcomp>rP   Nr   r   r   r   r   get_warranty_catalog  s    
rR   c              
   C   s   d}zFt  6}| }|||  dd | D W  5 Q R  W S Q R X W n8 tk
r } ztd|  g  W Y S d}~X Y nX dS )z8Obtiene las pruebas disponibles para el KW seleccionado.ap  
    SELECT DISTINCT
        CZE_PrjWarTesting.Item_PrjWar_Testing,
        CZE_PrjWarTesting.description
    FROM
        CZE_PrjWarTesting
    JOIN 
        CZE_PrjWarTestConfig ON CZE_PrjWarTesting.Item_PrjWar_Testing = CZE_PrjWarTestConfig.Item_PrjWar_Testing
    WHERE
        CZE_PrjWarTestConfig.KWOutput = ?
        AND CZE_PrjWarTestConfig.Evaluator >= 1
    c                 S   s   g | ]}|d  |d dqS r8   r   r   r   r   r   r   *  s     z'get_testing_catalog.<locals>.<listcomp>zError obteniendo pruebas: Nr   rJ   r   r   r   get_testing_catalog  s    *rS   c                 C   s   d}zzt }|std| }||| f | }|r|d |d |d |d |d |d |d	 |d
 |d |d |d |d |d |d dW W JS W W BdS  tk
r } ztd|  W Y W dS d}~X Y nX W 5 |r|   X dS )us   Obtiene la información del perfil completo del usuario.
    Retorna un diccionario con la información del perfil.a#  
    SELECT 
        Users.UserID,
        Users.RequestTypeID,
        Profiles.ProfileID,
        Profiles.Discount,
        Profiles.BusinessName,
        Profiles.FiscalAddress,
        Profiles.PrimaryContact,
        Profiles.Email,
        Profiles.ContactPhone,
        Profiles.FirstName,
        Profiles.MiddleName,
        Profiles.LastName,
        Profiles.SecondLastName,
        Profiles.SellerUserID
    FROM 
        Users
    LEFT JOIN 
        Profiles ON Users.UserID = Profiles.UserID
    WHERE 
        Users.UserID = ?
    r   r   r   r   r                  	   
            )UserIDRequestTypeIDZ	ProfileIDDiscountZBusinessNameZFiscalAddressZPrimaryContactEmailContactPhone	FirstName
MiddleNameLastNameSecondLastNameSellerUserIDNu=   [Error inesperado] Error obteniendo información del perfil: r   r   r   r   r   fetchoner   r   )user_idr   r   r   resultr   r   r   r   get_profile_info/  s<    
 rl   c              
   C   s   d}zznt }|std| }||| f | }|rl|d |d |d |d |d |d d	W W JS W W Bd
S  tk
r } ztd|  W Y W d
S d
}~X Y nX W 5 |r|   X d
S )u}   Obtiene la información del vendedor asignado a un distribuidor.
    Retorna un diccionario con la información del vendedor.z
    SELECT 
        Profiles.FirstName,
        Profiles.MiddleName,
        Profiles.LastName,
        Profiles.SecondLastName,
        Profiles.Email,
        Profiles.ContactPhone
    FROM 
        Profiles
    WHERE 
        Profiles.UserID = ?
    r   r   r   r   r   rT   rU   )rc   rd   re   rf   ra   rb   Nu?   [Error inesperado] Error obteniendo información del vendedor: rh   )Zseller_user_idr   r   r   rk   r   r   r   r   get_seller_infok  s,    
 rm   c              
   C   s   d}zZt  J}| }||| f | }|rB|W  5 Q R  W S W 5 Q R  W dS W 5 Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )uW   
    Obtiene el valor del descuento por pais, en función del id de la cotización
    a  
        SELECT
            CZE_Quotes.QuoteID,
            CZE_Quotes.Destiny_Country,
            CZE_Quotes.Destiny_State,
            CZE_Countries.isDiscount,
            CZE_Countries.percents
        FROM 
            CZE_Quotes  
            JOIN CZE_Countries 
            ON  CZE_Quotes.Destiny_Country = CZE_Countries.CountryID

        WHERE 
            CZE_Quotes.QuoteID = ?

    Nz#Error al obtener datos de Country: r   r   r   ri   r   r   )quote_idr   r   r   rk   r   r   r   r   get_discount_country_value  s    rp   c              
   C   s   d}z@t  0}| }||||| f |  td W 5 Q R X W n8 tk
r| } ztd|  d|   W 5 d}~X Y nX dS )zt
    Actualiza los valores de los precios de CommercialOffer y de CountryDiscount en la 
    tabla de CZE_Quote
    z
    
        UPDATE CZE_Quotes 
        SET 
            Country_Discount = ?,
            Commercial_Offer = ?
        WHERE
            QuoteID  = ?

    z1EXITO, VALORES COMERCIALES ACTUALIZADOS CON EXITOu0   Error actualizado los precios de la cotizaciòn : N)r   r   r   commitr   r   )ro   Zcountry_discountZcommercial_offerr   r   r   r   r   r   r    update_commercial_country_values  s    rs   c           
         s  ddddddddd	d
dddddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddg}dܠ |}dܠ dgt| }d| d| d} fdd|D }zLt <}| }||| | d }|  |W  5 Q R  W S Q R X W n4 tk
r| }	 ztd|	   W 5 d}	~	X Y nX dS )uF   Guarda una nueva cotización en la base de datos y retorna el QuoteID.ZPlateRatingZFuelTypeIDBackFuelTypeFrontKWOutputZEngineBrandIDEngineBrandZAlternatorBrandIDAlternatorBrand	VoltageIDVoltage_FrontZCertificationIDCertification	QtyGensetZQtyBreakersZFrontQtyBreakersItem_breaker1Breaker1Item_Sunt_t1Shunt_trip1Item_Sunt_w1Shunt_trip_wiring1	Item_GFI1GFI1Item_Proyection_t1Protection_type1Item_Auxiliary_c1Auxiliary_contacts1Item_Breaker_L1Breaker_Lock1Item_Motorized_B1Motorized_Breaker1Item_breaker2Breaker2Item_Sunt_t2Shunt_trip2Item_Sunt_w2Shunt_trip_wiring2	Item_GFI2GFI2Item_Proyection_t2Protection_type2Item_Auxiliary_c2Auxiliary_contacts2Item_Breaker_L2Breaker_Lock2Item_Motorized_B2Motorized_Breaker2Item_breaker3Breaker3Item_Sunt_t3Shunt_trip3Item_Sunt_w3Shunt_trip_wiring3	Item_GFI3GFI3Item_Proyection_t3Protection_type3Item_Auxiliary_c3Auxiliary_contacts3Item_Breaker_L3Breaker_Lock3Item_Motorized_B3Motorized_Breaker3ZControllerBrandIDZControlbrandItem_controllerControlModelItem_CtrlPanelHeaterCtrlPanelHeaterItem_RempteDisplModRemoteDisplayModuleItem_AntenaAntenaItem_DSE890DSE890Item_DSE2157DSE2157
QtyDSE2157Item_DSE2548DSE2548
QtyDSE2548Item_CtrlPanelHeaterCMPCtrlPanelHeaterCMPItem_RempteDisplModCMPZRemoteDisplayModuleCMPItem_AntenaCMP	AntenaCMPItem_ComapDSE890ComapDSE890Item_ComapDSE2157ComapDSE2157QtyComapDSE2157Item_ComapDSE2548ComapDSE2548QtyComapDSE2548Item_CtrlVotlOperCtrlVotlOperItem_BateryChargerBateryChargerItem_Enclosuree_type	EnclosureZItem_Eclousure_MatEnclosureTypeItem_GFCI120VGFCI120VQtyGFCI120VItem_Receptable120VReceptable120VQtyReceptable120VItem_Enclosure_ligthAClightAC
QtylightACItem_Enclosure_ligthDClightDC
QtylightDCItem_Enclosure_SHeaterSpaceHeaterQtySpaceHeaterItem_Enclosure_LCenter
LoadCenterItem_PrewireAccsEnclPrewireAccsEnclousureItem_autolouversautolouversItem_ReceptautolouversReceptautolouversItem_OpeningEnclousureOpeningEnclousureItem_StopButtonEnclosureStopButtonEnclosureStopButtonEnclosure_QtyItem_BandHeater
BandHeaterItem_PMGUpdate	PMGUpdateItem_DigitalRegulatorDigitalRegulatorItem_VoltageRheostatVoltageRheostatItem_ThermalWrapThermalWrapItem_BaseHeater
BaseHeaterItem_BatterySwitchBatterySwitchItem_BatteryHolderBatteryHolderItem_OilHeater	OilHeaterItem_OilLevelSwitchOilLevelSwitchItem_CommonAlarmRelayCommonAlarmRelayItem_FunctionRelayFunctionRelayItem_CoolantCoolantItem_OilOilItem_DisconnectSwitchesDisconnectSwitchesItem_AddAccesory_EstopEStopQtyEStopItem_RemoteEStopRemoteEStopItem_AddAccesory_SpringSpringIsolatorZItem_Tank_AutonomyTankCapacityZItem_Tank_typeTankTypeItem_BreakTraySwitchBreakTraySwitchItem_FuelLevelSensorFuelLevelSensorItem_Tank_SpillContSpillContainmentItem_OverfillValveOverfillValveItem_DualFuelSwitchDualFuelSwitchesItem_HighFuelSwitchHighFuelSwitchItem_RemoteAlarmPRemoteAlarmPanelItem_VentPipeVentPipeItem_FlammableLFlammableLiquidsItem_NFPAIdentificatNFPAIdentificationItem_NoSmoking	NoSmokingItem_TankNumber
TankNumberItem_FluidContainmentFluidContainmentItem_louvers_in
louvers_inItem_louvers_outlouvers_outProjectItem_PrjWar_WarrantyGarantyItem_PrjWar_TestingTeastingReqCustomerr`   CustomerCompanyCustomerAddressCustomerContactCustomerEmailCustomerTel
SellerNameSellerEmailSellerPhoneZDestiny_CountryZDestiny_Statez, ?z!
        INSERT INTO CZE_Quotes (z2)
        OUTPUT INSERTED.QuoteID
        VALUES (z)
    c                    s   g | ]}  |qS r   )get)r	   fielddatar   r   r   X  s     zsave_quote.<locals>.<listcomp>r   u   Error guardando cotización: N)	joinlenr   r   r   ri   rr   r   r   )
rC  fields
field_listZplaceholdersr   valuesr   r   ro   r   r   rB  r   
save_quote  s                                                                                                                                         l
rI  )r   returnc                 C   sx   t  h}| T}|d| f | }|rL|d W  5 Q R  W  5 Q R  S W 5 Q R  W 5 Q R  dS Q R X W 5 Q R X dS )uq   
    Obtiene la descripción de una cotización por su ID.
    Retorna una lista con la(s) descripción(es).
    z:select * from StopButtonEnclosureOptions WHERE stop_id = ?r   N)r   r   r   ri   )r   r   r   rk   r   r   r   get_descriptiong  s    
 rK  c              
   C   sz   d}z>t  .}| }||| f | W  5 Q R  W S Q R X W n2 tk
rt } ztd|   W 5 d}~X Y nX dS )<   Obtiene los datos necesarios de una cotización específica.a#  
        SELECT 
            FuelTypeIDBack,          -- 0
            KWOutput,                -- 1
            EngineBrandID,           -- 2
            AlternatorBrandID,       -- 3
            VoltageID,               -- 4
            CertificationID,         -- 5
            ControllerBrandID,       -- 6
            QtyGenset,               -- 7

            -- SECCION DE LOS BREAKERS
            -- Breaker gral
            Item_breaker1,           -- 8
            Item_breaker2,           -- 9
            Item_breaker3,           -- 10
            Item_Proyection_t1,      -- 11
            Item_Proyection_t2,      -- 12
            Item_Proyection_t3,      -- 13

            -- Breaker 1 options
            Item_Sunt_t1,            -- 14
            Shunt_trip1,             -- 15
            Item_Sunt_w1,            -- 16
            Shunt_trip_wiring1,      -- 17
            Item_GFI1,               -- 18
            GFI1,                    -- 19
            Item_Auxiliary_c1,       -- 20
            Auxiliary_contacts1,     -- 21
            Item_Breaker_L1,         -- 22
            Breaker_Lock1,           -- 23
            Item_Motorized_B1,       -- 24
            Motorized_Breaker1,      -- 25

            -- Breaker 2 options
            Item_Sunt_t2,            -- 26
            Shunt_trip2,             -- 27
            Item_Sunt_w2,            -- 28
            Shunt_trip_wiring2,      -- 29
            Item_GFI2,               -- 30
            GFI2,                    -- 31
            Item_Auxiliary_c2,       -- 32
            Auxiliary_contacts2,     -- 33
            Item_Breaker_L2,         -- 34
            Breaker_Lock2,           -- 35
            Item_Motorized_B2,       -- 36
            Motorized_Breaker2,      -- 37

            -- Breaker 3 options
            Item_Sunt_t3,            -- 38
            Shunt_trip3,             -- 39
            Item_Sunt_w3,            -- 40
            Shunt_trip_wiring3,      -- 41
            Item_GFI3,               -- 42
            GFI3,                    -- 43
            Item_Auxiliary_c3,       -- 44
            Auxiliary_contacts3,     -- 45
            Item_Breaker_L3,         -- 46
            Breaker_Lock3,           -- 47
            Item_Motorized_B3,       -- 48
            Motorized_Breaker3,      -- 49

            -- SECCION DEL CONTROLLER
            -- Controller gral
            Item_controller,         -- 50
            ControlModel,            -- 51
            Item_CtrlVotlOper,       -- 52
            CtrlVotlOper,            -- 53
            Item_BateryCharger,      -- 54
            BateryCharger,           -- 55

            -- Controller options Si/NO con cantidad
            Item_DSE2157,           -- 56
            DSE2157,                -- 57
            QtyDSE2157,             -- 58
            Item_DSE2548,           -- 59
            DSE2548,                -- 60
            QtyDSE2548,             -- 61
            Item_ComapDSE2157,      -- 62
            ComapDSE2157,           -- 63
            QtyComapDSE2157,        -- 64
            Item_ComapDSE2548,      -- 65
            ComapDSE2548,           -- 66
            QtyComapDSE2548,        -- 67

            -- Controller options Si/NO sin cantidad
            Item_ComapDSE890,       -- 68
            ComapDSE890,            -- 69
            Item_CtrlPanelHeater,   -- 70
            CtrlPanelHeater,        -- 71
            Item_RempteDisplMod,    -- 72
            RemoteDisplayModule,    -- 73
            Item_Antena,            -- 74
            Antena,                 -- 75
            Item_DSE890,            -- 76
            DSE890,                 -- 77

            -- SECCION DEL ENLOSURE
            -- Indices para Enclosure
            Item_Enclosuree_type,   -- 78
            Item_Eclousure_Mat,     -- 79

            Item_Enclosure_ligthAC, -- 80
            lightAC,                -- 81
            QtylightAC,             -- 82

            Item_Enclosure_ligthDC, -- 83
            lightDC,                -- 84
            QtylightDC,             -- 85

            Item_Enclosure_SHeater, -- 86
            SpaceHeater,            -- 87
            QtySpaceHeater,         -- 88

            Item_Enclosure_LCenter, -- 89
            LoadCenter,             -- 90

            Item_GFCI120V,          -- 91
            GFCI120V,               -- 92
            QtyGFCI120V,            -- 93

            Item_Receptable120V,    -- 94
            Receptable120V,         -- 95
            QtyReceptable120V,      -- 96

            Item_PrewireAccsEncl,   -- 97
            PrewireAccsEnclousure,  -- 98

            Item_autolouvers,       -- 99
            autolouvers,            -- 100

            Item_Receptautolouvers, -- 101
            Receptautolouvers,      -- 102
            
            -- SECCION DEL ACCESORIOS
            Item_AddAccesory_Estop, -- 103
            EStop,                  -- 104
            QtyEStop,               -- 105

            Item_AddAccesory_Spring,-- 106
            SpringIsolator,         -- 107

            Item_BandHeater,        -- 108
            BandHeater,             -- 109

            Item_PMGUpdate,         -- 110
            PMGUpdate,              -- 111

            Item_DigitalRegulator,  -- 112
            DigitalRegulator,       -- 113

            Item_VoltageRheostat,   -- 114
            VoltageRheostat,        -- 115

            Item_ThermalWrap,       -- 116
            ThermalWrap,            -- 117

            Item_BaseHeater,        -- 118
            BaseHeater,             -- 119

            Item_BatterySwitch,     -- 120
            BatterySwitch,          -- 121

            Item_BatteryHolder,     -- 122
            BatteryHolder,          -- 123

            Item_OilHeater,         -- 124
            OilHeater,              -- 125

            Item_OilLevelSwitch,    -- 126
            OilLevelSwitch,         -- 127

            Item_CommonAlarmRelay,  -- 128
            CommonAlarmRelay,       -- 129

            Item_FunctionRelay,     -- 130
            FunctionRelay,          -- 131

            Item_Coolant,           -- 132
            Coolant,                -- 133

            Item_Oil,               -- 134
            Oil,                    -- 135

            Item_DisconnectSwitches,-- 136
            DisconnectSwitches,     -- 137

            Item_RemoteEStop,       -- 138
            RemoteEStop,            -- 139
            
            -- SECCION DE TANQUE
            --Tank
            Item_Tank_Autonomy,     -- 140
            TankCapacity,           -- 141
            Item_Tank_type,         -- 142
            TankType,               -- 143

            --TankOptions
            Item_BreakTraySwitch,   -- 144
            BreakTraySwitch,        -- 145

            Item_FuelLevelSensor,   -- 146
            FuelLevelSensor,        -- 147

            Item_Tank_SpillCont,    -- 148
            SpillContainment,       -- 149

            Item_OverfillValve,     -- 150
            OverfillValve,          -- 151

            Item_DualFuelSwitch,    -- 152
            DualFuelSwitches,       -- 153

            Item_HighFuelSwitch,    -- 154
            HighFuelSwitch,         -- 155

            Item_RemoteAlarmP,      -- 156
            RemoteAlarmPanel,       -- 157

            Item_VentPipe,          -- 158
            VentPipe,               -- 159

            Item_FlammableL,        -- 160
            FlammableLiquids,       -- 161

            Item_NFPAIdentificat,   -- 162
            NFPAIdentification,     -- 163

            Item_NoSmoking,         -- 164
            NoSmoking,              -- 165

            Item_TankNumber,        -- 166
            TankNumber,             -- 167

            Item_FluidContainment,  -- 168
            FluidContainment,       -- 169
            
            -- SECCION DE ULTIMOS DETALLES
            --Warranty
            Item_PrjWar_Warranty,   -- 170
            Garanty,                -- 171
            Garanty_price,          -- 172
            Garanty_Percentage,     -- 173

            --Testing
            Item_PrjWar_Testing,    -- 174
            Teasting,               -- 175
            
            Genset_Unit_Price,      -- 176
            Discount,                -- 177

            Item_CtrlPanelHeaterCMP,   -- 178
            CtrlPanelHeaterCMP,        -- 179
            Item_RempteDisplModCMP,    -- 180
            RemoteDisplayModuleCMP,    -- 181
            Item_AntenaCMP,            -- 182
            AntenaCMP,                 -- 183
            
            Item_OpeningEnclousure,    -- 184
            OpeningEnclousure,         -- 185
            
            Item_StopButtonEnclosure,  -- 186
            StopButtonEnclosure,       -- 187
            StopButtonEnclosure_Qty,    -- 188

            Item_louvers_in,          -- 189
            louvers_in,               -- 190

            Item_louvers_out,         -- 191
            louvers_out              -- 192

        FROM CZE_Quotes
        WHERE QuoteID = ?
    *   Error obteniendo datos de la cotización: Nrn   )ro   r   r   r   r   r   r   r   get_quote_datau  s       rN  c	                 C   s@  d}	z t  }
|
 }||	|||| ||||||f
 | }|r|d |d |d |d |d |d |d |d	 |d
 |d |d |d |d |d |d |d |d |d |d |d |d |d |d |d |d dW  5 Q R  W S W 5 Q R  W dS Q R X W n4 tk
r: } ztd|   W 5 d}~X Y nX dS )uE   Obtiene los datos del generador según los parámetros seleccionados.a	  
    SELECT DISTINCT
        CZE_GensetCost.CostID,
        ISNULL(CZE_GensetCost.Cost, 0) * ((100 - ?) / 100) AS price,
        CZE_GensetCost.TechnicalSheet,
        ((100 - ?) / 100) * ? * ISNULL(CZE_GensetCost.Cost, 0) AS Genset_PriceTot,
        CZE_Genset.EngineModel,
        CZE_EngineModel.TechnicalSheet,
        CZE_Genset.Engine_Tier,
        CZE_Genset.Engine_Rpm,
        CZE_Genset.Engine_Power,
        CZE_Genset.Engine_NumberOfCylinder,
        CZE_Genset.Engine_Aspiration,
        CZE_Genset.Engine_Governor_type,
        CZE_Genset.Engine_Control_voltage,
        CZE_Genset.Engine_Battery_type,
        CZE_Genset.Engine_Hotstart_model,
        CZE_Genset.Engine_RadiatorTemp,
        CZE_GensetConfig.AlternatorModel,
        CZE_AlternatorModel.TechnicalSheet,
        CZE_GensetConfig.Powerfactor,
        CZE_GensetConfig.Insulation_System,
        CZE_GensetConfig.Control_System,
        CZE_GensetConfig.Protection,
        CZE_GensetConfig.AvrModel,
        CZE_GensetConfig.Voltage_Regulation,
        CZE_GensetConfig.Class_temp_rise
    FROM
        CZE_Genset
    JOIN
        CZE_EngineModel ON CZE_Genset.EngineModel = CZE_EngineModel.EngineModel
    JOIN
        CZE_FuelType ON CZE_EngineModel.FuelTypeBack = CZE_FuelType.Back
    JOIN
        CZE_EngineBrand ON CZE_EngineModel.EngineBrandID = CZE_EngineBrand.EngineBrandID
    JOIN
        CZE_AlternatorBrand ON CZE_Genset.AlternatorBrandID = CZE_AlternatorBrand.AlternatorBrandID
    JOIN
        CZE_GensetConfig ON CZE_Genset.GensetModel = CZE_GensetConfig.GensetModel
    JOIN
        CZE_AlternatorModel ON CZE_GensetConfig.AlternatorModel = CZE_AlternatorModel.AlternatorModel
    JOIN
        CZE_Voltage ON CZE_GensetConfig.VoltageID = CZE_Voltage.VoltageID
    JOIN
        CZE_Certification ON CZE_GensetConfig.CertificationID = CZE_Certification.CertificationID
    JOIN
        CZE_GensetCost ON CZE_GensetConfig.ConfigID = CZE_GensetCost.ConfigID
    JOIN
        CZE_ControllerBrand ON CZE_GensetCost.ControllerBrandID = CZE_ControllerBrand.BrandID
    WHERE
        CZE_Genset.Active = 1
        AND CZE_EngineBrand.Active = 1
        AND CZE_AlternatorBrand.Active = 1
        AND CZE_FuelType.Front = ?
        AND CZE_Genset.KWOutput = ?
        AND CZE_EngineBrand.EngineBrandID = ?
        AND CZE_AlternatorBrand.AlternatorBrandID = ?
        AND CZE_Voltage.VoltageID = ?
        AND CZE_Certification.CertificationID = ?
        AND CZE_ControllerBrand.BrandID = ?
        AND CZE_GensetCost.Evaluator >= 1
    r   r   r   r   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]                                    )cost_id
unit_price
tech_sheetGenset_PriceTotEngineModelEngineTSheetE_TierE_RpmE_PowerE_NumberOfCylinderE_AspirationE_Governor_typeE_Control_voltageE_Battery_typeE_Hotstart_modelE_RadiatorTempAlternatorModelAlternatorTSheetA_PowerfactorA_Insulation_SystemA_Control_SystemA_Protection
A_AvrModelA_Voltage_RegulationA_Class_temp_riseNz&Error obteniendo datos del generador: rn   )r$   r'   Zengine_brandZalternator_brandr-   r6   Zcontroller_brandr{   r`   r   r   r   rk   r   r   r   r   get_genset_data  sR    ?  rs  c                 C   s   d}zft  V}| }|||||||||||	|
|||||||||||||||| f |  W 5 Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )uG   Actualiza los precios y ficha técnica del generador en la cotización.a:  
    UPDATE CZE_Quotes
    SET 
        Genset_CostID = ?,
        Genset_Unit_Price = ?,
        Genset_TSheet = ?,
        Genset_PriceTot = ?,
        EngineModel = ?,
        Engine_TSheet = ?,
        Engine_Tier = ?,
        Engine_Rpm = ?,
        Engine_Power = ?,
        Engine_NumberOfCylinder = ?,
        Engine_Aspiration = ?,
        Engine_Governor_type = ?,
        Engine_Control_voltage = ?,
        Engine_Battery_type = ?,
        Engine_Hotstart_model = ?,
        Engine_RadiatorTemp = ?,
        AlternatorModel = ?,
        Altern_TSheet = ?,
        Altern_Powerfactor = ?,
        Altern_Insulation_Sys = ?,
        Altern_Control_System = ?,
        Altern_Protection = ?,
        Altern_AvrModel = ?,
        Altern_VoltageRegulat = ?,
        Altern_Class_temp_rise = ?
    WHERE QuoteID = ?
    z*Error actualizando precios del generador: Nr   r   r   rr   r   r   )ro   rZ  r[  r\  r]  r^  r_  r`  ra  rb  rc  rd  re  rf  rg  rh  ri  rj  rk  rl  rm  rn  ro  rp  rq  rr  r   r   r   r   r   r   r   update_genset_pricing   s>                    ru  c              
   C   s   d}zvt  f}| }|||||| f | }|rb|d |d |d |d dW  5 Q R  W S W 5 Q R  W dS Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )	u:   Obtiene los datos del breaker según el item seleccionado.aA  
    SELECT 
        CZE_BreakersCatalog.Item_breaker,
        ISNULL(CZE_BreakersCatalog.price, 0) * ? AS price,
        CZE_BreakersCatalog.TechnicalSheet,
        ? * ? * ISNULL(CZE_BreakersCatalog.price, 0) AS price_tot
    FROM 
        CZE_BreakersCatalog
    WHERE
        CZE_BreakersCatalog.Item_breaker = ?
    r   r   r   r   r9   r0   r\  	price_totNz$Error obteniendo datos del breaker: rn   )Zitem_breaker
qty_gensetr`   r   r   r   rk   r   r   r   r   get_breaker_data7  s     ry  c              
   C   s   d}zvt  f}| }|||||| f | }|rb|d |d |d |d dW  5 Q R  W S W 5 Q R  W dS Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )	u@   Obtiene los datos de la protección según el item seleccionado.a{  
    SELECT 
        CZE_BreakerProtectionType.Item_breaker_Protection,
        ISNULL(CZE_BreakerProtectionType.price, 0) * ? AS price,
        CZE_BreakerProtectionType.TechnicalSheet,
        ? * ? * ISNULL(CZE_BreakerProtectionType.price, 0) AS price_tot
    FROM 
        CZE_BreakerProtectionType
    WHERE
        CZE_BreakerProtectionType.Item_breaker_Protection = ?
    r   r   r   r   rv  Nu*   Error obteniendo datos de la protección: rn   )Zitem_protectionrx  r`   r   r   r   rk   r   r   r   r   get_protection_dataZ  s     rz  c              
   C   s   d| d| d| d}zFt  6}| }|||d |d |d | f |  W 5 Q R X W n8 tk
r } ztd| d	|   W 5 d
}~X Y nX d
S )uE   Actualiza los precios y ficha técnica del breaker en la cotización.z/
    UPDATE CZE_Quotes
    SET 
        Breakerz_Price = ?,
        Breakerz_TSheet = ?,
        Breaker(_PriceTot = ?
    WHERE QuoteID = ?
    r0   r\  rw  z'Error actualizando precios del breaker rq   Nrt  )ro   breaker_numbreaker_datar   r   r   r   r   r   r   update_breaker_pricing}  s(    	r~  c              
   C   s   d| d| d| d}zFt  6}| }|||d |d |d | f |  W 5 Q R X W n8 tk
r } ztd| d	|   W 5 d
}~X Y nX d
S )uK   Actualiza los precios y ficha técnica de la protección en la cotización.z4
    UPDATE CZE_Quotes
    SET 
        Proyection_tz _Price = ?,
        Proyection_tz!_TSheet = ?,
        Proyection_tr{  r0   r\  rw  u-   Error actualizando precios de la protección rq   Nrt  )ro   Zprotection_numprotection_datar   r   r   r   r   r   r   update_protection_pricing  s(    	r  c              
   C   s   d}zvt  f}| }|||||| f | }|rb|d |d |d |d dW  5 Q R  W S W 5 Q R  W dS Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )	uH   Obtiene los datos de la opción del breaker según el item seleccionado.aQ  
    SELECT 
        CZE_BreakersOptions.Item_breaker_options,
        ISNULL(CZE_BreakersOptions.price, 0) * ? AS price,
        CZE_BreakersOptions.TechnicalSheet,
        ? * ? * ISNULL(CZE_BreakersOptions.price, 0) AS price_tot
    FROM 
        CZE_BreakersOptions
    WHERE
        CZE_BreakersOptions.Item_breaker_options = ?
    r   r   r   r   rv  Nu.   Error obteniendo datos de opción de breaker: rn   item_optionrx  r`   r   r   r   rk   r   r   r   r   get_breaker_option_data  s     r  c           
   
   C   s   ddddddd}| |}|s.td| d	| | d
| | d| | d
}zFt 6}| }|||d |d |d | f |  W 5 Q R X W n> tk
r }	 z td| d| d|	   W 5 d}	~	X Y nX dS )uS   Actualiza los precios y ficha técnica de la opción del breaker en la cotización.ZSunt_tZSunt_wZGFIZAuxiliary_cZ	Breaker_LZMotorized_B)sunt_tsunt_wgfiaux_c	breaker_l	motorized   Tipo de opción no válido: (
    UPDATE CZE_Quotes
    SET 
        _Price = ?,
        _TSheet = ?,
        r{  r0   r\  rw  &   Error actualizando precios de opción z del breaker rq   Nr@  
ValueErrorr   r   r   rr   r   r   )
ro   r|  option_typeoption_dataoption_mappingsprefixr   r   r   r   r   r   r   update_breaker_option_pricing  sH    	
	r  c              
   C   s   d}zvt  f}| }|||||| f | }|rb|d |d |d |d dW  5 Q R  W S W 5 Q R  W dS Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )	u>   Obtiene los datos del controlador según el item seleccionado.aZ  
    SELECT DISTINCT
        CZE_ControllerCatalog.Item_controller,
        ISNULL(CZE_ControllerCatalog.price, 0) * ? AS price,
        CZE_ControllerCatalog.TechnicalSheet,
        ? * ? * ISNULL(CZE_ControllerCatalog.price, 0) AS priceTot
    FROM 
        CZE_ControllerCatalog
    WHERE
        CZE_ControllerCatalog.Item_controller = ?
    r   r   r   r   rv  Nz(Error obteniendo datos del controlador: rn   )Zitem_controllerrx  r`   r   r   r   rk   r   r   r   r   get_controller_data  s     r  c              
   C   s   d}zvt  f}| }|||||| f | }|rb|d |d |d |d dW  5 Q R  W S W 5 Q R  W dS Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )	u@   Obtiene los datos del precalentador según el item seleccionado.af  
    SELECT 
        CZE_ControllerPreheater.Item_preheater_volt,
        ISNULL(CZE_ControllerPreheater.price, 0) * ? AS price,
        CZE_ControllerPreheater.TechnicalSheet,
        ? * ? * ISNULL(CZE_ControllerPreheater.price, 0) AS priceTot
    FROM 
        CZE_ControllerPreheater
    WHERE
        CZE_ControllerPreheater.Item_preheater_volt = ?
    r   r   r   r   rv  Nz*Error obteniendo datos del precalentador: rn   )Zitem_preheaterrx  r`   r   r   r   rk   r   r   r   r   get_preheater_data$  s     r  c              
   C   s   d}zvt  f}| }|||||| f | }|rb|d |d |d |d dW  5 Q R  W S W 5 Q R  W dS Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )	uG   Obtiene los datos del cargador de batería según el item seleccionado.ar  
    SELECT 
        CZE_ControllerBattCharger.Item_batterycharger,
        ISNULL(CZE_ControllerBattCharger.price, 0) * ? AS price,
        CZE_ControllerBattCharger.TechnicalSheet,
        ? * ? * ISNULL(CZE_ControllerBattCharger.price, 0) AS priceTot
    FROM 
        CZE_ControllerBattCharger
    WHERE
        CZE_ControllerBattCharger.Item_batterycharger = ?
    r   r   r   r   rv  Nu1   Error obteniendo datos del cargador de batería: rn   )Zitem_chargerrx  r`   r   r   r   rk   r   r   r   r   get_battery_charger_dataE  s     r  c              
   C   s   d}zFt  6}| }|||d |d |d | f |  W 5 Q R X W n2 tk
r| } ztd|   W 5 d}~X Y nX dS )u8   Actualiza los precios del controlador en la cotización.z
    UPDATE CZE_Quotes
    SET 
        controller_Price = ?,
        controller_TSheet = ?,
        ControlModel_PriceTot = ?
    WHERE QuoteID = ?
    r0   r\  rw  z,Error actualizando precios del controlador: Nrt  )ro   controller_datar   r   r   r   r   r   r   update_controller_pricingf  s    	r  c              
   C   s   d}zFt  6}| }|||d |d |d | f |  W 5 Q R X W n2 tk
r| } ztd|   W 5 d}~X Y nX dS )u:   Actualiza los precios del precalentador en la cotización.z
    UPDATE CZE_Quotes
    SET 
        CtrlVotlOper_Price = ?,
        CtrlVotlOper_TSheet = ?,
        CtrlVotlOper_PriceTot = ?
    WHERE QuoteID = ?
    r0   r\  rw  z.Error actualizando precios del precalentador: Nrt  )ro   preheater_datar   r   r   r   r   r   r   update_preheater_pricing  s    	r  c              
   C   s   d}zFt  6}| }|||d |d |d | f |  W 5 Q R X W n2 tk
r| } ztd|   W 5 d}~X Y nX dS )uA   Actualiza los precios del cargador de batería en la cotización.z
    UPDATE CZE_Quotes
    SET 
        BateryCharger_Price = ?,
        BateryCharger_TSheet = ?,
        BateryCharger_PriceTot = ?
    WHERE QuoteID = ?
    r0   r\  rw  u5   Error actualizando precios del cargador de batería: Nrt  )ro   charger_datar   r   r   r   r   r   r   update_battery_charger_pricing  s    	r  c           	   
   C   s   d}zxt  h}| }||||||| f | }|rd|d |d |d |d dW  5 Q R  W S W 5 Q R  W dS Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )	uJ   Obtiene los datos de la opción del controlador que tiene cantidad propia.af  
    SELECT 
        CZE_ControllerOptions.Item_controller_options,
        ISNULL(CZE_ControllerOptions.price, 0) * ? AS price,
        CZE_ControllerOptions.TechnicalSheet,
        ? * ? * ? * ISNULL(CZE_ControllerOptions.price, 0) AS priceTot
    FROM 
        CZE_ControllerOptions
    WHERE
        CZE_ControllerOptions.Item_controller_options = ?
    r   r   r   r   rv  N3   Error obteniendo datos de opción del controlador: rn   	r  rx  Zqty_itemr`   r   r   r   rk   r   r   r   r   get_controller_option_qty_data  s     r  c              
   C   s   d}zFt  6}| }|||d |d |d | f |  W 5 Q R X W n2 tk
r| } ztd|   W 5 d}~X Y nX dS )u4   Actualiza los precios del DSE2157 en la cotización.z
    UPDATE CZE_Quotes
    SET 
        DSE2157_Price = ?,
        DSE2157_TSheet = ?,
        DSE2157_PriceTot = ?
    WHERE QuoteID = ?
    r0   r\  rw  z'Error actualizando precios de DSE2157: Nrt  ro   rC  r   r   r   r   r   r   r   update_dse2157_pricing  s    	r  c              
   C   s   d}zFt  6}| }|||d |d |d | f |  W 5 Q R X W n2 tk
r| } ztd|   W 5 d}~X Y nX dS )u4   Actualiza los precios del DSE2548 en la cotización.z
    UPDATE CZE_Quotes
    SET 
        DSE2548_Price = ?,
        DSE2548_TSheet = ?,
        DSE2548_PriceTot = ?
    WHERE QuoteID = ?
    r0   r\  rw  z'Error actualizando precios de DSE2548: Nrt  r  r   r   r   update_dse2548_pricing  s    	r  c              
   C   s   d}zFt  6}| }|||d |d |d | f |  W 5 Q R X W n2 tk
r| } ztd|   W 5 d}~X Y nX dS )u9   Actualiza los precios del ComapDSE2157 en la cotización.z
    UPDATE CZE_Quotes
    SET 
        ComapDSE2157_Price = ?,
        ComapDSE2157_TSheet = ?,
        ComapDSE2157_PriceTot = ?
    WHERE QuoteID = ?
    r0   r\  rw  z,Error actualizando precios de ComapDSE2157: Nrt  r  r   r   r   update_comap_dse2157_pricing  s    	r  c              
   C   s   d}zFt  6}| }|||d |d |d | f |  W 5 Q R X W n2 tk
r| } ztd|   W 5 d}~X Y nX dS )u9   Actualiza los precios del ComapDSE2548 en la cotización.z
    UPDATE CZE_Quotes
    SET 
        ComapDSE2548_Price = ?,
        ComapDSE2548_TSheet = ?,
        ComapDSE2548_PriceTot = ?
    WHERE QuoteID = ?
    r0   r\  rw  z,Error actualizando precios de ComapDSE2548: Nrt  r  r   r   r   update_comap_dse2548_pricing%  s    	r  c              
   C   s   d}zvt  f}| }|||||| f | }|rb|d |d |d |d dW  5 Q R  W S W 5 Q R  W dS Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )	u0   Obtiene los datos de la opción del controlador.ab  
    SELECT 
        CZE_ControllerOptions.Item_controller_options,
        ISNULL(CZE_ControllerOptions.price, 0) * ? AS price,
        CZE_ControllerOptions.TechnicalSheet,
        ? * ? * ISNULL(CZE_ControllerOptions.price, 0) AS priceTot
    FROM 
        CZE_ControllerOptions
    WHERE
        CZE_ControllerOptions.Item_controller_options = ?
    r   r   r   r   rv  Nr  rn   r  r   r   r   get_controller_option_data?  s     r  c           
   
   C   s   ddddddddd	}| |d
\}}|s8td| d| d| d| d}t| zFt 6}| }|||d |d |d | f |  W 5 Q R X W n8 tk
r }	 ztd| d|	   W 5 d}	~	X Y nX dS )uF   Actualiza los precios de la opción del controlador en la cotización.)r   r   )r   ZCtrlPanelHeat)RempteDisplModr  )r   r   )r   r   )r   r   )r   ZCtrlPanelHeatCMP)RempteDisplModCMPr  )comap_dse890panel_heaterremote_displayantenadse890	antenaCMPpanel_heaterCMPremote_displayCMPNNr  r  r  r  r{  r0   r\  rw  r  rq   N)r@  r  r   r   r   r   rr   r   
ro   r  rC  r  Zprice_prefixZtotal_prefixr   r   r   r   r   r   r    update_controller_option_pricing`  sB    	r  c                 C   s   d}z~t  n}| }	|	|||||| |||f |	 }
|
rj|
d |
d |
d |
d dW  5 Q R  W S W 5 Q R  W dS Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )	uD   Obtiene los datos de la caseta según los parámetros seleccionados.a<  
    SELECT DISTINCT
        CZE_EnclosureConfig.ConfigID,
        ISNULL(CZE_EnclosureConfig.Cost, 0) * ? AS price,
        CZE_EnclosureConfig.TechnicalSheet,
        ? * ? * ISNULL(CZE_EnclosureConfig.Cost, 0) AS priceTot
    FROM
        CZE_EnclosureConfig
    WHERE
        CZE_EnclosureConfig.CertificationID = ?
        AND CZE_EnclosureConfig.Fueltype = ?
        AND CZE_EnclosureConfig.Item_Enclosure_type = ?
        AND CZE_EnclosureConfig.KWOutput = ?
        AND CZE_EnclosureConfig.Item_Enclosure_Mat = ?
        AND CZE_EnclosureConfig.Evaluator >= 1
    r   r   r   r   )	config_idr0   r\  rw  Nz%Error obteniendo datos de la caseta: rn   )r$   r'   r6   rB   Zenclosure_matrx  r`   r   r   r   rk   r   r   r   r   get_enclosure_data  s&     r  Tc           
   
   C   s   d}zxt  h}| }||||||| f | }|rd|d |d |d |d dW  5 Q R  W S W 5 Q R  W dS Q R X W n2 tk
r }	 ztd|	   W 5 d}	~	X Y nX dS )	uK   Obtiene los datos de la iluminación (AC o DC) según el item seleccionado.aN  
    SELECT 
        CZE_EnclosureLight.Item_Enclosure_ligth,
        ISNULL(CZE_EnclosureLight.price, 0) * ? AS price,
        CZE_EnclosureLight.TechnicalSheet,
        ? * ? * ? * ISNULL(CZE_EnclosureLight.price, 0) AS priceTot
    FROM 
        CZE_EnclosureLight
    WHERE
        CZE_EnclosureLight.Item_Enclosure_ligth = ?
    r   r   r   r   rv  Nu(   Error obteniendo datos de iluminación: rn   )
Z
item_lightrx  Z	qty_lightr`   is_acr   r   r   rk   r   r   r   r   get_light_data  s     r  c           	   
   C   s   d}zxt  h}| }||||||| f | }|rd|d |d |d |d dW  5 Q R  W S W 5 Q R  W dS Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )	uH   Obtiene los datos del calentador de espacio según el item seleccionado.av  
    SELECT 
        CZE_EnclosureSpaceHeater.Item_Enclosure_SHeater,
        ISNULL(CZE_EnclosureSpaceHeater.price, 0) * ? AS price,
        CZE_EnclosureSpaceHeater.TechnicalSheet,
        ? * ? * ? * ISNULL(CZE_EnclosureSpaceHeater.price, 0) AS priceTot
    FROM 
        CZE_EnclosureSpaceHeater
    WHERE
        CZE_EnclosureSpaceHeater.Item_Enclosure_SHeater = ?
    r   r   r   r   rv  Nz'Error obteniendo datos del calentador: rn   )	Zitem_heaterrx  Z
qty_heaterr`   r   r   r   rk   r   r   r   r   get_space_heater_data  s     r  c              
   C   s   d}zvt  f}| }|||||| f | }|rb|d |d |d |d dW  5 Q R  W S W 5 Q R  W dS Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )	uB   Obtiene los datos del centro de carga según el item seleccionado.al  
    SELECT 
        CZE_EnclosureLoadCenter.Item_Enclosure_LCenter,
        ISNULL(CZE_EnclosureLoadCenter.price, 0) * ? AS price,
        CZE_EnclosureLoadCenter.TechnicalSheet,
        ? * ? * ISNULL(CZE_EnclosureLoadCenter.price, 0) AS priceTot
    FROM 
        CZE_EnclosureLoadCenter
    WHERE
        CZE_EnclosureLoadCenter.Item_Enclosure_LCenter = ?
    r   r   r   r   rv  Nz,Error obteniendo datos del centro de carga: rn   )Zitem_centerrx  r`   r   r   r   rk   r   r   r   r   get_load_center_data  s     r  c              
   C   s   d}zLt  <}| }|||d |d |d |d | f |  W 5 Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )u5   Actualiza los precios de la caseta en la cotización.z
    UPDATE CZE_Quotes
    SET 
        Enclosure_ConfigID = ?,
        Enclosure_price = ?,
        Enclosure_TSheet = ?,
        Enclosure_PriceTot = ?
    WHERE QuoteID = ?
    r  r0   r\  rw  z)Error actualizando precios de la caseta: Nrt  r  r   r   r   update_enclosure_pricing	  s    
r  c           	   
   C   s   ddddd}| |}|s*td| d| d| d	| d
}zFt 6}| }|||d |d |d | f |  W 5 Q R X W n8 tk
r } ztd| d|   W 5 d}~X Y nX dS )z6Actualiza los precios de los componentes de la caseta.r   r   r   r   )light_aclight_dcspace_heaterload_centeru   Tipo de componente no válido: r  z_price = ?,
        r  r{  r0   r\  rw  z*Error actualizando precios del componente rq   Nr  )	ro   Zcomponent_typerC  Zcomponent_mappingsr  r   r   r   r   r   r   r   "update_enclosure_component_pricing4	  s8    
	r  c           	   
   C   s   d}zxt  h}| }||||||| f | }|rd|d |d |d |d dW  5 Q R  W S W 5 Q R  W dS Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )	zCObtiene los datos de opciones de caseta que tienen cantidad propia.aX  
    SELECT 
        CZE_EnclosureOption.Item_Enclosure_options,
        ISNULL(CZE_EnclosureOption.price, 0) * ? AS price,
        CZE_EnclosureOption.TechnicalSheet,
        ? * ? * ? * ISNULL(CZE_EnclosureOption.price, 0) AS priceTot
    FROM 
        CZE_EnclosureOption
    WHERE
        CZE_EnclosureOption.Item_Enclosure_options = ?
    r   r   r   r   rv  N-   Error obteniendo datos de opción de caseta: rn   r  r   r   r   get_enclosure_option_qty_data[	  s     r  c              
   C   s   d}zvt  f}| }|||||| f | }|rb|d |d |d |d dW  5 Q R  W S W 5 Q R  W dS Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )	z<Obtiene los datos de opciones de caseta sin cantidad propia.aT  
    SELECT 
        CZE_EnclosureOption.Item_Enclosure_options,
        ISNULL(CZE_EnclosureOption.price, 0) * ? AS price,
        CZE_EnclosureOption.TechnicalSheet,
        ? * ? * ISNULL(CZE_EnclosureOption.price, 0) AS priceTot
    FROM 
        CZE_EnclosureOption
    WHERE
        CZE_EnclosureOption.Item_Enclosure_options = ?
    r   r   r   r   rv  Nr  rn   r  r   r   r   get_enclosure_option_data}	  s     r  c           
   
   C   s   dddddddd}| |d	\}}|s6td
| d| d| d| d}zFt 6}| }|||d |d |d | f |  W 5 Q R X W n8 tk
r }	 ztd| d|	   W 5 d}	~	X Y nX dS )z3Actualiza los precios de las opciones de la caseta.)r   r   )r   r   )ZPrewireAccsEncloZPrewireAccsEnc)r   r   )ZReceptautolouverZReceptautolouv)r   r   )r   r   )gfci
receptableprewirer   receptautolouversopeningEnclousureZstopButtonEnclosurer  r  r  r  r  r{  r0   r\  rw  r  rq   Nr  r  r   r   r   update_enclosure_option_pricing	  s>    
	r  c           	   
   C   s   d}zxt  h}| }||||||| f | }|rd|d |d |d |d dW  5 Q R  W S W 5 Q R  W dS Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )	u9   Obtiene los datos del E-Stop según el item seleccionado.ad  
    SELECT 
        CZE_AddAccesory_Estop.Item_AddAccesory_Estop,
        ISNULL(CZE_AddAccesory_Estop.price, 0) * ? AS price,
        CZE_AddAccesory_Estop.TechnicalSheet,
        ? * ? * ? * ISNULL(CZE_AddAccesory_Estop.price, 0) AS priceTot
    FROM 
        CZE_AddAccesory_Estop
    WHERE
        CZE_AddAccesory_Estop.Item_AddAccesory_Estop = ?
    r   r   r   r   rv  Nz#Error obteniendo datos del E-Stop: rn   )	Z
item_estoprx  Z	qty_estopr`   r   r   r   rk   r   r   r   r   get_estop_data	  s     r  c              
   C   s   d}zvt  f}| }|||||| f | }|rb|d |d |d |d dW  5 Q R  W S W 5 Q R  W dS Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )	uF   Obtiene los datos del aislador de resorte según el item seleccionado.ah  
    SELECT 
        CZE_AddAccesory_Spring.Item_AddAccesory_Spring,
        ISNULL(CZE_AddAccesory_Spring.price, 0) * ? AS price,
        CZE_AddAccesory_Spring.TechnicalSheet,
        ? * ? * ISNULL(CZE_AddAccesory_Spring.price, 0) AS priceTot
    FROM 
        CZE_AddAccesory_Spring
    WHERE
        CZE_AddAccesory_Spring.Item_AddAccesory_Spring = ?
    r   r   r   r   rv  Nz0Error obteniendo datos del aislador de resorte: rn   )Zitem_springrx  r`   r   r   r   rk   r   r   r   r   get_spring_isolator_data	  s     r  c              
   C   s   d}zFt  6}| }|||d |d |d | f |  W 5 Q R X W n2 tk
r| } ztd|   W 5 d}~X Y nX dS )u3   Actualiza los precios del E-Stop en la cotización.z
    UPDATE CZE_Quotes
    SET 
        EStop_price = ?,
        EStop_TSheet = ?,
        EStop_PriceTot = ?
    WHERE QuoteID = ?
    r0   r\  rw  z'Error actualizando precios del E-Stop: Nrt  r  r   r   r   update_estop_pricing

  s    	r  c              
   C   s   d}zFt  6}| }|||d |d |d | f |  W 5 Q R X W n2 tk
r| } ztd|   W 5 d}~X Y nX dS )u@   Actualiza los precios del aislador de resorte en la cotización.z
    UPDATE CZE_Quotes
    SET 
        SpringIsolator_price = ?,
        SpringIsolator_TSheet = ?,
        SpringIsolator_PriceTot = ?
    WHERE QuoteID = ?
    r0   r\  rw  z4Error actualizando precios del aislador de resorte: Nrt  r  r   r   r   update_spring_isolator_pricing$
  s    	r  c              
   C   s   d}zvt  f}| }|||||| f | }|rb|d |d |d |d dW  5 Q R  W S W 5 Q R  W dS Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )	u-   Obtiene los datos de la opción de accesorio.ah  
    SELECT 
        CZE_AddAccesory_Option.Item_AddAccesory_option,
        ISNULL(CZE_AddAccesory_Option.price, 0) * ? AS price,
        CZE_AddAccesory_Option.TechnicalSheet,
        ? * ? * ISNULL(CZE_AddAccesory_Option.price, 0) AS priceTot
    FROM 
        CZE_AddAccesory_Option
    WHERE
        CZE_AddAccesory_Option.Item_AddAccesory_option = ?
    r   r   r   r   rv  Nu0   Error obteniendo datos de opción de accesorio: rn   r  r   r   r   get_accessory_option_data>
  s     r  c           
      C   s   ddddddddd	d
ddddddd}| |d\}}|sHtd| d| d| d| d}zFt 6}| }|||d |d |d | f |  W 5 Q R X W n8 tk
r }	 ztd| d|	   W 5 d}	~	X Y nX dS )z4Actualiza los precios de las opciones de accesorios.)r   r   )r   r   )r   ZDigitalRegulat)r   ZVoltageRheosta)r   r   )r   r   )r   r   )r   r   )r   r   )r   r   )r  ZCommonAlarmRel)r  r  )r  r  )r  r  )ZDisconnectSwitchZDisconnectSwit)r  r  )band_heater
pmg_updatedigital_regulatorvoltage_rheostatthermal_wrapbase_heaterbattery_switchbattery_holder
oil_heateroil_level_switchcommon_alarm_relayfunction_relaycoolantoildisconnect_switchremote_estopr  r  r  r  r  r{  r0   r\  rw  r  rq   Nr  r  r   r   r   update_accessory_option_pricing_
  sP    	r  c           
   
   C   s   d}zt  p}| }|||||| ||f | }|rl|d |d |d |d |d dW  5 Q R  W S W 5 Q R  W dS Q R X W n2 tk
r }	 ztd	|	   W 5 d}	~	X Y nX dS )
uB   Obtiene los datos del tanque según los parámetros seleccionados.a  
    SELECT DISTINCT
        CZE_TankConfig.ConfigID,
        CZE_TankConfig.CapacityGAL,
        ISNULL(CZE_TankConfig.Cost, 0) * ? AS price,
        CZE_TankConfig.TechnicalSheet,
        ? * ? * ISNULL(CZE_TankConfig.Cost, 0) AS priceTot
    FROM
        CZE_TankConfig
    WHERE
        CZE_TankConfig.KWOutput = ?
        AND CZE_TankConfig.Item_Tank_Autonomy = ?
        AND CZE_TankConfig.Item_Tank_type = ?
        AND CZE_TankConfig.Evaluator >= 1
    r   r   r   r   rT   )r  capacity_galr0   r\  rw  Nz#Error obteniendo datos del tanque: rn   )
r'   rL   Z	tank_typerx  r`   r   r   r   rk   r   r   r   r   get_tank_data
  s"    r  c              
   C   s   d}zvt  f}| }|||||| f | }|rb|d |d |d |d dW  5 Q R  W S W 5 Q R  W dS Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )	uI   Obtiene los datos del contenedor de derrames según el item seleccionado.aB  
    SELECT 
        CZE_TankSpillCont.Item_Tank_SpillCont,
        ISNULL(CZE_TankSpillCont.price, 0) * ? AS price,
        CZE_TankSpillCont.TechnicalSheet,
        ? * ? * ISNULL(CZE_TankSpillCont.price, 0) AS priceTot
    FROM 
        CZE_TankSpillCont
    WHERE
        CZE_TankSpillCont.Item_Tank_SpillCont = ?
    r   r   r   r   rv  Nz3Error obteniendo datos del contenedor de derrames: rn   )Z
item_spillrx  r`   r   r   r   rk   r   r   r   r   get_spill_containment_data
  s     r  c              
   C   s   d}zvt  f}| }|||||| f | }|rb|d |d |d |d dW  5 Q R  W S W 5 Q R  W dS Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )	u+   Obtiene los datos de la opción del tanque.a0  
    SELECT 
        CZE_TankOptions.Item_Tank_option,
        ISNULL(CZE_TankOptions.price, 0) * ? AS price,
        CZE_TankOptions.TechnicalSheet,
        ? * ? * ISNULL(CZE_TankOptions.price, 0) AS priceTot
    FROM 
        CZE_TankOptions
    WHERE
        CZE_TankOptions.Item_Tank_option = ?
    r   r   r   r   rv  Nu.   Error obteniendo datos de opción del tanque: rn   r  r   r   r   get_tank_option_data
  s     r  c              
   C   s   d}zRt  B}| }|||d |d |d |d |d | f |  W 5 Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )	u3   Actualiza los precios del tanque en la cotización.z
    UPDATE CZE_Quotes
    SET 
        Tank_ConfigID = ?,
        Tank_CapacityGAL = ?,
        Tank_price = ?,
        Tank_TSheet = ?,
        Tank_PriceTot = ?
    WHERE QuoteID = ?
    r  r  r0   r\  rw  z'Error actualizando precios del tanque: Nrt  r  r   r   r   update_tank_pricing
  s     r  c           
      C   s   ddddddddd	d
dddd}| |d\}}|sBtd| d| d| d| d}zFt 6}| }|||d |d |d | f |  W 5 Q R X W n8 tk
r }	 ztd| d|	   W 5 d}	~	X Y nX dS )z1Actualiza los precios de las opciones del tanque.)r  ZBreakTraySwitc)r  ZFuelLevelSenso)r  ZSpillContainme)r  r  )r  ZDualFuelSwitch)r  r  )r   ZRemoteAlarmPan)r"  r"  )r$  ZFlammableLiqui)ZNFPAIdentificatZNFPAIdentifica)r(  r(  )r*  r*  )r,  ZFluidContainme)
break_tray
fuel_level
spill_contoverfill	dual_fuel	high_fuelremote_alarm	vent_pipe	flammablenfpa
no_smokingtank_number
fluid_contr  r  r  r  r  r{  r0   r\  rw  r  rq   Nr  r  r   r   r   update_tank_option_pricing  sJ    	r  c           	   
   C   s   d}zxt  h}| }|||||| |f | }|rd|d |d |d |d dW  5 Q R  W S W 5 Q R  W dS Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )	u9   Obtiene los datos de pruebas según el item seleccionado.a  
    SELECT DISTINCT
        CZE_PrjWarTestConfig.ConfigID,
        ISNULL(CZE_PrjWarTestConfig.Cost, 0) * ? AS price,
        CZE_PrjWarTestConfig.Document,
        ? * ? * ISNULL(CZE_PrjWarTestConfig.Cost, 0) AS priceTot
    FROM
        CZE_PrjWarTestConfig
    WHERE
        CZE_PrjWarTestConfig.Item_PrjWar_Testing = ?
        AND CZE_PrjWarTestConfig.KWOutput = ?
        AND CZE_PrjWarTestConfig.Evaluator >= 1
    r   r   r   r   )r  r0   documentrw  Nz#Error obteniendo datos de pruebas: rn   )	Zitem_testingr'   rx  r`   r   r   r   rk   r   r   r   r   get_testing_dataH  s     r  c           	   
   C   s   d}zzt  j}| }|||||||| f | }|rf|d |d |d |d dW  5 Q R  W S W 5 Q R  W dS Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )	u>   Obtiene los datos de la garantía según el item seleccionado.a  
    SELECT 
        CZE_PrjWarWarranty.Item_PrjWar_Warranty,
        ISNULL(CZE_PrjWarWarranty.Percentage, 0) AS Percentage,
        ? * ? * ISNULL(CZE_PrjWarWarranty.Percentage, 0) AS warranty_unit_price,
        ? * ? * ? * ISNULL(CZE_PrjWarWarranty.Percentage, 0) AS warranty_price_tot
    FROM 
        CZE_PrjWarWarranty
    WHERE
        CZE_PrjWarWarranty.Item_PrjWar_Warranty = ?
    r   r   r   r   )r9   
percentager0   rw  Nu%   Error obteniendo datos de garantía: rn   )	Zitem_warrantyrx  Zgenset_unit_pricer`   r   r   r   rk   r   r   r   r   get_warranty_datak  s.    r  c              
   C   s   d}zLt  <}| }|||d |d |d |d | f |  W 5 Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )u3   Actualiza los precios de pruebas en la cotización.z
    UPDATE CZE_Quotes
    SET 
        Teasting_ConfigID = ?,
        Teasting_price = ?,
        Teasting_Document = ?,
        Teasting_PriceTot = ?
    WHERE QuoteID = ?
    r  r0   r  rw  z'Error actualizando precios de pruebas: Nrt  r  r   r   r   update_testing_pricing  s    
r  c              
   C   s   d}zFt  6}| }|||d |d |d | f |  W 5 Q R X W n2 tk
r| } ztd|   W 5 d}~X Y nX dS )u8   Actualiza los precios de la garantía en la cotización.z
    UPDATE CZE_Quotes
    SET 
        Garanty_Percentage = ?,
        Garanty_price = ?,
        Garanty_PriceTot = ?
    WHERE QuoteID = ?
    r  r0   rw  u)   Error actualizando precios de garantía: Nrt  r  r   r   r   update_warranty_pricing  s    	r  c              
   C   s   d}zpt  `}| }||| f dd |jD }| }|r\tt||W  5 Q R  W S W 5 Q R  W dS Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )rL  uh  
        SELECT 
            CZE_Quotes.QuoteID,-- 1
            CZE_Quotes.PlateRating,-- 2
            CZE_Quotes.FuelTypeIDBack,-- 3
            CZE_Quotes.FuelTypeFront,-- 4
            CZE_Quotes.KWOutput,-- 5
            CZE_Quotes.EngineBrandID,-- 6
            CZE_Quotes.EngineBrand,-- 7
            CZE_Quotes.AlternatorBrandID,-- 8
            CZE_Quotes.AlternatorBrand,-- 9
            CZE_Quotes.VoltageID,-- 10
            CZE_Quotes.Voltage_Front,-- 11
            CZE_Quotes.CertificationID,-- 12
            CZE_Quotes.Certification,-- 13
            CZE_Quotes.QtyGenset,-- 14
            CZE_Quotes.ControllerBrandID,-- 15
            CZE_Quotes.Controlbrand,-- 16
            CZE_Quotes.Genset_CostID,-- 17
            CZE_Quotes.Genset_Unit_Price,-- 18
            CZE_Quotes.Genset_TSheet,-- 19
            CZE_Quotes.Genset_PriceTot,-- 20
            CZE_Quotes.QtyBreakers,-- 21
            CZE_Quotes.FrontQtyBreakers,-- 22
            CZE_Quotes.Item_breaker1,-- 23
            CZE_Quotes.Breaker1,-- 24
            CZE_Quotes.Breaker1_Price,-- 25
            CZE_Quotes.Breaker1_TSheet,-- 26
            CZE_Quotes.Breaker1_PriceTot,-- 27
            CZE_Quotes.Item_Sunt_t1,-- 28
            CZE_Quotes.Shunt_trip1,-- 29
            CZE_Quotes.Sunt_t1_Price,-- 30
            CZE_Quotes.Sunt_t1_TSheet,-- 31
            CZE_Quotes.Sunt_t1_PriceTot,-- 32
            CZE_Quotes.Item_Sunt_w1,-- 33
            CZE_Quotes.Shunt_trip_wiring1,-- 34
            CZE_Quotes.Sunt_w1_Price,-- 35
            CZE_Quotes.Sunt_w1_TSheet,-- 36
            CZE_Quotes.Sunt_w1_PriceTot,-- 37
            CZE_Quotes.Item_GFI1,-- 38
            CZE_Quotes.GFI1,-- 39
            CZE_Quotes.GFI1_Price,-- 40
            CZE_Quotes.GFI1_TSheet,-- 41
            CZE_Quotes.GFI1_PriceTot,-- 42
            CZE_Quotes.Item_Proyection_t1,-- 43
            CZE_Quotes.Protection_type1,-- 44
            CZE_Quotes.Proyection_t1_Price,-- 45
            CZE_Quotes.Proyection_t1_TSheet,-- 46
            CZE_Quotes.Proyection_t1_PriceTot,-- 47
            CZE_Quotes.Item_Auxiliary_c1,-- 48
            CZE_Quotes.Auxiliary_contacts1,-- 49
            CZE_Quotes.Auxiliary_c1_Price,-- 50
            CZE_Quotes.Auxiliary_c1_TSheet,-- 51
            CZE_Quotes.Auxiliary_c1_PriceTot,-- 52
            CZE_Quotes.Item_Breaker_L1,-- 53
            CZE_Quotes.Breaker_Lock1,-- 54
            CZE_Quotes.Breaker_L1_Price,-- 55
            CZE_Quotes.Breaker_L1_TSheet,-- 56
            CZE_Quotes.Breaker_L1_PriceTot,-- 57
            CZE_Quotes.Item_Motorized_B1,-- 58
            CZE_Quotes.Motorized_Breaker1,-- 59
            CZE_Quotes.Motorized_B1_Price,-- 60
            CZE_Quotes.Motorized_B1_TSheet,-- 61
            CZE_Quotes.Motorized_B1_PriceTot,-- 62
            CZE_Quotes.Item_breaker2,-- 63
            CZE_Quotes.Breaker2,-- 64
            CZE_Quotes.Breaker2_Price,-- 65
            CZE_Quotes.Breaker2_TSheet,-- 66
            CZE_Quotes.Breaker2_PriceTot,-- 67
            CZE_Quotes.Item_Sunt_t2,-- 68
            CZE_Quotes.Shunt_trip2,-- 69
            CZE_Quotes.Sunt_t2_Price,-- 70
            CZE_Quotes.Sunt_t2_TSheet,-- 71
            CZE_Quotes.Sunt_t2_PriceTot,-- 72
            CZE_Quotes.Item_Sunt_w2,-- 73
            CZE_Quotes.Shunt_trip_wiring2,-- 74
            CZE_Quotes.Sunt_w2_Price,-- 75
            CZE_Quotes.Sunt_w2_TSheet,-- 76
            CZE_Quotes.Sunt_w2_PriceTot,-- 77
            CZE_Quotes.Item_GFI2,-- 78
            CZE_Quotes.GFI2,-- 79
            CZE_Quotes.GFI2_Price,-- 80
            CZE_Quotes.GFI2_TSheet,-- 81
            CZE_Quotes.GFI2_PriceTot,-- 82
            CZE_Quotes.Item_Proyection_t2,-- 83
            CZE_Quotes.Protection_type2,-- 84
            CZE_Quotes.Proyection_t2_Price,-- 85
            CZE_Quotes.Proyection_t2_TSheet,-- 86
            CZE_Quotes.Proyection_t2_PriceTot,-- 87
            CZE_Quotes.Item_Auxiliary_c2,-- 88
            CZE_Quotes.Auxiliary_contacts2,-- 89
            CZE_Quotes.Auxiliary_c2_Price,-- 90
            CZE_Quotes.Auxiliary_c2_TSheet,-- 91
            CZE_Quotes.Auxiliary_c2_PriceTot,-- 92
            CZE_Quotes.Item_Breaker_L2,-- 93
            CZE_Quotes.Breaker_Lock2,-- 94
            CZE_Quotes.Breaker_L2_Price,-- 95
            CZE_Quotes.Breaker_L2_TSheet,-- 96
            CZE_Quotes.Breaker_L2_PriceTot,-- 97
            CZE_Quotes.Item_Motorized_B2,-- 98
            CZE_Quotes.Motorized_Breaker2,-- 99
            CZE_Quotes.Motorized_B2_Price,-- 100
            CZE_Quotes.Motorized_B2_TSheet,-- 101
            CZE_Quotes.Motorized_B2_PriceTot,-- 102
            CZE_Quotes.Item_breaker3,-- 103
            CZE_Quotes.Breaker3,-- 104
            CZE_Quotes.Breaker3_Price,-- 105
            CZE_Quotes.Breaker3_TSheet,-- 106
            CZE_Quotes.Breaker3_PriceTot,-- 107
            CZE_Quotes.Item_Sunt_t3,-- 108
            CZE_Quotes.Shunt_trip3,-- 109
            CZE_Quotes.Sunt_t3_Price,-- 110
            CZE_Quotes.Sunt_t3_TSheet,-- 111
            CZE_Quotes.Sunt_t3_PriceTot,-- 112
            CZE_Quotes.Item_Sunt_w3,-- 113
            CZE_Quotes.Shunt_trip_wiring3,-- 114
            CZE_Quotes.Sunt_w3_Price,-- 115
            CZE_Quotes.Sunt_w3_TSheet,-- 116
            CZE_Quotes.Sunt_w3_PriceTot,-- 117
            CZE_Quotes.Item_GFI3,-- 118
            CZE_Quotes.GFI3,-- 119
            CZE_Quotes.GFI3_Price,-- 120
            CZE_Quotes.GFI3_TSheet,-- 121
            CZE_Quotes.GFI3_PriceTot,-- 122
            CZE_Quotes.Item_Proyection_t3,-- 123
            CZE_Quotes.Protection_type3,-- 124
            CZE_Quotes.Proyection_t3_Price,-- 125
            CZE_Quotes.Proyection_t3_TSheet,-- 126
            CZE_Quotes.Proyection_t3_PriceTot,-- 127
            CZE_Quotes.Item_Auxiliary_c3,-- 128
            CZE_Quotes.Auxiliary_contacts3,-- 129
            CZE_Quotes.Auxiliary_c3_Price,-- 130
            CZE_Quotes.Auxiliary_c3_TSheet,-- 131
            CZE_Quotes.Auxiliary_c3_PriceTot,-- 132
            CZE_Quotes.Item_Breaker_L3,-- 133
            CZE_Quotes.Breaker_Lock3,-- 134
            CZE_Quotes.Breaker_L3_Price,-- 135
            CZE_Quotes.Breaker_L3_TSheet,-- 136
            CZE_Quotes.Breaker_L3_PriceTot,-- 137
            CZE_Quotes.Item_Motorized_B3,-- 138
            CZE_Quotes.Motorized_Breaker3,-- 139
            CZE_Quotes.Motorized_B3_Price,-- 140
            CZE_Quotes.Motorized_B3_TSheet,-- 141
            CZE_Quotes.Motorized_B3_PriceTot,-- 142
            CZE_Quotes.Item_controller,-- 143
            CZE_Quotes.ControlModel,-- 144
            CZE_Quotes.controller_Price,-- 145
            CZE_Quotes.controller_TSheet,-- 146
            CZE_Quotes.ControlModel_PriceTot,-- 147
            CZE_Quotes.Item_CtrlPanelHeater,-- 148
            CZE_Quotes.CtrlPanelHeater,-- 149
            CZE_Quotes.CtrlPanelHeater_Price,-- 150
            CZE_Quotes.CtrlPanelHeater_TSheet,-- 151
            CZE_Quotes.CtrlPanelHeat_PriceTot,-- 152
            CZE_Quotes.Item_RempteDisplMod,-- 153
            CZE_Quotes.RemoteDisplayModule,-- 154
            CZE_Quotes.RempteDisplMod_Price,-- 155
            CZE_Quotes.RempteDisplMod_TSheet,-- 156
            CZE_Quotes.RempteDisplMod_PriceTot,-- 157
            CZE_Quotes.Item_Antena,-- 158
            CZE_Quotes.Antena,-- 159
            CZE_Quotes.Antena_Price,-- 160
            CZE_Quotes.Antena_TSheet,-- 161
            CZE_Quotes.Antena_PriceTot,-- 162
            CZE_Quotes.Item_DSE890,-- 163
            CZE_Quotes.DSE890,-- 164
            CZE_Quotes.DSE890_Price,-- 165
            CZE_Quotes.DSE890_TSheet,-- 166
            CZE_Quotes.DSE890_PriceTot,-- 167
            CZE_Quotes.Item_DSE2157,-- 168
            CZE_Quotes.DSE2157,-- 169
            CZE_Quotes.QtyDSE2157,-- 170
            CZE_Quotes.DSE2157_Price,-- 171
            CZE_Quotes.DSE2157_TSheet,-- 172
            CZE_Quotes.DSE2157_PriceTot,-- 173
            CZE_Quotes.Item_DSE2548,-- 174
            CZE_Quotes.DSE2548,-- 175
            CZE_Quotes.QtyDSE2548,-- 176
            CZE_Quotes.DSE2548_Price,-- 177
            CZE_Quotes.DSE2548_TSheet,-- 178
            CZE_Quotes.DSE2548_PriceTot,-- 179
            
            CZE_Quotes.Item_ComapDSE890,-- 180
            CZE_Quotes.ComapDSE890,-- 181
            CZE_Quotes.ComapDSE890_Price,-- 182
            CZE_Quotes.ComapDSE890_TSheet,-- 183
            CZE_Quotes.ComapDSE890_PriceTot,-- 184

            CZE_Quotes.Item_ComapDSE2157,-- 185
            CZE_Quotes.ComapDSE2157,-- 186
            CZE_Quotes.QtyComapDSE2157,-- 187
            CZE_Quotes.ComapDSE2157_Price,-- 188
            CZE_Quotes.ComapDSE2157_TSheet,-- 189
            CZE_Quotes.ComapDSE2157_PriceTot,-- 190
            CZE_Quotes.Item_ComapDSE2548,-- 191
            CZE_Quotes.ComapDSE2548,-- 192
            CZE_Quotes.QtyComapDSE2548,-- 193
            CZE_Quotes.ComapDSE2548_Price,-- 194
            CZE_Quotes.ComapDSE2548_TSheet,-- 195
            CZE_Quotes.ComapDSE2548_PriceTot,-- 196
            CZE_Quotes.Item_CtrlVotlOper,-- 197
            CZE_Quotes.CtrlVotlOper,-- 198
            CZE_Quotes.CtrlVotlOper_Price,-- 199
            CZE_Quotes.CtrlVotlOper_TSheet,-- 200
            CZE_Quotes.CtrlVotlOper_PriceTot,-- 201
            CZE_Quotes.Item_BateryCharger,-- 202
            CZE_Quotes.BateryCharger,-- 203
            CZE_Quotes.BateryCharger_Price,-- 204
            CZE_Quotes.BateryCharger_TSheet,-- 205
            CZE_Quotes.BateryCharger_PriceTot,-- 206
            CZE_Quotes.Item_Enclosuree_type,-- 207
            CZE_Quotes.Enclosure,-- 208
            CZE_Quotes.Item_Eclousure_Mat,-- 209
            CZE_Quotes.EnclosureType,-- 210
            CZE_Quotes.Enclosure_ConfigID,-- 211
            CZE_Quotes.Enclosure_price,-- 212
            CZE_Quotes.Enclosure_TSheet,-- 213
            CZE_Quotes.Enclosure_PriceTot,-- 214
            CZE_Quotes.Item_GFCI120V,-- 215
            CZE_Quotes.GFCI120V,-- 216
            CZE_Quotes.QtyGFCI120V,-- 217
            CZE_Quotes.GFCI120V_Price,-- 218
            CZE_Quotes.GFCI120V_TSheet,-- 219
            CZE_Quotes.GFCI120V_PriceTot,-- 220
            CZE_Quotes.Item_Receptable120V,-- 221
            CZE_Quotes.Receptable120V,-- 222
            CZE_Quotes.QtyReceptable120V,-- 223
            CZE_Quotes.Receptable120V_Price,-- 224
            CZE_Quotes.Receptable120V_TSheet,-- 225
            CZE_Quotes.Receptable120V_PriceTot,-- 226
            CZE_Quotes.Item_Enclosure_ligthAC,-- 227
            CZE_Quotes.lightAC,-- 228
            CZE_Quotes.QtylightAC,-- 229
            CZE_Quotes.lightAC_price,-- 230
            CZE_Quotes.lightAC_TSheet,-- 231
            CZE_Quotes.lightAC_PriceTot,-- 232
            CZE_Quotes.Item_Enclosure_ligthDC,-- 233
            CZE_Quotes.lightDC,-- 234
            CZE_Quotes.QtylightDC,-- 235
            CZE_Quotes.lightDC_price,-- 236
            CZE_Quotes.lightDC_TSheet,-- 237
            CZE_Quotes.lightDC_PriceTot,-- 238
            CZE_Quotes.Item_Enclosure_SHeater,-- 239
            CZE_Quotes.SpaceHeater,-- 240
            CZE_Quotes.QtySpaceHeater,-- 241
            CZE_Quotes.SpaceHeater_price,-- 242
            CZE_Quotes.SpaceHeater_TSheet,-- 243
            CZE_Quotes.SpaceHeater_PriceTot,-- 244
            CZE_Quotes.Item_Enclosure_LCenter,-- 245
            CZE_Quotes.LoadCenter,-- 246
            CZE_Quotes.LoadCenter_price,-- 247
            CZE_Quotes.LoadCenter_TSheet,-- 248
            CZE_Quotes.LoadCenter_PriceTot,-- 249
            CZE_Quotes.Item_PrewireAccsEncl,-- 250
            CZE_Quotes.PrewireAccsEnclousure,-- 251
            CZE_Quotes.PrewireAccsEnclo_Price,-- 252
            CZE_Quotes.PrewireAccsEnclo_TSheet,-- 253
            CZE_Quotes.PrewireAccsEnc_PriceTot,-- 254
            CZE_Quotes.Item_autolouvers,-- 255
            CZE_Quotes.autolouvers,-- 256
            CZE_Quotes.autolouvers_Price,-- 257
            CZE_Quotes.autolouvers_TSheet,-- 258
            CZE_Quotes.autolouvers_PriceTot,-- 259
            CZE_Quotes.Item_Receptautolouvers,-- 260
            CZE_Quotes.Receptautolouvers,-- 261
            CZE_Quotes.Receptautolouver_Price,-- 262
            CZE_Quotes.Receptautolouver_TSheet,-- 263
            CZE_Quotes.Receptautolouv_PriceTot,-- 264
            CZE_Quotes.Item_BandHeater,-- 265
            CZE_Quotes.BandHeater,-- 266
            CZE_Quotes.BandHeater_Price,-- 267
            CZE_Quotes.BandHeater_TSheet,-- 268
            CZE_Quotes.BandHeater_PriceTot,-- 269
            CZE_Quotes.Item_PMGUpdate,-- 270
            CZE_Quotes.PMGUpdate,-- 271
            CZE_Quotes.PMGUpdate_Price,-- 272
            CZE_Quotes.PMGUpdate_TSheet,-- 273
            CZE_Quotes.PMGUpdate_PriceTot,-- 274
            CZE_Quotes.Item_DigitalRegulator,-- 275
            CZE_Quotes.DigitalRegulator,-- 276
            CZE_Quotes.DigitalRegulator_Price,-- 277
            CZE_Quotes.DigitalRegulator_TSheet,-- 278
            CZE_Quotes.DigitalRegulat_PriceTot,-- 279
            CZE_Quotes.Item_VoltageRheostat,-- 280
            CZE_Quotes.VoltageRheostat,-- 281
            CZE_Quotes.VoltageRheostat_Price,-- 282
            CZE_Quotes.VoltageRheostat_TSheet,-- 283
            CZE_Quotes.VoltageRheosta_PriceTot,-- 284
            CZE_Quotes.Item_ThermalWrap,-- 285
            CZE_Quotes.ThermalWrap,-- 286
            CZE_Quotes.ThermalWrap_Price,-- 287
            CZE_Quotes.ThermalWrap_TSheet,-- 288
            CZE_Quotes.ThermalWrap_PriceTot,-- 289
            CZE_Quotes.Item_BaseHeater,-- 290
            CZE_Quotes.BaseHeater,-- 291
            CZE_Quotes.BaseHeater_Price,-- 292
            CZE_Quotes.BaseHeater_TSheet,-- 293
            CZE_Quotes.BaseHeater_PriceTot,-- 294
            CZE_Quotes.Item_BatterySwitch,-- 295
            CZE_Quotes.BatterySwitch,-- 296
            CZE_Quotes.BatterySwitch_Price,-- 297
            CZE_Quotes.BatterySwitch_TSheet,-- 298
            CZE_Quotes.BatterySwitch_PriceTot,-- 299
            CZE_Quotes.Item_BatteryHolder,-- 300
            CZE_Quotes.BatteryHolder,-- 301
            CZE_Quotes.BatteryHolder_Price,-- 302
            CZE_Quotes.BatteryHolder_TSheet,-- 303
            CZE_Quotes.BatteryHolder_PriceTot,-- 304
            CZE_Quotes.Item_OilHeater,-- 305
            CZE_Quotes.OilHeater,-- 306
            CZE_Quotes.OilHeater_Price,-- 307
            CZE_Quotes.OilHeater_TSheet,-- 308
            CZE_Quotes.OilHeater_PriceTot,-- 309
            CZE_Quotes.Item_OilLevelSwitch,-- 310
            CZE_Quotes.OilLevelSwitch,-- 311
            CZE_Quotes.OilLevelSwitch_Price,-- 312
            CZE_Quotes.OilLevelSwitch_TSheet,-- 313
            CZE_Quotes.OilLevelSwitch_PriceTot,-- 314
            CZE_Quotes.Item_CommonAlarmRelay,-- 315
            CZE_Quotes.CommonAlarmRelay,-- 316
            CZE_Quotes.CommonAlarmRelay_Price,-- 317
            CZE_Quotes.CommonAlarmRelay_TSheet,-- 318
            CZE_Quotes.CommonAlarmRel_PriceTot,-- 319
            CZE_Quotes.Item_FunctionRelay,-- 320
            CZE_Quotes.FunctionRelay,-- 321
            CZE_Quotes.FunctionRelay_Price,-- 322
            CZE_Quotes.FunctionRelay_TSheet,-- 323
            CZE_Quotes.FunctionRelay_PriceTot,-- 324
            CZE_Quotes.Item_Coolant,-- 325
            CZE_Quotes.Coolant,-- 326
            CZE_Quotes.Coolant_Price,-- 327
            CZE_Quotes.Coolant_TSheet,-- 328
            CZE_Quotes.Coolant_PriceTot,-- 329
            CZE_Quotes.Item_Oil,-- 330
            CZE_Quotes.Oil,-- 331
            CZE_Quotes.Oil_Price,-- 332
            CZE_Quotes.Oil_TSheet,-- 333
            CZE_Quotes.Oil_PriceTot,-- 334
            CZE_Quotes.Item_DisconnectSwitches,-- 335
            CZE_Quotes.DisconnectSwitches,-- 336
            CZE_Quotes.DisconnectSwitch_Price,-- 337
            CZE_Quotes.DisconnectSwitch_TSheet,-- 338
            CZE_Quotes.DisconnectSwit_PriceTot,-- 339
            CZE_Quotes.Item_AddAccesory_Estop,-- 340
            CZE_Quotes.EStop,-- 341
            CZE_Quotes.QtyEStop,-- 342
            CZE_Quotes.EStop_price,-- 343
            CZE_Quotes.EStop_TSheet,-- 344
            CZE_Quotes.EStop_PriceTot,-- 345
            CZE_Quotes.Item_RemoteEStop,-- 346
            CZE_Quotes.RemoteEStop,-- 347
            CZE_Quotes.RemoteEStop_Price,-- 348
            CZE_Quotes.RemoteEStop_TSheet,-- 349
            CZE_Quotes.RemoteEStop_PriceTot,-- 350
            CZE_Quotes.Item_AddAccesory_Spring,-- 351
            CZE_Quotes.SpringIsolator,-- 352
            CZE_Quotes.SpringIsolator_price,-- 353
            CZE_Quotes.SpringIsolator_TSheet,-- 354
            CZE_Quotes.SpringIsolator_PriceTot,-- 355
            CZE_Quotes.Item_Tank_Autonomy,-- 356
            CZE_Quotes.TankCapacity,-- 357
            CZE_Quotes.Item_Tank_type,-- 358
            CZE_Quotes.TankType,-- 359
            CZE_Quotes.Tank_ConfigID,-- 360
            CZE_Quotes.Tank_CapacityGAL,-- 361
            CZE_Quotes.Tank_price,-- 362
            CZE_Quotes.Tank_TSheet,-- 363
            CZE_Quotes.Tank_PriceTot,-- 364
            CZE_Quotes.Item_BreakTraySwitch,-- 365
            CZE_Quotes.BreakTraySwitch,-- 366
            CZE_Quotes.BreakTraySwitch_Price,-- 367
            CZE_Quotes.BreakTraySwitch_TSheet,-- 368
            CZE_Quotes.BreakTraySwitc_PriceTot,-- 369
            CZE_Quotes.Item_FuelLevelSensor,-- 370
            CZE_Quotes.FuelLevelSensor,-- 371
            CZE_Quotes.FuelLevelSensor_Price,-- 372
            CZE_Quotes.FuelLevelSensor_TSheet,-- 373
            CZE_Quotes.FuelLevelSenso_PriceTot,-- 374
            CZE_Quotes.Item_Tank_SpillCont,-- 375
            CZE_Quotes.SpillContainment,-- 376
            CZE_Quotes.SpillContainment_Price,-- 377
            CZE_Quotes.SpillContainment_TSheet,-- 378
            CZE_Quotes.SpillContainme_PriceTot,-- 379
            CZE_Quotes.Item_OverfillValve,-- 380
            CZE_Quotes.OverfillValve,-- 381
            CZE_Quotes.OverfillValve_Price,-- 382
            CZE_Quotes.OverfillValve_TSheet,-- 383
            CZE_Quotes.OverfillValve_PriceTot,-- 384
            CZE_Quotes.Item_DualFuelSwitch,-- 385
            CZE_Quotes.DualFuelSwitches,-- 386
            CZE_Quotes.DualFuelSwitches_Price,-- 387
            CZE_Quotes.DualFuelSwitches_TSheet,-- 388
            CZE_Quotes.DualFuelSwitch_PriceTot,-- 389
            CZE_Quotes.Item_HighFuelSwitch,-- 390
            CZE_Quotes.HighFuelSwitch,-- 391
            CZE_Quotes.HighFuelSwitch_Price,-- 392
            CZE_Quotes.HighFuelSwitch_TSheet,-- 393
            CZE_Quotes.HighFuelSwitch_PriceTot,-- 394
            CZE_Quotes.Item_RemoteAlarmP,-- 395
            CZE_Quotes.RemoteAlarmPanel,-- 396
            CZE_Quotes.RemoteAlarmPanel_Price,-- 397
            CZE_Quotes.RemoteAlarmPanel_TSheet,-- 398
            CZE_Quotes.RemoteAlarmPan_PriceTot,-- 399
            CZE_Quotes.Item_VentPipe,-- 400
            CZE_Quotes.VentPipe,-- 401
            CZE_Quotes.VentPipe_Price,-- 402
            CZE_Quotes.VentPipe_TSheet,-- 403
            CZE_Quotes.VentPipe_PriceTot,-- 404
            CZE_Quotes.Item_FlammableL,-- 405
            CZE_Quotes.FlammableLiquids,-- 406
            CZE_Quotes.FlammableLiquids_Price,-- 407
            CZE_Quotes.FlammableLiquids_TSheet,-- 408
            CZE_Quotes.FlammableLiqui_PriceTot,-- 409
            CZE_Quotes.Item_NFPAIdentificat,-- 410
            CZE_Quotes.NFPAIdentification,-- 411
            CZE_Quotes.NFPAIdentificat_Price,-- 412
            CZE_Quotes.NFPAIdentificat_TSheet,-- 413
            CZE_Quotes.NFPAIdentifica_PriceTot,-- 414
            CZE_Quotes.Item_NoSmoking,-- 415
            CZE_Quotes.NoSmoking,-- 416
            CZE_Quotes.NoSmoking_Price,-- 417
            CZE_Quotes.NoSmoking_TSheet,-- 418
            CZE_Quotes.NoSmoking_PriceTot,-- 419
            CZE_Quotes.Item_TankNumber,-- 420
            CZE_Quotes.TankNumber,-- 421
            CZE_Quotes.TankNumber_Price,-- 422
            CZE_Quotes.TankNumber_TSheet,-- 423
            CZE_Quotes.TankNumber_PriceTot,-- 424
            CZE_Quotes.Item_FluidContainment,-- 425
            CZE_Quotes.FluidContainment,-- 426
            CZE_Quotes.FluidContainment_Price,-- 427
            CZE_Quotes.FluidContainment_TSheet,-- 428
            CZE_Quotes.FluidContainme_PriceTot,-- 429
            CZE_Quotes.Project,-- 430
            CZE_Quotes.Item_PrjWar_Warranty,-- 431
            CZE_Quotes.Garanty,-- 432
            CZE_Quotes.Garanty_Percentage,-- 433
            CZE_Quotes.Garanty_price,-- 434
            CZE_Quotes.Garanty_PriceTot,-- 435
            CZE_Quotes.Item_PrjWar_Testing,-- 436
            CZE_Quotes.Teasting,-- 437
            CZE_Quotes.Teasting_ConfigID,-- 438
            CZE_Quotes.Teasting_price,-- 439
            CZE_Quotes.Teasting_Document,-- 440
            CZE_Quotes.Teasting_PriceTot,-- 441
            CZE_Quotes.ReqCustomer,-- 442
            CZE_Quotes.EngineModel,-- 443
            CZE_Quotes.Engine_TSheet,-- 444
            CZE_Quotes.Engine_Tier,-- 445
            CZE_Quotes.Engine_Rpm,-- 446
            CZE_Quotes.Engine_Power,-- 447
            CZE_Quotes.Engine_NumberOfCylinder,-- 448
            CZE_Quotes.Engine_Aspiration,-- 449
            CZE_Quotes.Engine_Governor_type,-- 450
            CZE_Quotes.Engine_Control_voltage,-- 451
            CZE_Quotes.Engine_Battery_type,-- 452
            CZE_Quotes.Engine_Hotstart_model,-- 453
            CZE_Quotes.Engine_RadiatorTemp,-- 454
            CZE_Quotes.AlternatorModel,-- 455
            CZE_Quotes.Altern_TSheet,-- 456
            CZE_Quotes.Altern_Powerfactor,-- 457
            CZE_Quotes.Altern_Insulation_Sys,-- 458
            CZE_Quotes.Altern_Control_System,-- 459
            CZE_Quotes.Altern_Protection,-- 460
            CZE_Quotes.Altern_AvrModel,-- 461
            CZE_Quotes.Altern_VoltageRegulat,-- 462
            CZE_Quotes.Altern_Class_temp_rise,-- 463
			(
			SELECT
				CASE
					WHEN CZE_Voltage.Phases = 'Single' THEN 1
					WHEN CZE_Voltage.Phases = 2 THEN 2
					WHEN CZE_Voltage.Phases = 3 THEN 3
				END
			FROM
				CZE_Voltage
			WHERE 
				CZE_Voltage.VoltageID = CZE_Quotes.VoltageID
			) AS Phases,-- 464
			(
			SELECT
				CONCAT( UPPER (CZE_TankType.description),' - ', CZE_TankConfig.CapacityGAL, ' GAL',' - ', CZE_TankAutonomy.description)
				/*
				CZE_TankType.description,
				CZE_TankConfig.CapacityGAL,
				CZE_TankAutonomy.description
				*/
			FROM
				CZE_TankConfig
			LEFT JOIN
				CZE_TankType ON CZE_TankConfig.Item_Tank_type = CZE_TankType.Item_Tank_type
			LEFT JOIN
				CZE_TankAutonomy ON CZE_TankConfig.Item_Tank_Autonomy = CZE_TankAutonomy.Item_Tank_Autonomy
			WHERE 
				CZE_TankConfig.ConfigID = CZE_Quotes.Tank_ConfigID
			) AS BaseTank,-- 465
			(
			SELECT
				CONCAT( 'AUTONOMY ', CZE_TankAutonomy.description)
			FROM
				CZE_TankConfig
			LEFT JOIN
				CZE_TankType ON CZE_TankConfig.Item_Tank_type = CZE_TankType.Item_Tank_type
			LEFT JOIN
				CZE_TankAutonomy ON CZE_TankConfig.Item_Tank_Autonomy = CZE_TankAutonomy.Item_Tank_Autonomy
			WHERE 
				CZE_TankConfig.ConfigID = CZE_Quotes.Tank_ConfigID
			) AS TankAutonomy,-- 466
			(
			SELECT
				CONCAT (CZE_EnclosureMaterial.description, ' - ', CZE_EnclosureType.Front)
			FROM
				CZE_EnclosureConfig
			LEFT JOIN
				CZE_EnclosureMaterial ON CZE_EnclosureConfig.Item_Enclosure_Mat = CZE_EnclosureMaterial.Item_Eclousure_Mat
			LEFT JOIN
				CZE_EnclosureType ON CZE_EnclosureConfig.Item_Enclosure_type = CZE_EnclosureType.Item_Enclosuree_type
			WHERE 
				CZE_EnclosureConfig.ConfigID = CZE_Quotes.Enclosure_ConfigID
			) AS AcousticEnclosure,-- 467
            CZE_Quotes.CustomerCompany,-- 468
            CZE_Quotes.CustomerAddress,-- 469
            CZE_Quotes.CustomerContact,-- 470
            CZE_Quotes.CustomerEmail,-- 471
            CZE_Quotes.CustomerTel,-- 472
            CZE_Quotes.SellerName,-- 473
            CZE_Quotes.SellerEmail,-- 474
            CZE_Quotes.SellerPhone, -- 475
            CZE_Quotes.Destiny_Country, -- 476
            CZE_Quotes.Destiny_State, -- 477
            CZE_Quotes.Country_Discount, --478
            CZE_Quotes.Commercial_Offer, --479


            CZE_Quotes.Item_CtrlPanelHeaterCMP, --480
            CZE_Quotes.CtrlPanelHeaterCMP, --481
            CZE_Quotes.CtrlPanelHeaterCMP_Price, --482
            CZE_Quotes.CtrlPanelHeaterCMP_TSheet, --483
            CZE_Quotes.CtrlPanelHeatCMP_PriceTot, --484,

            -- Módulo de Pantalla Remota
            CZE_Quotes.Item_RempteDisplModCMP, --485
            CZE_Quotes.RemoteDisplayModuleCMP, --486
            CZE_Quotes.RempteDisplModCMP_Price, --487
            CZE_Quotes.RempteDisplModCMP_TSheet, --488
            CZE_Quotes.RempteDisplModCMP_PriceTot, --489

            -- Antena CMP GSM / GPS
            CZE_Quotes.Item_AntenaCMP, --490
            CZE_Quotes.AntenaCMP, --491
            CZE_Quotes.AntenaCMP_Price, --492
            CZE_Quotes.AntenaCMP_TSheet, --493
            CZE_Quotes.AntenaCMP_PriceTot, --494

            -- CM3 Ethernet / 4G gateway device
            CZE_Quotes.Item_ComapDSE890, --495
            CZE_Quotes.ComapDSE890, --496
            CZE_Quotes.ComapDSE890_Price, --497
            CZE_Quotes.ComapDSE890_TSheet, --498
            CZE_Quotes.ComapDSE890_PriceTot, --499

            -- CMP-IRB8 Output module
            CZE_Quotes.Item_ComapDSE2157, --500
            CZE_Quotes.ComapDSE2157, --501
            CZE_Quotes.ComapDSE2157_Price, --502
            CZE_Quotes.ComapDSE2157_TSheet, --503
            CZE_Quotes.ComapDSE2157_PriceTot, --504

            -- IGLRA15 Remote annunciator
            CZE_Quotes.Item_ComapDSE2548, --505
            CZE_Quotes.ComapDSE2548, --506
            CZE_Quotes.ComapDSE2548_Price, --507
            CZE_Quotes.ComapDSE2548_TSheet, --508
            CZE_Quotes.ComapDSE2548_PriceTot, --509

            CZE_Quotes.Item_OpeningEnclousure, --510
            CZE_Quotes.OpeningEnclousure, --511
            CZE_Quotes.OpeningEnclousure_Price, --512
            CZE_Quotes.OpeningEnclousure_TSheet, --513
            CZE_Quotes.OpeningEnclousure_PriceTot, --514

            CZE_Quotes.Item_StopButtonEnclosure, --515
            CZE_Quotes.StopButtonEnclosure, --516
            CZE_Quotes.StopButtonEnclosure_Price, --517
            CZE_Quotes.StopButtonEnclosure_TSheet, --518
            CZE_Quotes.StopButtonEnclosure_PriceTot, --519
            CZE_Quotes.StopButtonEnclosure_Qty, --520


            CZE_Quotes.Item_louvers_in, --521
            CZE_Quotes.louvers_in, --522
            CZE_Quotes.louvers_in_price, --523
            CZE_Quotes.louvers_in_tsheet, --524
            CZE_Quotes.louvers_in_pricetot, --525

            CZE_Quotes.Item_louvers_out, --526
            CZE_Quotes.louvers_out, --527
            CZE_Quotes.louvers_out_price, --528
            CZE_Quotes.louvers_out_tsheet,  --529
            CZE_Quotes.louvers_out_pricetot --530


        FROM CZE_Quotes
        WHERE QuoteID = ?
    c                 S   s   g | ]}|d  qS r   r   r	   columnr   r   r   r   -  s     z-get_Definitive_quote_data.<locals>.<listcomp>NrM  	r   r   r   r/   ri   dictzipr   r   ro   r   r   r   columnsr
   r   r   r   r   get_Definitive_quote_data  s"        br  c              
   C   s   d}z^t  N}| }||| f | }|rF|d W  5 Q R  W S W 5 Q R  W dS W 5 Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )zGObtiene el GensetModel desde la tabla CZE_GensetConfig usando ConfigID.z
    SELECT 
        CZE_GensetConfig.GensetModel
    FROM 
        CZE_GensetCost
    LEFT JOIN
        CZE_GensetConfig ON CZE_GensetCost.ConfigID = CZE_GensetConfig.ConfigID
    WHERE 
        CostID = ?
    r   NzError al obtener GensetModel: rn   )Zgenset_cost_idr   r   r   rk   r   r   r   r   get_genset_model=  s    r  c              
   C   s   d}zht  X}| }||| f | }|rP|d |d dW  5 Q R  W S W 5 Q R  W dS W 5 Q R X W n2 tk
r } ztd|   W 5 d}~X Y nX dS )zEObtiene la frecuencia y las fases de acuerdo al voltaje seleccionado.zh
    SELECT
        Frecuency,
        Phases
    FROM CZE_Voltage
    WHERE 
        VoltageID = ?
    r   r   )	FrecuencyPhasesNz'Error al obtener los datos de voltaje: rn   )Z
Voltage_IDr   r   r   rk   r   r   r   r   get_frecuencyY  s    	r  c              
   C   s   d}zpt  `}| }||| f dd |jD }| }|r\tt||W  5 Q R  W S W 5 Q R  W d S Q R X W n2 tk
r } ztd|   W 5 d }~X Y nX d S )Nz{
            SELECT 
                CZE_Quotes.RoutePDF
            FROM CZE_Quotes
            WHERE QuoteID = ?
        c                 S   s   g | ]}|d  qS r  r   r  r   r   r   r     s     z get_RoutePDF.<locals>.<listcomp>rM  r  r  r   r   r   get_RoutePDFw  s    r  c              
   C   sr   d}z6t  &}| }||| |f |  W 5 Q R X W n2 tk
rl } ztd|   W 5 d }~X Y nX d S )NzO
    UPDATE CZE_Quotes
    SET 
        RoutePDF = ?
    WHERE QuoteID = ?
    zError actualizando RoutePDF: rt  )RoutePDFro   r   r   r   r   r   r   r   update_RoutePDF  s    r  N)r   )r   )r   )r   )r   )r   )r   )r   )r   )r   )r   T)r   )r   )r   )r   )r   )r   )r   )r   )r   )r   )r   )r   )[Consultas_SQL.conexionr   typingr   r   r   r!   r#   r%   r(   r*   r,   r.   r3   r5   r7   r;   r?   r@   rA   rC   rD   rE   rF   rG   rH   rI   rK   rM   rN   rQ   rR   rS   rl   rm   rp   rs   rI  strrK  rN  rs  ru  ry  rz  r~  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r   <module>   s   (&*/37;<*'" 
  !
l7
#
#
"*
!
!
!
"
!.
'
!
!
!'
"
!*
!
!
!3
&
!
!0
#
'    z