--- layout: null permalink: /nobreakspace/inventory --- <?xml version="1.0" encoding="UTF-8"?> <inventoy> {%- for device in site.inventory -%} {% assign tool = device -%} {% assign display_info = 0 -%} {% assign display_info_next_week = 0 -%} {% if tool.out_of_service -%} {% assign display_info = 1 -%} {% endif -%} {% capture nowunix %}{{'now' | date: '%s'}}{% endcapture %} {%- capture next_week %}{{'now' | date: '%s' | plus: 604800 }}{%- endcapture -%} {% for loan in site.loan -%} {% capture eventdate %}{{loan.eventdate | date: '%s'}}{% endcapture %} {% capture eventend %}{{loan.eventend | date: '%s'}}{% endcapture %} {% if loan.devices -%} {% if loan.devices contains tool.uid -%} {% if eventdate < nowunix -%} {% if nowunix < eventend -%} {% assign display_info = 2 -%} {% endif -%} {% else -%} {% if eventdate < next_week -%} {% assign display_info_next_week = 2 -%} {% endif -%} {% endif -%} {% endif -%} {% endif -%} {% if loan.sets -%} {% for set in tool.sets -%} {% if loan.sets contains set -%} {% if eventdate < nowunix -%} {% if nowunix < eventend -%} {% assign display_info = 2 -%} {% endif -%} {% else -%} {% if eventdate < next_week -%} {% assign display_info_next_week = 2 -%} {% endif -%} {% endif -%} {% endif -%} {% endfor -%} {% endif -%} {% endfor -%} {% for loan in site.events %} {% capture eventdate %}{{loan.eventdate | date: '%s'}}{% endcapture %} {% capture eventend %}{{loan.eventend | date: '%s'}}{% endcapture %} {% if loan.devices -%} {% if loan.devices contains tool.uid -%} {% if eventdate < nowunix -%} {% if nowunix < eventend -%} {% assign display_info = 3 -%} {% endif -%} {% else -%} {% if eventdate < next_week -%} {% assign display_info_next_week = 3 -%} {% endif -%} {% endif -%} {% endif -%} {% endif -%} {% if loan.sets -%} {% for set in tool.sets -%} {% if loan.sets contains set -%} {% if eventdate < nowunix -%} {% if nowunix < eventend -%} {% assign display_info = 3 -%} {% endif -%} {% else -%} {% if eventdate < next_week -%} {% assign display_info_next_week = 3 -%} {% endif -%} {% endif -%} {% endif -%} {% endfor -%} {% endif -%} {% endfor -%} <device> <name>{{device.name}}</name> <uid>{{device.uid}}</uid> {% if device.safetybriefing -%} <safetybriefing>true</safetybriefing> {% else %} <safetybriefing>false</safetybriefing> {% endif -%} {% if display_info == 1 -%} <outofservice>true</outofservice> {% else %} <outofservice>false</outofservice> {% endif -%} {% if display_info == 2 -%} <onloan>true</onloan> {% else %} <onloan>false</onloan> {% endif -%} {% if display_info == 3 -%} <usedinevent>true</usedinevent> {% else %} <usedinevent>false</usedinevent> {% endif -%} {% assign futureLoans = "" | split: ',' -%} {% for loan in site.loan -%} {% capture eventdate %}{{loan.eventdate | date: '%s'}}{% endcapture %} {% capture eventend %}{{loan.eventend | date: '%s'}}{% endcapture %} {% if loan.devices -%} {% if loan.devices contains tool.uid -%} {% if eventend > nowunix -%} {% assign futureLoans = futureLoans | push: loan -%} {% endif -%} {% endif -%} {% endif -%} {% if loan.sets -%} {% for set in tool.sets -%} {% if loan.sets contains set -%} {% if eventend > nowunix -%} {% assign futureLoans = futureLoans | push: loan -%} {% endif -%} {% endif -%} {% endfor -%} {% endif -%} {% endfor -%} {% for loan in site.events -%} {% capture eventdate %}{{loan.eventdate | date: '%s'}}{% endcapture -%} {% capture eventend %}{{loan.eventend | date: '%s'}}{% endcapture -%} {% if loan.devices -%} {% if loan.devices contains tool.uid -%} {% if eventend > nowunix -%} {% assign futureLoans = futureLoans | push: loan -%} {% endif -%} {% endif -%} {% endif -%} {% if loan.sets -%} {% for set in tool.sets -%} {% if loan.sets contains set -%} {% if eventend > nowunix -%} {% assign futureLoans = futureLoans | push: loan -%} {% endif -%} {% endif -%} {% endfor -%} {% endif -%} {% endfor -%} {% assign floans = futureLoans | sort: 'eventdate' -%} <futurebookings> {% for floan in floans -%} <booking> <start>{{floan.eventdate | date: '%s'}}</start> <end>{{floan.eventend | date: '%s'}}</end> </booking> {% endfor -%} </futurebookings> <wikilink>{{device.wikilink}}</wikilink> <sets> {%- for set in device.sets -%} <set>{{set}}</set> {%- endfor -%} </sets> <contacts> {%- for contact in device.contact -%} {% for person in site.people -%} {% if contact == person.person_id %} <contact>{{contact.name}}</contact> {% endif -%} {% endfor -%} {% endfor -%} </contacts> </device> {%- endfor -%} </inventoy>