<?xml version="1.0"?>
<ZopeData>
  <record id="1" aka="AAAAAAAAAAE=">
    <pickle>
      <tuple>
        <global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
        <tuple/>
      </tuple>
    </pickle>
    <pickle>
      <dictionary>
        <item>
            <key> <string>Script_magic</string> </key>
            <value> <int>3</int> </value>
        </item>
        <item>
            <key> <string>_bind_names</string> </key>
            <value>
              <object>
                <klass>
                  <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
                </klass>
                <tuple/>
                <state>
                  <dictionary>
                    <item>
                        <key> <string>_asgns</string> </key>
                        <value>
                          <dictionary>
                            <item>
                                <key> <string>name_container</string> </key>
                                <value> <string>container</string> </value>
                            </item>
                            <item>
                                <key> <string>name_context</string> </key>
                                <value> <string>context</string> </value>
                            </item>
                            <item>
                                <key> <string>name_m_self</string> </key>
                                <value> <string>script</string> </value>
                            </item>
                            <item>
                                <key> <string>name_subpath</string> </key>
                                <value> <string>traverse_subpath</string> </value>
                            </item>
                          </dictionary>
                        </value>
                    </item>
                  </dictionary>
                </state>
              </object>
            </value>
        </item>
        <item>
            <key> <string>_body</string> </key>
            <value> <string>listbox = []\n
result_dict = {}\n
portal_workflow = context.portal_workflow\n
content_type_list = context.allowedContentTypes()\n
content_type_list.sort()\n
\n
translateString = context.Base_translateString\n
\n
# XXX better implementation is required, but I do not know how to get workflows related to a portal type\n
possible_state_name_list = (\'validation_state\',\n
                            \'simulation_state\',\n
                            \'causality_state\',\n
                            \'invoice_state\',\n
                            \'payment_state\',\n
                            \'event_state\',\n
                            \'opportunity_state\',\n
                            \'immobilisation_state\',)\n
\n
for content_type in content_type_list:\n
  content_type_id = content_type.id\n
  for state_name in possible_state_name_list:\n
    result_list = context.Base_zCountByWorkflowState(portal_type=content_type_id,\n
                                                     state_name=state_name)\n
    if not ((len(result_list) == 1) and (result_list[0][0] is None)):\n
      for result in result_list:\n
        portal_type_dict = result_dict.get(content_type_id, {})\n
        count = portal_type_dict.get(result[0], 0) + result[1]\n
        portal_type_dict.update({result[0]: count})\n
        result_dict.update({content_type_id: portal_type_dict})\n
\n
\n
def getStateTranslatedTitle(state, portal_type, saved_state_dict=dict()):\n
  if state in saved_state_dict:\n
    return saved_state_dict[state]\n
  # XXX requires manager proxy role\n
  workflow_for_ptype = portal_workflow.getWorkflowsFor(portal_type)\n
  for workflow in workflow_for_ptype:\n
    if getattr(workflow, \'states\', None) is not None and state in workflow.states.objectIds():\n
      saved_state_dict[state] = translateString(getattr(workflow.states, state).title_or_id())\n
      return saved_state_dict[state]\n
\n
state_list_dict = {}\n
portal_type_list = result_dict.keys()\n
portal_type_list.sort()\n
for portal_type in portal_type_list:\n
  listbox.append({\'translated_portal_type\': translateString(portal_type),\n
                  \'state\'      : \'\',\n
                  \'count\'      : \'\'})\n
  state_list = result_dict[portal_type].keys()\n
  state_list.sort()\n
  for state in state_list:\n
    state_title = getStateTranslatedTitle(state, portal_type)\n
    count = state_list_dict.get(state, 0) + result_dict[portal_type][state]\n
    state_list_dict.update({state:count})\n
    listbox.append({\'translated_portal_type\': \'\',\n
                    \'state\'      : state_title,\n
                    \'count\'      : result_dict[portal_type][state]})\n
\n
listbox.append({\'translated_portal_type\': translateString(\'All\'),\n
                \'state\'      : \'\',\n
                \'count\'      : \'\'})\n
state_list = state_list_dict.keys()\n
state_list.sort()\n
for state in state_list:\n
  listbox.append({\'translated_portal_type\': \'\',\n
                  \'state\'      : getStateTranslatedTitle(state, None),\n
                  \'count\'      : state_list_dict[state]})\n
\n
context.Base_updateDialogForm(listbox=listbox, empty_line_number=0)\n
return context.Folder_viewWorkflowReport()\n
</string> </value>
        </item>
        <item>
            <key> <string>_code</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>_params</string> </key>
            <value> <string></string> </value>
        </item>
        <item>
            <key> <string>_proxy_roles</string> </key>
            <value>
              <tuple>
                <string>Manager</string>
              </tuple>
            </value>
        </item>
        <item>
            <key> <string>errors</string> </key>
            <value>
              <tuple/>
            </value>
        </item>
        <item>
            <key> <string>func_code</string> </key>
            <value>
              <object>
                <klass>
                  <global name="FuncCode" module="Shared.DC.Scripts.Signature"/>
                </klass>
                <tuple/>
                <state>
                  <dictionary>
                    <item>
                        <key> <string>co_argcount</string> </key>
                        <value> <int>0</int> </value>
                    </item>
                    <item>
                        <key> <string>co_varnames</string> </key>
                        <value>
                          <tuple>
                            <string>listbox</string>
                            <string>result_dict</string>
                            <string>_getattr_</string>
                            <string>context</string>
                            <string>portal_workflow</string>
                            <string>content_type_list</string>
                            <string>translateString</string>
                            <string>possible_state_name_list</string>
                            <string>_getiter_</string>
                            <string>content_type</string>
                            <string>content_type_id</string>
                            <string>state_name</string>
                            <string>result_list</string>
                            <string>len</string>
                            <string>_getitem_</string>
                            <string>None</string>
                            <string>result</string>
                            <string>portal_type_dict</string>
                            <string>count</string>
                            <string>dict</string>
                            <string>getStateTranslatedTitle</string>
                            <string>state_list_dict</string>
                            <string>portal_type_list</string>
                            <string>portal_type</string>
                            <string>state_list</string>
                            <string>state</string>
                            <string>state_title</string>
                          </tuple>
                        </value>
                    </item>
                  </dictionary>
                </state>
              </object>
            </value>
        </item>
        <item>
            <key> <string>func_defaults</string> </key>
            <value>
              <none/>
            </value>
        </item>
        <item>
            <key> <string>id</string> </key>
            <value> <string>Folder_generateWorkflowReport</string> </value>
        </item>
        <item>
            <key> <string>warnings</string> </key>
            <value>
              <tuple/>
            </value>
        </item>
      </dictionary>
    </pickle>
  </record>
</ZopeData>
