<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers" xmlns:cal="http://typo3.org/ns/Ig/IgReservations/ViewHelpers" xmlns:core="http://typo3.org/ns/TYPO3/CMS/Core/ViewHelpers" data-namespace-typo3-fluid="true">
<cal:calendar.hasPermission calendar="{calendar}" permission="team">
    <f:then>
        <div class="timeslot-name" title="{f:translate(key: 'tx_igreservations_domain_model_event')}: {f:if(condition: event.reservations, then: '{event.reservations.0.firstName} {event.reservations.0.lastName}')}
{f:translate(key: 'tx_igreservations_domain_model_event.num_participants')}: {event.numParticipants}">
            {event.timeslot.name}
            <cal:calendar.hasPermission calendar="{calendar}" permission="team">
                <f:if condition="{event.category}">
                    <br /><span class="category-name">{event.category.name}</span>
                </f:if>
            </cal:calendar.hasPermission>
        </div>
    </f:then>
    <f:else>
        <div class="timeslot-name">
            {event.timeslot.name}
            <cal:calendar.hasPermission calendar="{calendar}" permission="team">
                <f:if condition="{event.category}">
                    <br /><span class="category-name">{event.category.name}</span>
                </f:if>
            </cal:calendar.hasPermission>
        </div>
    </f:else>
</cal:calendar.hasPermission>

<f:if condition="!{event.isBlocked}">
<div class="timeslot-action event-status-{event.status.uid}">
    <f:comment>
        <cal:event.link.action event="{event}" action="new" controller="Event" pluginName="PublicCalendar">New</cal:event.link.action>
    </f:comment>

    <f:comment>*** Buchen ***</f:comment>
    <cal:event.canAddReservation event="{event}">
        <f:then>
            <f:comment>*** Benutzerbereich ***</f:comment>
            <cal:calendar.hasPermission calendar="{calendar}" permission="user">
                <f:if condition="{event.uid}">
                    <f:then>
                      <cal:calendar.hasPermission calendar="{calendar}" permission="team">
			<f:then>
            	          <f:if condition="{event.status.needsAction} || {event.status.needsMember}">
                            <f:comment>*** Benutzer zuweisen ***</f:comment>
                            <cal:event.command title="{f:translate(key: 'events.assign_user')}" controller="Ajax" action="teammemberAssignmentForm" event="{event}" lightbox="1" class="button button-new">
                              <core:icon identifier="actions-user" size="small" alternativeMarkupIdentifier="inline" /><span class="label">
                                <f:translate key="events.assign_user" /></span>
                            </cal:event.command>
            	          </f:if>
                          <f:comment>*** Ansehen ***</f:comment>
                          <cal:event.command title="{f:translate(key: 'events.show')}" controller="Ajax" action="eventShow" event="{event}" lightbox="1" class="button button-new">
                            <core:icon identifier="actions-version-workspace-preview" size="small" alternativeMarkupIdentifier="inline" /><span class="label">
                              <f:translate key="events.show" /></span>
                          </cal:event.command>
                          <f:comment>*** Bearbeiten ***</f:comment>
                          <cal:event.command title="{f:translate(key: 'events.edit')}" controller="Ajax" action="reservationCreateForm" event="{event}" lightbox="1" class="button button-new">
                            <core:icon identifier="actions-open" size="small" alternativeMarkupIdentifier="inline" /><span class="label">
                              <f:translate key="events.edit" /></span>
                          </cal:event.command>
                          <f:comment>*** Löschen ***</f:comment>
                          <cal:calendar.isAdmin calendar="{calendar}">
                            <cal:event.remove title="{f:translate(key: 'events.delete')}" confirm-title="{f:translate(key: 'events.delete')}" confirm-content="{f:translate(key: 'events.really_delete')}" event="{event}"
					      class="button button-delete">
                              <core:icon identifier="actions-delete" size="small" alternativeMarkupIdentifier="inline" /><span class="label">
                                <f:translate key="events.unregister" /></span>
                            </cal:event.remove>
                          </cal:calendar.isAdmin>
			</f:then>
			<f:else>
            	          <f:if condition="!{event.status.noReservationAllowed}">
                          <f:comment>*** Bearbeiten ***</f:comment>
                          <cal:event.command title="{f:translate(key: 'events.new')}" controller="Ajax" action="reservationCreateForm" event="{event}" lightbox="1" class="button button-new">
                            <core:icon identifier="actions-add" size="small" alternativeMarkupIdentifier="inline" /><span class="label">
                              <f:translate key="events.new" /></span>
                          </cal:event.command>
			  </f:if>
			</f:else>
		      </cal:calendar.hasPermission>
                    </f:then>
                    <f:else>
                        <f:comment>*** Hinzufügen ***</f:comment>
                        <cal:event.command title="{f:translate(key: 'events.new')}" controller="Ajax" action="reservationCreateForm" event="{event}" lightbox="1" class="button button-new">
                            <core:icon identifier="actions-add" size="small" alternativeMarkupIdentifier="inline" /><span class="label">
                                <f:translate key="events.new" /></span>
                        </cal:event.command>
                        <f:if condition="{eventClipboard}">
                            <cal:calendar.hasPermission calendar="{calendar}" permission="team">
                                <f:link.action pageUid="{calendar.pageUid}" action="insert" controller="Event" arguments="{event: eventClipboard, date: '{date->f:format.date(format: \'Y-m-d\')}', timeslot: event.timeslot}" class="button button-new">
                                    <core:icon identifier="actions-document-paste" size="small" alternativeMarkupIdentifier="inline" /><span class="label">
                                        Einfügen</span>
                                </f:link.action>
                            </cal:calendar.hasPermission>
                        </f:if>
                    </f:else>
                </f:if>
            </cal:calendar.hasPermission>
        </f:then>
        <f:else if="{event.uid}">
            <f:comment>*** Team-/Adminbereich ***</f:comment>
            <cal:calendar.hasPermission calendar="{calendar}" permission="team">
                <f:if condition="!{event.reservations}">
                    <f:comment>*** Bearbeiten ***</f:comment>
                    <cal:event.command title="{f:translate(key: 'events.edit')}" controller="Ajax" action="reservationCreateForm" event="{event}" lightbox="1" class="button button-new">
                        <core:icon identifier="actions-open" size="small" alternativeMarkupIdentifier="inline" /><span class="label">
                            <f:translate key="events.edit" /></span>
                    </cal:event.command>
                    <f:comment>*** Löschen ***</f:comment>
                    <cal:calendar.isAdmin calendar="{calendar}">
                        <cal:event.remove title="{f:translate(key: 'events.delete')}" confirm-title="{f:translate(key: 'events.delete')}" confirm-content="{f:translate(key: 'events.really_delete')}" event="{event}"
                            class="button button-delete">
                            <core:icon identifier="actions-delete" size="small" alternativeMarkupIdentifier="inline" /><span class="label">
                                <f:translate key="events.unregister" /></span>
                        </cal:event.remove>
                    </cal:calendar.isAdmin>
                </f:if>
    	      <f:if condition="{event.status.needsAction} || {event.status.needsMember}">
                    <f:comment>*** Benutzer zuweisen ***</f:comment>
                    <cal:event.command title="{f:translate(key: 'events.assign_user')}" controller="Ajax" action="teammemberAssignmentForm" event="{event}" lightbox="1" class="button button-new">
                        <core:icon identifier="actions-user" size="small" alternativeMarkupIdentifier="inline" /><span class="label">
                            <f:translate key="events.assign_user" /></span>
                    </cal:event.command>
    	      </f:if>
                <f:comment>*** Ansehen ***</f:comment>
                <cal:event.command title="{f:translate(key: 'events.show')}" controller="Ajax" action="eventShow" event="{event}" lightbox="1" class="button button-new">
                    <core:icon identifier="actions-version-workspace-preview" size="small" alternativeMarkupIdentifier="inline" /><span class="label">
                        <f:translate key="events.show" /></span>
                </cal:event.command>
                <f:comment>*** Bearbeiten ***</f:comment>
                <f:for each="{event.reservations}" as="reservation">
                    <cal:reservation.command title="{f:translate(key: 'events.edit')}" controller="Ajax" action="reservationEditForm" reservation="{reservation}" lightbox="1" class="button button-new">
                        <core:icon identifier="actions-open" size="small" alternativeMarkupIdentifier="inline" /><span class="label">
                            <f:translate key="events.edit" /></span>
                    </cal:reservation.command>
                    <f:comment>*** Abmelden ***</f:comment>
                    <cal:calendar.isAdmin calendar="{calendar}">
                        <cal:reservation.remove title="{f:translate(key: 'events.delete')}" confirm-title="{f:translate(key: 'events.delete')}" confirm-content="{f:translate(key: 'events.really_delete')}" reservation="{reservation}"
                            class="button button-delete">
                            <core:icon identifier="actions-delete" size="small" alternativeMarkupIdentifier="inline" /><span class="label">
                                <f:translate key="events.unregister" /></span>
                        </cal:reservation.remove>
                    </cal:calendar.isAdmin>
                </f:for>

                <f:if condition="!{eventClipboard}">
                    <f:then>
                        <f:link.action pageUid="{calendar.pageUid}" pageUid="{calendar.pageUid}" action="cut" controller="Event" arguments="{event: event}" class="button button-new">
                            <core:icon identifier="actions-edit-cut" size="small" alternativeMarkupIdentifier="inline" /><span class="label">
                                Ausschneiden</span>
                        </f:link.action>
                    </f:then>
                    <f:else if="{eventClipboard.uid} == {event.uid}">
                        <f:link.action pageUid="{calendar.pageUid}" action="uncut" controller="Event" arguments="{event: eventClipboard}" class="button button-new">
                            <core:icon identifier="actions-edit-cut-release" size="small" alternativeMarkupIdentifier="inline" /><span class="label">
                                Ausschneiden abbrechen</span>
                        </f:link.action>
                    </f:else>
                </f:if>
            </cal:calendar.hasPermission>
        </f:else>
    </cal:event.canAddReservation>
</div>
</f:if>
</html>
