NovaBryan/EVE_Dump
Log | Files | 📦 下载最新源码 (.zip) | Refs | README

contractPanels.py (25160B)


      1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\eve\client\script\ui\shared\neocom\contracts\contractPanels.py
      2 import eveicon
      3 import gametime
      4 from carbon.common.script.util.format import FmtDate
      5 import uthread
      6 from carbonui import uiconst
      7 from carbonui.control.buttonIcon import ButtonIcon
      8 from carbonui.control.combo import Combo
      9 from carbonui.control.scrollContainer import ScrollContainer
     10 from carbonui.primitives.gridcontainer import GridContainer
     11 from carbonui.control.singlelineedits.singleLineEditText import SingleLineEditText
     12 from carbonui.primitives.container import Container
     13 from carbonui.button.group import ButtonGroup
     14 from carbonui.control.button import Button
     15 from eve.client.script.ui.control.entries.util import GetFromClass
     16 from eve.client.script.ui.control.eveLabel import EveCaptionLarge
     17 from eve.client.script.ui.control.eveScroll import Scroll
     18 from eve.client.script.ui.shared.neocom.contracts.contractentry import ContractEntrySmall, ContractStartPageEntry
     19 from eve.client.script.ui.util import searchOld
     20 from eve.client.script.util.contractutils import IsSearchStringLongEnough, ConFmtDate, GetColoredContractStatusText, GetContractLabel
     21 from eve.common.lib import appConst
     22 from eve.common.script.sys import idCheckers
     23 from eve.common.script.util.contractscommon import CONTYPE_AUCTIONANDITEMECHANGE
     24 import evelink
     25 from eveexceptions import UserError
     26 from localization import GetByLabel
     27 import blue
     28 from player_messaging.client.ui_message import prompt_player_fsd_dialog
     29 from utillib import KeyVal
     30 RESULTS_PER_PAGE = 100
     31 MAX_IGNORED = 1000
     32 
     33 class StartPagePanel(Container):
     34     __notifyevents__ = ['OnContractCacheCleared']
     35     __guid__ = 'xtriui.StartPagePanel'
     36     submitFunc = None
     37 
     38     def ApplyAttributes(self, attributes):
     39         super(StartPagePanel, self).ApplyAttributes(attributes)
     40         self.ConstructLayout()
     41         sm.RegisterNotify(self)
     42 
     43     def AddItem(self, icon, header, text, isSmall = False):
     44         header = unicode(header).replace('\n', '')
     45         text = text.rstrip('\n')
     46         data = {'header': header,
     47          'text': text,
     48          'icon': icon,
     49          'isSmall': isSmall}
     50         ContractStartPageEntry(parent=self.startPageScroll, align=uiconst.TOTOP, node=KeyVal(data))
     51 
     52     def ConstructLayout(self):
     53         header = EveCaptionLarge(text=GetByLabel('UI/Contracts/ContractEntry/MyStartPage'), parent=self, left=14, top=8)
     54         self.startPageScroll = ScrollContainer(parent=self, align=uiconst.TOALL, padding=(uiconst.defaultPadding,
     55          header.textheight + uiconst.defaultPadding * 2,
     56          uiconst.defaultPadding,
     57          uiconst.defaultPadding))
     58         self.buttonGroup = ButtonGroup(parent=self, idx=0)
     59         self.buttonGroup.AddButton(GetByLabel('UI/Inventory/ItemActions/CreateContract'), lambda x: sm.GetService('contracts').OpenCreateContract())
     60 
     61     def Init(self):
     62         self.startPageScroll.Flush()
     63         mpi = sm.GetService('contracts').CollectMyPageInfo()
     64         n = mpi.numContractsLeft
     65         ntot = mpi.numContractsTotal
     66         np = mpi.numContractsLeftInCorp
     67         nforcorp = mpi.numContractsLeftForCorp
     68         desc = GetByLabel('UI/Contracts/ContractsService/YouCanCreateNew', numContracts=ntot)
     69         if not idCheckers.IsNPC(session.corpid):
     70             desc += '<br>' + GetByLabel('UI/Contracts/ContractsService/YouCanCreateForCorp', numContracts=np)
     71         if session.corprole & appConst.corpRoleContractManager == appConst.corpRoleContractManager:
     72             desc += '<br>' + GetByLabel('UI/Contracts/ContractsService/YouCanCreateOnBehalfOfCorp', numContracts=nforcorp)
     73         createLabel = GetByLabel('UI/Contracts/ContractsService/YouCanCreate', numContracts=n)
     74         self.AddItem('res:/ui/Texture/WindowIcons/contracts.png', evelink.local_service_link('OpenCreateContract', createLabel), desc)
     75         ignoreList = set(settings.user.ui.Get('contracts_ignorelist', []))
     76         numAssignedToMeAuctionItemExchange = 0
     77         numAssignedToMeCourier = 0
     78         numAssignedToMyCorpAuctionItemExchange = 0
     79         numAssignedToMyCorpCourier = 0
     80         if mpi.outstandingContracts is None:
     81             prompt_player_fsd_dialog('ConNotReady')
     82             mpi.outstandingContracts = []
     83         else:
     84             for contract in mpi.outstandingContracts:
     85                 if contract[0] in ignoreList or contract[1] in ignoreList:
     86                     continue
     87                 if contract[2] == session.charid:
     88                     if contract[3] == appConst.conTypeCourier:
     89                         numAssignedToMeCourier += 1
     90                     else:
     91                         numAssignedToMeAuctionItemExchange += 1
     92                 elif contract[3] == appConst.conTypeCourier:
     93                     numAssignedToMyCorpCourier += 1
     94                 else:
     95                     numAssignedToMyCorpAuctionItemExchange += 1
     96 
     97         if mpi.numRequiresAttention > 0:
     98             attentionReqLabel = GetByLabel('UI/Contracts/ContractsService/RequireAttention', numContracts=mpi.numRequiresAttention)
     99             attentionReqDescLabel = GetByLabel('UI/Contracts/ContractsService/RequiresAttentionDesc')
    100             self.AddItem('res:/ui/Texture/WindowIcons/warning.png', evelink.local_service_link('ShowContracts', attentionReqLabel, status=-1, forCorp=0), attentionReqDescLabel)
    101         if mpi.numRequiresAttentionCorp > 0:
    102             attentionReqCorpLabel = GetByLabel('UI/Contracts/ContractsService/RequireAttentionCorp', numContracts=mpi.numRequiresAttentionCorp)
    103             attentionReqCorpDescLabel = GetByLabel('UI/Contracts/ContractsService/RequireAttentionCorpDesc')
    104             self.AddItem('res:/ui/Texture/WindowIcons/warning.png', evelink.local_service_link('ShowContracts', attentionReqCorpLabel, status=-1, forCorp=1), attentionReqCorpDescLabel)
    105         if numAssignedToMeAuctionItemExchange > 0 or numAssignedToMeCourier > 0:
    106             assignedLabel = GetByLabel('UI/Contracts/ContractsService/AssignedPersonal', numContracts=numAssignedToMeAuctionItemExchange + numAssignedToMeCourier)
    107             subText = ''
    108             subTextList = []
    109             if numAssignedToMeAuctionItemExchange > 0:
    110                 auctionLabel = GetByLabel('UI/Contracts/ContractsService/AuctionItemExchange', numContracts=numAssignedToMeAuctionItemExchange)
    111                 method = self._GetContractMethodText(CONTYPE_AUCTIONANDITEMECHANGE, isCorp=0)
    112                 subText += self._GetContractLink(auctionLabel, method)
    113             if numAssignedToMeCourier > 0:
    114                 assignedCourierLabel = GetByLabel('UI/Contracts/ContractsService/AssignedCourier', numContracts=numAssignedToMeCourier)
    115                 method = self._GetContractMethodText(appConst.conTypeCourier, isCorp=0)
    116                 subText += self._GetContractLink(assignedCourierLabel, method, numSpaces=2)
    117             self.AddItem('res:/ui/Texture/WindowIcons/info.png', assignedLabel, subText)
    118         if numAssignedToMyCorpAuctionItemExchange > 0 or numAssignedToMyCorpCourier > 0:
    119             numContracts = numAssignedToMyCorpAuctionItemExchange + numAssignedToMyCorpCourier
    120             corpAssignedLabel = GetByLabel('UI/Contracts/ContractsService/AssignedCorp', numContracts=numContracts)
    121             subText = ''
    122             if numAssignedToMyCorpAuctionItemExchange > 0:
    123                 corpExchangeLabel = GetByLabel('UI/Contracts/ContractsService/AssignedCorpAuctionItemExchange', numContracts=numAssignedToMyCorpAuctionItemExchange)
    124                 method = self._GetContractMethodText(CONTYPE_AUCTIONANDITEMECHANGE, isCorp=1)
    125                 subText += self._GetContractLink(corpExchangeLabel, method)
    126             if numAssignedToMyCorpCourier > 0:
    127                 corpCourierLabel = GetByLabel('UI/Contracts/ContractsService/AssignedCorpCourier', numContracts=numAssignedToMyCorpCourier)
    128                 method = self._GetContractMethodText(appConst.conTypeCourier, isCorp=1)
    129                 subText += self._GetContractLink(corpCourierLabel, method)
    130             self.AddItem('res:/ui/Texture/WindowIcons/info.png', corpAssignedLabel, subText)
    131         if mpi.numBiddingOn > 0:
    132             activeLabel = GetByLabel('UI/Contracts/ContractsService/BiddingOn', numAuctions=mpi.numBiddingOn)
    133             activeDescLabel = GetByLabel('UI/Contracts/ContractsService/BiddingOnDesc')
    134             self.AddItem('64_16', evelink.local_service_link('ShowContracts', activeLabel, status=10, forCorp=0), activeDescLabel)
    135         if mpi.numInProgress > 0:
    136             progressLabel = GetByLabel('UI/Contracts/ContractsService/InProgress', numContracts=mpi.numInProgress)
    137             progressDescLabel = GetByLabel('UI/Contracts/ContractsService/InProgressDesc')
    138             self.AddItem('res:/ui/Texture/WindowIcons/info.png', evelink.local_service_link('ShowContracts', progressLabel, status=1, forCorp=0), progressDescLabel)
    139         if mpi.numBiddingOnCorp > 0:
    140             biddingOnLabel = GetByLabel('UI/Contracts/ContractsService/BiddingOnCorp', numAuctions=mpi.numBiddingOnCorp)
    141             biddingOnDescLabel = GetByLabel('UI/Contracts/ContractsService/BiddingOnCorpDesc')
    142             self.AddItem('64_16', evelink.local_service_link('ShowContracts', biddingOnLabel, status=10, forCorp=1), biddingOnDescLabel)
    143         if mpi.numInProgressCorp > 0:
    144             inProgressCorpLabel = GetByLabel('UI/Contracts/ContractsService/InProgressCorp', numContracts=mpi.numInProgressCorp)
    145             inProgressCorpDescLabel = GetByLabel('UI/Contracts/ContractsService/InProgressCorpDesc')
    146             self.AddItem('res:/ui/Texture/WindowIcons/info.png', evelink.local_service_link('ShowContracts', inProgressCorpLabel, status=1, forCorp=1), inProgressCorpDescLabel)
    147         ignoreList = settings.user.ui.Get('contracts_ignorelist', [])
    148         l = len(ignoreList)
    149         if l > 0:
    150             ignoreLabel = GetByLabel('UI/Contracts/ContractsService/Ignoring', numIssuers=l)
    151             ignoreDescLabel = GetByLabel('UI/Contracts/ContractsService/IngoringDesc', numIssuers=MAX_IGNORED)
    152             self.AddItem('ui_38_16_208', evelink.local_service_link('OpenIgnoreList', ignoreLabel), ignoreDescLabel, isSmall=True)
    153         mess = sm.GetService('contracts').GetMessages()
    154         for i in mess:
    155             self.AddItem('ui_38_16_208', '', i, isSmall=True)
    156 
    157     def _GetContractMethodText(self, contractType, isCorp):
    158         methodTextCorp = 'method=OpenAssignedToMe&contractType=%s&isCorp=%s' % (contractType, isCorp)
    159         return methodTextCorp
    160 
    161     def _GetContractLink(self, label, method, numSpaces = 1):
    162         link = ' ' * numSpaces
    163         link += '- <a href="localsvc:%s">%s</a><br>' % (method, label)
    164         return link
    165 
    166     def OnContractCacheCleared(self, *args):
    167         if self.display:
    168             self.Init()
    169 
    170 
    171 class MyContractsPanel(Container):
    172     __guid__ = 'xtriui.MyContractsPanel'
    173     inited = 0
    174     submitFunc = None
    175 
    176     def _OnClose(self):
    177         Container._OnClose(self)
    178         if self.inited:
    179             settings.user.ui.Set('mycontracts_filter_tofrom', self.GetIssuedByToFilterValue())
    180             settings.char.ui.Set('mycontracts_filter_owner', self.GetOwnerFilterValue())
    181             settings.user.ui.Set('mycontracts_filter_status', self.fltStatus.GetValue())
    182             settings.user.ui.Set('mycontracts_filter_type', self.GetContractTypeFilterValue())
    183 
    184     def GetOwnerFilterValue(self):
    185         return self.fltOwner.GetValue()
    186 
    187     def Init(self):
    188         if not self.inited:
    189             self.ConstructFilters()
    190             self.contractlistParent = contractlistParent = Container(name='contractlistParent', align=uiconst.TOALL, pos=(uiconst.defaultPadding,
    191              uiconst.defaultPadding,
    192              uiconst.defaultPadding,
    193              uiconst.defaultPadding), parent=self)
    194             self.contractlist = contractlist = Scroll(parent=contractlistParent, name='mycontractlist')
    195             contractlist.sr.id = 'mycontractlist'
    196             contractlist.ShowHint(GetByLabel('UI/Contracts/ContractsWindow/ClickGetContracts'))
    197             contractlistParent.top = 5
    198             self.currPage = 0
    199             self.pages = {0: None}
    200             self.fetchingContracts = 0
    201             self.buttonGroup = ButtonGroup(parent=self, idx=0)
    202             self.buttonGroup.AddButton(GetByLabel('UI/Inventory/ItemActions/CreateContract'), lambda x: sm.GetService('contracts').OpenCreateContract())
    203         self.inited = 1
    204         self.FetchContracts()
    205 
    206     def ConstructFilters(self):
    207         PAD = 5
    208         self.filters = filters = Container(name='filters', parent=self, height=24, padTop=16, align=uiconst.TOTOP)
    209         self.comboGridContainer = comboGridContainer = GridContainer(name='comboContainer', parent=filters, align=uiconst.TOLEFT_PROP, width=0.73, maxWidth=600, contentSpacing=(PAD, 0), columns=4)
    210         options = [(GetByLabel('UI/Common/All'), None),
    211          (GetByLabel('UI/Contracts/Auction'), appConst.conTypeAuction),
    212          (GetByLabel('UI/Contracts/ContractsWindow/ItemExchange'), appConst.conTypeItemExchange),
    213          (GetByLabel('UI/Contracts/ContractsWindow/Courier'), appConst.conTypeCourier)]
    214         self.fltType = Combo(name='contractTypeCombo', label=GetByLabel('UI/Contracts/ContractsWindow/ContractType'), parent=comboGridContainer, align=uiconst.TOALL, options=options, select=settings.user.ui.Get('mycontracts_filter_type', None), callback=self.OnComboChange)
    215         options = [(GetByLabel('UI/Contracts/ContractsWindow/IssuedToBy'), None), (GetByLabel('UI/Contracts/ContractsWindow/IssuedBy'), False), (GetByLabel('UI/Contracts/ContractsWindow/IssuedTo'), True)]
    216         self.fltToFrom = Combo(name='issuedByToCombo', label=GetByLabel('UI/Contracts/ContractsWindow/Action'), parent=comboGridContainer, align=uiconst.TOALL, options=options, select=settings.user.ui.Get('mycontracts_filter_tofrom', None), callback=self.OnComboChange, adjustWidth=True)
    217         corpName = cfg.eveowners.Get(session.corpid).name
    218         charName = cfg.eveowners.Get(session.charid).name
    219         val = getattr(self, 'lookup', None)
    220         if not val:
    221             val = settings.char.ui.Get('mycontracts_filter_owner', charName)
    222         self.fltOwner = SingleLineEditText(name='ownerCombo', parent=comboGridContainer, align=uiconst.TOALL, label=GetByLabel('UI/Contracts/ContractsWindow/Owner'), setvalue=val)
    223         ops = [(charName, charName), (corpName, corpName)]
    224         self.fltOwner.LoadCombo('usernamecombo', ops, self.OnComboChange)
    225         options = [(GetByLabel('UI/Contracts/ContractEntry/Outstanding'), appConst.conStatusOutstanding),
    226          (GetByLabel('UI/Contracts/ContractsWindow/InProgress'), appConst.conStatusInProgress),
    227          (GetByLabel('UI/Contracts/ContractsWindow/Finished'), appConst.conStatusFinished),
    228          (GetByLabel('UI/Journal/JournalWindow/Contracts/RequiresAttentionFilter'), appConst.conStatusRequiresAttention),
    229          (GetByLabel('UI/Journal/JournalWindow/Contracts/BidOnByFilter'), appConst.conStatusBidOnBy)]
    230         self.fltStatus = Combo(name='statusCombo', label=GetByLabel('UI/Contracts/ContractsWindow/Status'), parent=comboGridContainer, align=uiconst.TOALL, options=options, select=settings.user.ui.Get('mycontracts_filter_status', None), callback=self.OnComboChange)
    231         self.submitBtn = Button(parent=filters, label=GetByLabel('UI/Contracts/ContractsWindow/GetContracts'), func=self.FetchContracts, align=uiconst.TORIGHT, padRight=PAD)
    232         self.transMyFwdBtn = ButtonIcon(name='transMyFwdBtn', parent=filters, align=uiconst.TORIGHT, width=filters.height, texturePath=eveicon.caret_right, iconSize=16, hint=GetByLabel('UI/Common/ViewMore'), func=self.BrowseNextPage, padRight=4)
    233         self.transMyBackBtn = ButtonIcon(name='transMyBackBtn', parent=filters, align=uiconst.TORIGHT, width=filters.height, texturePath=eveicon.caret_left, iconSize=16, hint=GetByLabel('UI/Common/Previous'), func=self.BrowsePreviousPage)
    234 
    235     def BrowseNextPage(self):
    236         return self.BrowseMyContracts(1)
    237 
    238     def BrowsePreviousPage(self):
    239         return self.BrowseMyContracts(-1)
    240 
    241     def BrowseMyContracts(self, direction, *args):
    242         self.currPage = max(0, self.currPage + direction)
    243         self.DoFetchContracts()
    244 
    245     def FetchContracts(self, *args):
    246         if self.fetchingContracts:
    247             return
    248         self.submitBtn.Disable()
    249         self.fetchingContracts = 1
    250         uthread.new(self.EnableButtonTimer)
    251         self.currPage = 0
    252         self.pages = {0: None}
    253         self.DoFetchContracts()
    254 
    255     def EnableButtonTimer(self):
    256         blue.pyos.synchro.SleepWallclock(3000)
    257         try:
    258             self.fetchingContracts = 0
    259             self.submitBtn.Enable()
    260         except:
    261             pass
    262 
    263     def DoFetchContracts(self):
    264         self.contractlist.Load(contentList=[])
    265         self.contractlist.ShowHint(GetByLabel('UI/Contracts/ContractsWindow/FetchingData'))
    266         try:
    267             if self.currPage == 0:
    268                 self.transMyBackBtn.Disable()
    269             else:
    270                 self.transMyBackBtn.Enable()
    271             ownerID = self.GetOwnerID()
    272             if ownerID is None:
    273                 return
    274             contracts, itemsByContractID = self._GetContractsToShow(ownerID)
    275             forCorp = ownerID == session.corpid
    276             self.PrimeOwnerIDs(contracts)
    277             scrolllist = []
    278             for contract in contracts:
    279                 contractItems = itemsByContractID.get(contract.contractID, [])
    280                 entry = self._GetListEntry(contract, contractItems, forCorp)
    281                 scrolllist.append(entry)
    282 
    283             self.contractlist.ShowHint()
    284             self.contractlist.Load(contentList=scrolllist, headers=self._GetScrollHeaders())
    285             if len(scrolllist) == 0:
    286                 self.contractlist.ShowHint(GetByLabel('UI/Contracts/ContractEntry/NoContractsFound'))
    287             self.UpdatePagination(contracts, scrolllist)
    288         except UserError:
    289             self.contractlist.ShowHint(GetByLabel('UI/Contracts/ContractEntry/NoContractsFound'))
    290             raise
    291 
    292     def PrimeOwnerIDs(self, contracts):
    293         ownerIDs = set()
    294         for contract in contracts:
    295             ownerIDs.add(contract.issuerID)
    296             ownerIDs.add(contract.issuerCorpID)
    297             ownerIDs.add(contract.acceptorID)
    298             ownerIDs.add(contract.assigneeID)
    299 
    300         if 0 in ownerIDs:
    301             ownerIDs.remove(0)
    302         cfg.eveowners.Prime(ownerIDs)
    303 
    304     def UpdatePagination(self, contracts, scrolllist):
    305         if len(contracts) >= 2:
    306             self.pages[self.currPage] = contracts[0].contractID
    307             self.pages[self.currPage + 1] = contracts[-1].contractID
    308         if len(scrolllist) < RESULTS_PER_PAGE or self.GetStatusFilterValue() == appConst.conStatusRequiresAttention:
    309             self.transMyFwdBtn.Disable()
    310         else:
    311             self.transMyFwdBtn.Enable()
    312 
    313     def _GetScrollHeaders(self):
    314         filtStatus = self.GetStatusFilterValue()
    315         headers = [GetByLabel('UI/Common/Contract'),
    316          GetByLabel('UI/Common/Type'),
    317          GetByLabel('UI/Common/From'),
    318          GetByLabel('UI/Common/To')]
    319         if filtStatus == appConst.conStatusOutstanding:
    320             headers.extend([GetByLabel('UI/Contracts/ContractsWindow/DateIssued'), GetByLabel('UI/Contracts/ContractsWindow/TimeLeft')])
    321         elif filtStatus == appConst.conStatusInProgress:
    322             headers.extend([GetByLabel('UI/Contracts/ContractsWindow/DateAccepted'), GetByLabel('UI/Contracts/ContractsWindow/TimeLeft')])
    323         elif filtStatus == appConst.conStatusRequiresAttention:
    324             headers.extend([GetByLabel('UI/Contracts/ContractsWindow/Status'), GetByLabel('UI/Contracts/ContractsWindow/TimeLeft')])
    325         else:
    326             headers.extend([GetByLabel('UI/Contracts/ContractsWindow/Status'), GetByLabel('UI/Contracts/ContractsWindow/DateCompleted')])
    327         headers.append(GetByLabel('UI/Contracts/ContractsWindow/InfoByIssuer'))
    328         return headers
    329 
    330     def _GetListEntry(self, contract, contractItems, forCorp):
    331         timeLeftValue = 0
    332         filtStatus = self.GetStatusFilterValue()
    333         if filtStatus == appConst.conStatusOutstanding:
    334             issued = {False: FmtDate(contract.dateIssued, 'ss'),
    335              True: '-'}[contract.type == appConst.conTypeAuction and contract.issuerID != session.charid]
    336             timeLeftValue = contract.dateExpired - blue.os.GetWallclockTime()
    337             additionalColumns = '<t>%s<t>%s' % (issued, ConFmtDate(timeLeftValue, contract.type == appConst.conTypeAuction))
    338         elif filtStatus == appConst.conStatusInProgress:
    339             timeLeftValue = contract.dateAccepted + appConst.DAY * contract.numDays - blue.os.GetWallclockTime()
    340             additionalColumns = '<t>%s<t>%s' % (FmtDate(contract.dateAccepted, 'ss'), ConFmtDate(timeLeftValue, contract.type == appConst.conTypeAuction))
    341         elif filtStatus == appConst.conStatusRequiresAttention:
    342             if contract.acceptorID == session.charid:
    343                 timeLeftText = GetByLabel('UI/Journal/JournalWindow/Contracts/Overdue')
    344             else:
    345                 timeLeftValue = contract.dateExpired - blue.os.GetWallclockTime()
    346                 if contract.type == appConst.conTypeAuction and timeLeftValue > 0:
    347                     timeLeftText = ConFmtDate(timeLeftValue, True)
    348                 else:
    349                     timeLeftText = GetByLabel('UI/Contracts/Util/ContractExpired')
    350             statusText = GetColoredContractStatusText(contract.status)
    351             additionalColumns = '<t>%s<t><color=red>%s</color>' % (statusText, timeLeftText)
    352         else:
    353             additionalColumns = '<t>%s<t>%s' % (GetColoredContractStatusText(contract.status), FmtDate(contract.dateCompleted, 'ss'))
    354         additionalColumns += '<t>%s' % contract.title
    355         text = GetContractLabel(contract, contractItems, additionalColumns)
    356         return GetFromClass(ContractEntrySmall, {'contract': contract,
    357          'contractItems': contractItems,
    358          'status': filtStatus,
    359          'text': text,
    360          'label': text,
    361          'additionalColumns': additionalColumns,
    362          'callback': self.OnSelectContract,
    363          'forCorp': forCorp,
    364          'sort_%s' % GetByLabel('UI/Common/Contract'): text,
    365          'sort_%s' % GetByLabel('UI/Contracts/ContractsWindow/DateCompleted'): -contract.dateCompleted,
    366          'sort_%s' % GetByLabel('UI/Contracts/ContractsWindow/TimeLeft'): timeLeftValue})
    367 
    368     def _GetContractsToShow(self, ownerID):
    369         issuedBy = self.GetIssuedByToFilterValue()
    370         filtStatus = self.GetStatusFilterValue()
    371         contractType = self.GetContractTypeFilterValue()
    372         startContractID = self.pages.get(self.currPage, None)
    373         if filtStatus == appConst.conStatusRequiresAttention:
    374             _contracts = self._GetRequireAttentionContractsToShow(ownerID)
    375         elif filtStatus == appConst.conStatusBidOnBy:
    376             forCorp = ownerID == session.corpid
    377             _contracts = sm.GetService('contracts').GetMyBids(forCorp).list
    378         else:
    379             _contracts = sm.ProxySvc('contractProxy').GetContractListForOwner(ownerID, filtStatus, contractType, issuedBy, num=RESULTS_PER_PAGE, startContractID=startContractID)
    380         return (_contracts.contracts, _contracts.items)
    381 
    382     def _GetRequireAttentionContractsToShow(self, ownerID):
    383         _contracts = sm.GetService('contracts').GetMyExpiredContractList()
    384         if ownerID == session.charid:
    385             _contracts = _contracts.mySelf
    386         else:
    387             _contracts = _contracts.myCorp
    388         return _contracts
    389 
    390     def GetIssuedByToFilterValue(self):
    391         return self.fltToFrom.GetValue()
    392 
    393     def GetContractTypeFilterValue(self):
    394         return self.fltType.GetValue()
    395 
    396     def GetStatusFilterValue(self):
    397         return int(self.fltStatus.GetValue())
    398 
    399     def GetOwnerID(self):
    400         ownerName = self.GetOwnerFilterValue()
    401         if ownerName == cfg.eveowners.Get(session.charid).name:
    402             return session.charid
    403         elif ownerName == cfg.eveowners.Get(session.corpid).name:
    404             return session.corpid
    405         elif IsSearchStringLongEnough(ownerName):
    406             return searchOld.Search(ownerName.lower(), None, appConst.categoryOwner, hideNPC=1, exact=1, searchWndName='contractOwnerNameSearch')
    407         else:
    408             return None
    409 
    410     def OnComboChange(self, obj, *args):
    411         if obj == self.fltType and self.GetContractTypeFilterValue() == -1:
    412             self.fltType.SetValue(None)
    413 
    414     def OnSelectContract(self, *args):
    415         pass
    416 
    417     def ShowOwner(self, ownerName):
    418         self._SetFiltersAndFetch(ownerName, appConst.conStatusFinished)
    419 
    420     def ShowRequireAttention(self, status):
    421         ownerName = cfg.eveowners.Get(session.charid).name
    422         self._SetFiltersAndFetch(ownerName, status)
    423 
    424     def ShowRequireAttentionMyCorp(self, status):
    425         ownerName = cfg.eveowners.Get(session.corpid).name
    426         self._SetFiltersAndFetch(ownerName, status)
    427 
    428     def _SetFiltersAndFetch(self, ownerName, status = None, toFrom = None, contractType = None):
    429         self.fltToFrom.SetValue(toFrom)
    430         self.fltOwner.SetValue(ownerName)
    431         self.fltStatus.SelectItemByValue(status)
    432         self.fltType.SelectItemByValue(contractType)
    433         self.FetchContracts()