Permalink
Browse files

RMSAmericas: expose ID cards in HR rheader; import-option for card

configs; tweaks
  • Loading branch information...
nursix committed Sep 21, 2018
1 parent ab5280e commit 40c82c31c6e95de922e001302f28f3ddd831e529
@@ -1 +1 @@
nursix-dev-2399-g03e19f3 (2018-09-21 16:18:53)
nursix-dev-2400-gab5280e (2018-09-22 01:33:39)
@@ -311,4 +311,9 @@ def ck_delete():
filepath = os.path.join(request.folder, "uploads", filename)
os.unlink(filepath)
# -----------------------------------------------------------------------------
def card_config():
return s3_rest_controller()
# END =========================================================================
@@ -991,6 +991,7 @@
'Blizzard': 'Ventisca',
'Blood Banking': 'Almacenamiento de la Sangre',
'Blood Donor Recruitment': 'Reclutamiento de Donante de Sangre ',
'Blood Type': 'Tipo de Sangre',
'Blood Type (AB0)': 'Tipo de sangre (AB0)',
'Blowing Snow': 'Nieve y viento',
'Boat': 'Bote',
@@ -2655,6 +2656,7 @@
'Expiration Details': 'Detalles de Caducidad',
'Expiration Report': 'Informe de Caducidad',
'Expired': 'Expirado',
'Expires on': 'Expira',
'Expiring Staff Contracts Report': 'Caducidad Personal Contratos Reportar',
'Expiry (months)': 'Caducidad (meses)',
'Expiry Date': 'Fecha de Caducidad',
@@ -3433,6 +3435,7 @@
'Is there any industrial or agro-chemical production close to the affected area/village?': '¿Existe algun área de producción agro-quimico o industrial cerca al pueblo/area afectada?',
'Is this a strict hierarchy?': '¿Se trata de una jerarquía estricta?',
'Issuing Authority': 'Autoridad expedidora',
'Issued on': 'Expedido',
'It captures not only the places where they are active, but also captures information on the range of projects they are providing in each area.': 'No sólo captura los lugares donde que están activos, sino que también captura información sobre el rango de los proyectos que están proporcionando en cada área.',
'It gives four options: No Sync, Newer Timestamp, Keep All, Replace All': 'Da cuatro opciones: "no sincronizar", "nueva marca de hora", "mantener todo", "remplazar todo"',
'It is built using the Template agreed by a group of NGOs working together as the': 'Es construido usando ela Plantilla acordada por un grupo de ONGs trabajando conjuntamente como el',
@@ -3615,6 +3615,12 @@ def get_hrm_event_types(self):
"""
return self.__lazy("hrm", "event_types", default=False)
def get_hrm_id_cards(self):
"""
Show buttons to download printable ID cards for staff/volunteers
"""
return self.__lazy("hrm", "id_cards", default=False)
def get_hrm_job_title_deploy(self):
"""
Whether the 'deploy' Job Title type should be used
@@ -792,7 +792,6 @@ def model(self):
# Card Types
#
card_types = {"VOLID": T("Volunteer ID Card"),
"OTHER": T("Other Card"),
}
# ---------------------------------------------------------------------
@@ -849,6 +848,12 @@ def model(self):
s3_comments(),
*s3_meta_fields())
# Table configuration
self.configure(tablename,
deduplicate = S3Duplicate(primary=("organisation_id", "card_type"),
),
)
# CRUD Strings
crud_strings[tablename] = Storage(
label_create = T("Create Card Configuration"),
@@ -6504,24 +6504,33 @@ def hrm_rheader(r, tabs=None, profile=False):
row3,
row4,
)
service_record = DIV(A(T("Service Record"),
_href = URL(c = "vol",
f = "human_resource",
args = [hr, "form"]
),
_id = "service_record",
_class = "action-btn"
),
# @ToDo: Move to CSS
_style="margin-bottom:10px"
)
service_record = A(T("Service Record"),
_href = URL(c = "vol",
f = "human_resource",
args = [hr, "form"]
),
_id = "service_record",
_class = "action-btn"
)
if vol_experience == "both" and not use_cv:
experience_tab2 = (T("Experience"), "experience")
elif vol_experience == "experience" and not use_cv:
experience_tab = (T("Experience"), "experience")
elif settings.get_hrm_staff_experience() == "experience" and not use_cv:
experience_tab = (T("Experience"), "experience")
if settings.get_hrm_id_cards():
card_button = A(T("ID Card"),
data = {"url": URL(f = "human_resource",
args = ["%s.card" % hr]
),
},
_class = "action-btn s3-download-button",
_script = "alert('here')",
)
else:
card_button = ""
if settings.get_hrm_use_certificates() and not use_cv:
certificates_tab = (T("Certificates"), "certification")
else:
@@ -6724,7 +6733,12 @@ def hrm_rheader(r, tabs=None, profile=False):
if user_id:
tabs.append((T("Roles"), "roles"))
rheader_tabs = s3_rheader_tabs(r, tabs)
rheader = DIV(service_record,
rheader_btns = DIV(service_record, card_button,
# @ToDo: Move to CSS
_style="margin-bottom:10px",
_class="rheader-btns",
)
rheader = DIV(rheader_btns,
A(s3_avatar_represent(record_id,
"pr_person",
_class="rheader-avatar"),
@@ -3532,6 +3532,10 @@ def custom_prep(r):
s3.jquery_ready.append('''S3.showHidden('%s',%s,'%s')''' % \
("allergic", json.dumps(["allergies"], separators=SEPARATORS), "pr_physical_description"))
if not EXTERNAL:
# TODO limit this function to certain user roles
settings.hrm.id_cards = True
return True
s3.prep = custom_prep
@@ -0,0 +1,2 @@
Organisation,Card Type,Authority Statement,Organisation Statement,Signature Text,Validity Period,Comments
Red Cross Society of Panama,VOLID,"La Cruz Roja agradece a las autoridades y público en general, la cooperación que le brinden al portador en el ejercicio de sus funciones.",Miembro del Movimento Internacional de la Cruz Roja y La Media Luna Roja,,24,
@@ -297,7 +297,7 @@ def draw(self):
path = os.path.join(current.request.folder, 'uploads')
self.draw_image(os.path.join(path, signature),
CENTER,
MIDDLE - 15,
MIDDLE - 25,
height = 40,
width = 60,
valign = "middle",
@@ -308,7 +308,7 @@ def draw(self):
signature_text = config.get("signature_text")
if signature_text:
draw_value(CENTER,
MIDDLE - (45 if signature else 25),
MIDDLE - (50 if signature else 25),
signature_text,
height = 20,
size = 5,
@@ -0,0 +1 @@
Organisation,Branch,Card Type,Authority Statement,Organization Statement,Signature Text,Validity Period,Comments
@@ -0,0 +1,218 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<!-- **********************************************************************
PDF Data Card Configurations - CSV Import Stylesheet
CSV column..................Format..........Content
Organisation................string..........Organisation Name
Branch.........................optional.....Organisation Branch Name
...SubBranch,SubSubBranch...etc (indefinite depth, must specify all from root)
Card Type...................string..........Card Type [VOLID|...]
Authority Statement.........string..........Card Authority Statement
Organisation Statement......string..........Org/Affiliation Statement
Signature Text..............string..........Card Signature Text
Validity Period.............integer.........Validity Period in Months
Comments....................string..........Comments
*********************************************************************** -->
<xsl:output method="xml"/>
<!-- ****************************************************************** -->
<xsl:template match="/">
<s3xml>
<!-- Import the organisation hierarchy -->
<xsl:for-each select="table/row[1]">
<xsl:call-template name="OrganisationHierarchy">
<xsl:with-param name="level">Organisation</xsl:with-param>
<xsl:with-param name="rows" select="//table/row"/>
</xsl:call-template>
</xsl:for-each>
<!-- Process all rows for response themes -->
<xsl:apply-templates select="table/row"/>
</s3xml>
</xsl:template>
<!-- ****************************************************************** -->
<!-- Card Configurations -->
<xsl:template match="row">
<xsl:variable name="Type" select="col[@field='Card Type']/text()"/>
<xsl:if test="$Type!=''">
<resource name="doc_card_config">
<!-- Type -->
<data field="card_type">
<xsl:value-of select="$Type"/>
</data>
<!-- Link to Organisation -->
<reference field="organisation_id" resource="org_organisation">
<xsl:attribute name="tuid">
<xsl:call-template name="OrganisationID"/>
</xsl:attribute>
</reference>
<!-- Card Texts -->
<data field="authority_statement">
<xsl:value-of select="col[@field='Authority Statement']/text()"/>
</data>
<data field="org_statement">
<xsl:value-of select="col[@field='Organisation Statement']/text()"/>
</data>
<data field="signature_text">
<xsl:value-of select="col[@field='Signature Text']/text()"/>
</data>
<!-- Validity Period -->
<data field="validity_period">
<xsl:value-of select="col[@field='Validity Period']/text()"/>
</data>
<!-- Comments -->
<data field="comments">
<xsl:value-of select="col[@field='comments']"/>
</data>
</resource>
</xsl:if>
</xsl:template>
<!-- ****************************************************************** -->
<!-- Template to import the organisation hierarchy, to be called only once for the first row -->
<xsl:template name="OrganisationHierarchy">
<xsl:param name="level"/>
<xsl:param name="rows"/>
<xsl:param name="parentID"/>
<!-- Get the next level -->
<xsl:variable name="nextLevel">
<xsl:call-template name="NextLevel">
<xsl:with-param name="level" select="$level"/>
</xsl:call-template>
</xsl:variable>
<!-- Get the name -->
<xsl:variable name="name" select="col[@field=$level]/text()"/>
<!-- Generate the tuid -->
<xsl:variable name="tuid">
<xsl:choose>
<xsl:when test="$parentID and $parentID!=''">
<xsl:value-of select="concat($parentID, '/', $name)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat('ORG:', $name)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- Create this Organisation -->
<resource name="org_organisation">
<xsl:attribute name="tuid">
<xsl:value-of select="$tuid"/>
</xsl:attribute>
<data field="name"><xsl:value-of select="$name"/></data>
<xsl:if test="$parentID and $parentID!=''">
<resource name="org_organisation_branch" alias="parent">
<reference field="organisation_id" resource="org_organisation">
<xsl:attribute name="tuid">
<xsl:value-of select="$parentID"/>
</xsl:attribute>
</reference>
</resource>
</xsl:if>
</resource>
<!-- Process Branches -->
<xsl:for-each select="$rows[col[@field=$level]/text()=$name and col[@field=$nextLevel]/text()!=''][1]">
<xsl:call-template name="OrganisationHierarchy">
<xsl:with-param name="rows" select="$rows[col[@field=$level]/text()=$name and col[@field=$nextLevel]/text()!='']"/>
<xsl:with-param name="level" select="$nextLevel"/>
<xsl:with-param name="parentID" select="$tuid"/>
</xsl:call-template>
</xsl:for-each>
<!-- Process Siblings -->
<xsl:for-each select="$rows[col[@field=$level]/text()!=$name][1]">
<xsl:call-template name="OrganisationHierarchy">
<xsl:with-param name="rows" select="$rows[col[@field=$level]/text()!=$name]"/>
<xsl:with-param name="level" select="$level"/>
<xsl:with-param name="parentID" select="$parentID"/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<!-- ****************************************************************** -->
<!-- Template to generate an organisation tuid for the current row -->
<xsl:template name="OrganisationID">
<xsl:param name="parentID"/>
<xsl:param name="parentLevel"/>
<xsl:param name="prefix">ORG:</xsl:param>
<xsl:param name="suffix"/>
<xsl:variable name="level">
<xsl:call-template name="NextLevel">
<xsl:with-param name="level" select="$parentLevel"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="name" select="col[@field=$level]/text()"/>
<xsl:choose>
<xsl:when test="$name!=''">
<xsl:variable name="id">
<xsl:choose>
<xsl:when test="$parentID and $parentID!=''">
<xsl:value-of select="concat($parentID, '/', $name)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($prefix, $name)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<xsl:call-template name="OrganisationID">
<xsl:with-param name="parentID" select="$id"/>
<xsl:with-param name="parentLevel" select="$level"/>
<xsl:with-param name="prefix" select="$prefix"/>
<xsl:with-param name="suffix" select="$suffix"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat($parentID, $suffix)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- ****************************************************************** -->
<!-- Template to generate the name of the next level column -->
<xsl:template name="NextLevel">
<xsl:param name="level"/>
<xsl:choose>
<xsl:when test="not($level) or $level=''">Organisation</xsl:when>
<xsl:when test="$level='Organisation'">Branch</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat('Sub', $level)"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- END ************************************************************** -->
</xsl:stylesheet>
Oops, something went wrong.

0 comments on commit 40c82c3

Please sign in to comment.