<?xml version="1.0" encoding="UTF-8"?>
<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:modeler="http://camunda.org/schema/modeler/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:zeebe="http://camunda.org/schema/zeebe/1.0" id="Definitions_PropozycjaZakupu" targetNamespace="https://codeberg.org/MarekDeja/ipm/pakiety/camunda-start" modeler:executionPlatform="Camunda Cloud" modeler:executionPlatformVersion="8.10.0">
  <bpmn:collaboration id="Collaboration_PropozycjaZakupu">
    <bpmn:participant id="Participant_Biblioteka" name="Biblioteka uczelniana" processRef="propozycja-zakupu" />
  </bpmn:collaboration>
  <bpmn:process id="propozycja-zakupu" name="Propozycja zakupu książki" isExecutable="true">
    <bpmn:laneSet id="LaneSet_1">
      <bpmn:lane id="Lane_Czytelnik" name="Czytelnik">
        <bpmn:flowNodeRef>Start_Propozycja</bpmn:flowNodeRef>
      </bpmn:lane>
      <bpmn:lane id="Lane_System" name="System biblioteczny">
        <bpmn:flowNodeRef>Task_Tryb</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Gw_Tryb</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Gw_Zgoda_Join</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Task_Koszt</bpmn:flowNodeRef>
      </bpmn:lane>
      <bpmn:lane id="Lane_Kierownik" name="Kierownik Oddziału Gromadzenia">
        <bpmn:flowNodeRef>Task_Akceptacja</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Gw_Zgoda</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>Boundary_Termin</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>End_Odrzucona</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>End_Wygasla</bpmn:flowNodeRef>
      </bpmn:lane>
      <bpmn:lane id="Lane_Gromadzenie" name="Bibliotekarz gromadzenia">
        <bpmn:flowNodeRef>Task_Zamowienie</bpmn:flowNodeRef>
        <bpmn:flowNodeRef>End_Zamowiona</bpmn:flowNodeRef>
      </bpmn:lane>
    </bpmn:laneSet>
    <bpmn:startEvent id="Start_Propozycja" name="Propozycja złożona">
      <bpmn:extensionElements>
        <zeebe:formDefinition formId="formularz-propozycja" />
      </bpmn:extensionElements>
    </bpmn:startEvent>
    <bpmn:businessRuleTask id="Task_Tryb" name="Ustalenie trybu akceptacji">
      <bpmn:extensionElements>
        <zeebe:calledDecision decisionId="tryb-akceptacji" resultVariable="tryb" />
      </bpmn:extensionElements>
    </bpmn:businessRuleTask>
    <bpmn:exclusiveGateway id="Gw_Tryb" name="Czy potrzebna akceptacja kierownika?" default="Flow_Tryb_Nie" />
    <bpmn:userTask id="Task_Akceptacja" name="Akceptacja propozycji">
      <bpmn:extensionElements>
        <zeebe:userTask />
        <zeebe:formDefinition formId="formularz-akceptacja" />
      </bpmn:extensionElements>
    </bpmn:userTask>
    <bpmn:boundaryEvent id="Boundary_Termin" name="Minęło 7 dni" attachedToRef="Task_Akceptacja">
      <bpmn:timerEventDefinition id="Boundary_Termin_def">
        <bpmn:timeDuration xsi:type="bpmn:tFormalExpression">P7D</bpmn:timeDuration>
      </bpmn:timerEventDefinition>
    </bpmn:boundaryEvent>
    <bpmn:exclusiveGateway id="Gw_Zgoda" name="Czy kierownik się zgodził?" default="Flow_Zgoda_Nie" />
    <bpmn:exclusiveGateway id="Gw_Zgoda_Join" />
    <bpmn:scriptTask id="Task_Koszt" name="Wyliczenie kosztu zakupu">
      <bpmn:extensionElements>
        <zeebe:script expression="=cena + 12.5" resultVariable="koszt" />
      </bpmn:extensionElements>
    </bpmn:scriptTask>
    <bpmn:userTask id="Task_Zamowienie" name="Złożenie zamówienia u dostawcy">
      <bpmn:extensionElements>
        <zeebe:userTask />
        <zeebe:formDefinition formId="formularz-zamowienie" />
      </bpmn:extensionElements>
    </bpmn:userTask>
    <bpmn:endEvent id="End_Zamowiona" name="Książka zamówiona" />
    <bpmn:endEvent id="End_Odrzucona" name="Propozycja odrzucona" />
    <bpmn:endEvent id="End_Wygasla" name="Propozycja wygasła" />
    <bpmn:sequenceFlow id="Flow_Start" sourceRef="Start_Propozycja" targetRef="Task_Tryb" />
    <bpmn:sequenceFlow id="Flow_Tryb" sourceRef="Task_Tryb" targetRef="Gw_Tryb" />
    <bpmn:sequenceFlow id="Flow_Tryb_Tak" name="tak" sourceRef="Gw_Tryb" targetRef="Task_Akceptacja">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">=tryb = "kierownik"</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="Flow_Tryb_Nie" name="nie" sourceRef="Gw_Tryb" targetRef="Gw_Zgoda_Join" />
    <bpmn:sequenceFlow id="Flow_Akceptacja" sourceRef="Task_Akceptacja" targetRef="Gw_Zgoda" />
    <bpmn:sequenceFlow id="Flow_Zgoda_Tak" name="tak" sourceRef="Gw_Zgoda" targetRef="Gw_Zgoda_Join">
      <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">=zgoda = true</bpmn:conditionExpression>
    </bpmn:sequenceFlow>
    <bpmn:sequenceFlow id="Flow_Zgoda_Nie" name="nie" sourceRef="Gw_Zgoda" targetRef="End_Odrzucona" />
    <bpmn:sequenceFlow id="Flow_Termin" sourceRef="Boundary_Termin" targetRef="End_Wygasla" />
    <bpmn:sequenceFlow id="Flow_Join" sourceRef="Gw_Zgoda_Join" targetRef="Task_Koszt" />
    <bpmn:sequenceFlow id="Flow_Koszt" sourceRef="Task_Koszt" targetRef="Task_Zamowienie" />
    <bpmn:sequenceFlow id="Flow_Zamowienie" sourceRef="Task_Zamowienie" targetRef="End_Zamowiona" />
  </bpmn:process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_1">
    <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_PropozycjaZakupu">
      <bpmndi:BPMNShape id="Participant_Biblioteka_di" bpmnElement="Participant_Biblioteka" isHorizontal="true">
        <dc:Bounds x="0" y="0" width="1150" height="640" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Lane_Czytelnik_di" bpmnElement="Lane_Czytelnik" isHorizontal="true">
        <dc:Bounds x="30" y="0" width="1120" height="130" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Lane_System_di" bpmnElement="Lane_System" isHorizontal="true">
        <dc:Bounds x="30" y="130" width="1120" height="140" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Lane_Kierownik_di" bpmnElement="Lane_Kierownik" isHorizontal="true">
        <dc:Bounds x="30" y="270" width="1120" height="230" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Lane_Gromadzenie_di" bpmnElement="Lane_Gromadzenie" isHorizontal="true">
        <dc:Bounds x="30" y="500" width="1120" height="140" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Start_Propozycja_di" bpmnElement="Start_Propozycja">
        <dc:Bounds x="90" y="30" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="80" y="71" width="56" height="23" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Task_Tryb_di" bpmnElement="Task_Tryb">
        <dc:Bounds x="176" y="160" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Gw_Tryb_di" bpmnElement="Gw_Tryb" isMarkerVisible="true">
        <dc:Bounds x="326" y="175" width="50" height="50" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="314" y="137" width="74" height="35" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Task_Akceptacja_di" bpmnElement="Task_Akceptacja">
        <dc:Bounds x="426" y="300" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Gw_Zgoda_di" bpmnElement="Gw_Zgoda" isMarkerVisible="true">
        <dc:Bounds x="576" y="315" width="50" height="50" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="553" y="370" width="96" height="23" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Gw_Zgoda_Join_di" bpmnElement="Gw_Zgoda_Join" isMarkerVisible="true">
        <dc:Bounds x="676" y="175" width="50" height="50" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Task_Koszt_di" bpmnElement="Task_Koszt">
        <dc:Bounds x="776" y="160" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Task_Zamowienie_di" bpmnElement="Task_Zamowienie">
        <dc:Bounds x="926" y="530" width="100" height="80" />
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="End_Zamowiona_di" bpmnElement="End_Zamowiona">
        <dc:Bounds x="1076" y="552" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="1046" y="593" width="96" height="11" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="End_Odrzucona_di" bpmnElement="End_Odrzucona">
        <dc:Bounds x="683" y="322" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="673" y="363" width="56" height="23" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="End_Wygasla_di" bpmnElement="End_Wygasla">
        <dc:Bounds x="583" y="430" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="550" y="471" width="102" height="11" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape id="Boundary_Termin_di" bpmnElement="Boundary_Termin">
        <dc:Bounds x="478" y="362" width="36" height="36" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="423" y="401" width="68" height="11" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge id="Flow_Start_di" bpmnElement="Flow_Start">
        <di:waypoint x="126" y="48" />
        <di:waypoint x="226" y="48" />
        <di:waypoint x="226" y="160" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_Tryb_di" bpmnElement="Flow_Tryb">
        <di:waypoint x="276" y="200" />
        <di:waypoint x="326" y="200" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_Tryb_Tak_di" bpmnElement="Flow_Tryb_Tak">
        <di:waypoint x="351" y="225" />
        <di:waypoint x="351" y="340" />
        <di:waypoint x="426" y="340" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="358" y="325" width="18" height="11" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_Tryb_Nie_di" bpmnElement="Flow_Tryb_Nie">
        <di:waypoint x="376" y="200" />
        <di:waypoint x="676" y="200" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="383" y="185" width="18" height="11" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_Akceptacja_di" bpmnElement="Flow_Akceptacja">
        <di:waypoint x="526" y="340" />
        <di:waypoint x="576" y="340" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_Zgoda_Tak_di" bpmnElement="Flow_Zgoda_Tak">
        <di:waypoint x="601" y="315" />
        <di:waypoint x="601" y="200" />
        <di:waypoint x="676" y="200" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="608" y="185" width="18" height="11" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_Zgoda_Nie_di" bpmnElement="Flow_Zgoda_Nie">
        <di:waypoint x="626" y="340" />
        <di:waypoint x="683" y="340" />
        <bpmndi:BPMNLabel>
          <dc:Bounds x="633" y="325" width="18" height="11" />
        </bpmndi:BPMNLabel>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_Termin_di" bpmnElement="Flow_Termin">
        <di:waypoint x="496" y="398" />
        <di:waypoint x="496" y="448" />
        <di:waypoint x="583" y="448" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_Join_di" bpmnElement="Flow_Join">
        <di:waypoint x="726" y="200" />
        <di:waypoint x="776" y="200" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_Koszt_di" bpmnElement="Flow_Koszt">
        <di:waypoint x="876" y="200" />
        <di:waypoint x="976" y="200" />
        <di:waypoint x="976" y="530" />
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge id="Flow_Zamowienie_di" bpmnElement="Flow_Zamowienie">
        <di:waypoint x="1026" y="570" />
        <di:waypoint x="1076" y="570" />
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</bpmn:definitions>
