# coding: utf-8
'''
Created on 9.12.2013

@author: i.lopatin

'''
import json

from common._common_orm import linesOfNumbersSeriesCursor
from common._common_orm import numbersSeriesCursor
from common.numbersseries import getNextNo
from ru.curs.celesta.showcase.utils import XMLJSONConverter
from author._author_orm import serviceCatalogCursor
from java.text import SimpleDateFormat
from java.util import Date

try:
    from ru.curs.showcase.core.jython import JythonDTO
    from ru.curs.showcase.core.selector import ResultSelectorData
    from ru.beta2.extra.gwt.ui.selector.api import DataRecord
except:
    from ru.curs.celesta.showcase import JythonDTO, DataRecord, ResultSelectorData

def cardData(context, main=None, add=None, filterinfo=None, session=None, elementId=None):
    u'''Процедура для отрисовки данных карточки. '''
    
    service = serviceCatalogCursor(context)

    u"""Данные для полей на карточке"""    
    xformsdata = {"schema":{"catalogData": {"@add":add,
                                            "@show": "1",
                                            "@testSystemAddress": "",
                                            "@link": "",
                                           }
                            }
                  }
    
    xformssettings = {"properties":{"event":{"@name":"single_click",
                                             "@linkId": "1",
                                             "action":{
                                                  "#sorted": [
                                                      {"main_context": "current"},
                                                      {"datapanel": {"@type": "current",
                                                                     "@tab": "current",
                                                                     "element": {"@id":"webServiceCatalogGrid",
                                                                                 "add_context": ""}
                                                                     }
                                                      }]}
                                             },
                                    
                                    }
                      }
    
    return JythonDTO(XMLJSONConverter.jsonToXml(json.dumps(xformsdata)),
                     XMLJSONConverter.jsonToXml(json.dumps(xformssettings))
                     )


