###############################################################################
# File:        guTransportOrdersListView.py
# Appointment: List of transport orders
# Project:     GalaxyU
# Author:      AR
# History:
# 09.01.2014 Created
###############################################################################
import wxTools
import guObjects
import guApp
import guGroundBattle
import guListView
import guPlanetView

import wx


#===============================================================================
# List control
#===============================================================================
class CTransportOrdersViewCtrl(guListView.CListViewCtrlWithBuilder):
    #---------------------------------------------------------------------------
    def __init__(self, parent, aListCreator):
        guListView.CListViewCtrlWithBuilder.__init__(self, parent, aListCreator)
        
    #---------------------------------------------------------------------------
    # Redefined virtual
    def PrepareBuilder(self, aBuilder):
        # Add columns
        aBuilder.AddColumn("Nation", lambda data: data.NationName)
        aBuilder.AddColumn("Id", lambda data: str(data.OrderId), wx.LIST_FORMAT_RIGHT, True)
        aBuilder.AddColumn("Cargo type", lambda data: data.CargoType)
        aBuilder.AddColumn("Ordered", lambda data: "{0:.2f}".format(data.OrderedAmount), wx.LIST_FORMAT_RIGHT, True)
        aBuilder.AddColumn("Delivered", lambda data: "{0:.2f}".format(data.ProducedAmount), wx.LIST_FORMAT_RIGHT, True)
        aBuilder.AddColumn(\
            "To deliver",
            lambda data: "{0:.2f}".format(data.OrderedAmount - data.ProducedAmount), wx.LIST_FORMAT_RIGHT, True)
        aBuilder.AddColumn("From", lambda data: guApp.Application.GetReport().GetStarName(data.StartStarId))
        aBuilder.AddColumn("To", lambda data: guApp.Application.GetReport().GetStarName(data.DestinationStarId))
        aBuilder.AddColumn("Status", lambda data: data.Status)
        

#-------------------------------------------------------------------------------

#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# Shows a list of orders
#>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
def ShowTransportOrdersList():
    return guApp.Application.WindowsCollection.RegisterAndShow(\
        lambda: guListView.CListViewFrame(\
            guApp.Application.GetMainWindow(),
            lambda: guApp.Application.GetReport().TransportOrders,
            lambda panel, aListCreators: CTransportOrdersViewCtrl(panel, aListCreators),
            "CTransportOrdersViewCtrl", 
            "All Transport Orders"))
#<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
