Item Lending Process, View Lending List

Item Lending Process, View Lending List 20220812
This workflow accepts applications to borrow items. When a loan application is submitted, the loan status of the specified item is displayed in the list by pressing the search button. The loan status is retrieved from the loaned/reserved application, the period and user are retrieved and entered.
Worker (#of Swimlane: 3)
  • Applicant
  • General Affairs Department
    • The department in charge of lending supplies.
  • Supervisor
Business Flow (Complexity of Workflow: 23)
  • 11. Loan application
    • Employees apply to borrow items.
  • 41x. Reapply
    • The employee re-applies for the loan of goods on the basis of the reasons for rejection. Depending on the reasons for rejection, the application is withdrawn.
  • 22. Approval
    • The applicant’s superior approves the loan application.
  • 83. Lending library
    • The person in charge of lending in the General Affairs Department will check the application details from the QR code and register the date and time of item lending.
  • 124. Item returns
    • The lending staff in the General Affairs Department will check the application details from the QR code and register the date and time for returning the item.
  • 23 Loan Status: Cancelled
  • 19Loan Status: On loan
    • The workflow platform changes the loan status to “on loan”.
  • 21Loan Status: Reserved
    • The workflow platform changes the loan status to “Reserved”.
  • 20Loan Status: Returned
    • The workflow platform changes the lending status to “Returned”.
  • 22 Update of reminder date and time
  • 5x1. Set Subject
    • The workflow platform sets the subject line.
  • 6x2. Receipt QR code issued
    • The workflow platform generates a QR code (PNG image) for lending/returning.
  • 18 x3. Set Subject
Workflow Diagram (click to open)
Business Process Variables (#of Data Item: 19)
  • ◆ Application 10
  • Loan Item Category q_item_category 4*
    • Stores the category of loaned items.
  • Loan Item q_item 5*
    • Loan items are stored.
  • ◆ Checking the status of loaned items 17
    • Search and dynamically display the loan/reservation status of specified loaned items.
  • Lending Schedule Date and Time q_lending_schedule_datetime 0*
    • At the time of application, the expected date and time of the loan are stored.
  • Expected Return Date and Time q_return_schedule_datetime 1*
    • At the time of application, the expected return date and time are stored.
  • Purpose of Loan q_description 6
    • At the time of application, the reason for borrowing the goods is stored.
  • ◆ Lending/Returning 11
  • Loan Control Number q_management_number 15
    • A unique control number is stored for each loan case.
    • L#{#sformat(‘%06d’, processInstanceId)}
  • Item Loanee q_quser 7
    • The loan applicant is stored.
    • ${processInstance.initQuserId}
  • Item Loaner q_leader 8
    • The approver of the loan application is stored.
    • ${processInstance.initQuserId}
  • Date and Time of Loan q_lending_datetime 2*
    • The date and time when the goods were lent are stored.
  • Date and Time of Return q_return_datetime 3*
    • The date and time when the goods were returned is stored.
  • Loan: Memoq_lending_note 12
    • Notes on loan (e.g. handling and condition of goods) are stored.
  • Return: Memo q_return_note 13
    • The condition of the goods at the time of return, etc. is stored.
  • Communication q_communication 9
    • Notes on application, comments on approval, etc. are stored.
  • QR Code Image File q_QRCode_file 16
    • An image file of the QR code showing the process details URL for this project will be stored.
  • Loan Status q_status 14
    • The loan status of the goods is stored.
    • Not approved
  • Reminder Date and Time q_remind_datetime 19

Field Name, num, Initial Value

Download

This archive contains the BPMN icons that are not available in the Basic edition.

Notes

  • When importing, associate the processing person settings according to the organizational structure.
  • Assigned user privileges for “Applicant” swim lane
    • Please grant editing data viewing permission in App Settings > App Details > Permissions.
  • Operation of reservation cancellation
    • If you no longer need to borrow the item after applying for the loan, please ask the person in charge of general affairs to cancel your reservation.

Arrangement Tips

1. Loan application step, Loan status search Decoration Script (click to open)
<button onclick="user_getHistory()" type="button" class="user_Search">Confirmation of rental/reservation</button>
<br>If the item is being loaned/reserved, please consult with the user before applying.
<div style="padding: 0.5em 1em; margin: 2em 0; font-weight: bold; color: #6091d3; background: #FFFFF; border: solid 3px #6091d3;  border-radius: 10px; width:80%;">
<div id="user_Result"></div>
</div>

<script type="text/javascript">
document.addEventListener("click", function (e) {
  console.log( " DocumentElement clicked: " + e.target.textContent );
  if (e.target.classList.contains("user_Appender")) {
    qbpms.form.set( "q_Transaction_Title", e.target.value );   ///EDIT///
  }
});

function user_getHistory() {
  let numTARGET_ITEM_ID          = 5;     ///No Need to Edit///
  let numTARGET_STATUS_ID        = 14;    ///No Need to Edit///
  let numTARGET_STARTDATETIME_ID = 0;     ///No Need to Edit///
  let numTARGET_ENDDATETIME_ID    = 1;    ///No Need to Edit///
  let numLIMITSIZE     = 10;              ///Needs Editing (According to frequency of use)///
  let numWORKFLOWAPPID = ***;            ///Needs Editing (This WorkFlow Application ID)///
  let strSearchItemId = "";
  let strSearchItemName = "";
  let array = qbpms.form.get( "q_item" );
  let elResultDiv     = document.querySelector("#user_Result");    ///EDIT///
  console.log("array: " + array.length);
  if (array.length !== 0){
    console.log( "q_item is not empty or null.");
    strSearchItemName = array[0].display;
    strSearchItemId = array[0].value;
  }else{
    elResultDiv.innerHTML = ""; // clear
    return;
  }

  let objCriteria = {}; // JSON criteria: (BPMS v13.3~)
      // https://questetra.zendesk.com/hc/ja/articles/4415341995289
      // https://questetra.zendesk.com/hc/en-us/articles/4415341995289
      objCriteria.processModelInfoId = numWORKFLOWAPPID;
      objCriteria.processInstanceState = [];
      objCriteria.processInstanceState[0] = "STARTED";
      objCriteria.data = [];
      objCriteria.data[0] = {};
      objCriteria.data[0].type   = "select";
      objCriteria.data[0].number = numTARGET_ITEM_ID;
      objCriteria.data[0].method = "selected";
      objCriteria.data[0].value  = strSearchItemId;
      objCriteria.fields = [];
      objCriteria.fields[0] = {};
      objCriteria.fields[0].type   = "select";
      objCriteria.fields[0].number = numTARGET_ITEM_ID;
      objCriteria.fields[1] = {};
      objCriteria.fields[1].type   = "datetime";
      objCriteria.fields[1].number = numTARGET_STARTDATETIME_ID;
      objCriteria.fields[2] = {};
      objCriteria.fields[2].type   = "datetime";
      objCriteria.fields[2].number = numTARGET_ENDDATETIME_ID;
      objCriteria.fields[3] = {};
      objCriteria.fields[3].type   = "select";
      objCriteria.fields[3].number = numTARGET_STATUS_ID;
  let xhr = new XMLHttpRequest();
      xhr.open( "GET", "/API/OR/ProcessInstance/list?limit=" + numLIMITSIZE +
                       "&criteria=" + encodeURIComponent(JSON.stringify(objCriteria)) );
      xhr.responseType = 'json';
      xhr.send();
      xhr.onload = function() {
        if (xhr.status != 200) {
          console.error(`Error ${xhr.status}: ${xhr.statusText}`); // e.g. "404: Not Found"
        } else { // show the result
          let objResponse = xhr.response;
          if (objResponse.count === 0){
            elResultDiv.innerHTML = "Available for loan at any time"; // clear
            return;
          }
          console.log( " Decoration XHR: Found PastData " + objResponse.processInstances.length +
                       "/" + objResponse.count  );
          elResultDiv.innerHTML = ""; // clear
          let list = Array.from(new Array(objResponse.processInstances.length), () => new Array(6).fill(""));
          for (let i=0; i < objResponse.processInstances.length; i++){
            console.log("STATUS:" + objResponse.processInstances[i].data[numTARGET_STATUS_ID].value[0].value);
            list[i][1] = "【" + objResponse.processInstances[i].data[numTARGET_STATUS_ID].value[0].display +"】" + " ";
            list[i][2] = "/OR/ProcessInstance/view?processInstanceId=" + objResponse.processInstances[i].processInstanceId;
            list[i][3] = "_blank";
            if (objResponse.processInstances[i].data[numTARGET_STARTDATETIME_ID].value !== null){
              list[i][0] = objResponse.processInstances[i].data[numTARGET_STARTDATETIME_ID].value;
              list[i][4] = objResponse.processInstances[i].data[numTARGET_STARTDATETIME_ID].value + " - ";
            }else{
              list[i][4] = "To be decided - ";
            }
            if (objResponse.processInstances[i].data[numTARGET_ENDDATETIME_ID].value !== null){
              list[i][5] = objResponse.processInstances[i].data[numTARGET_ENDDATETIME_ID].value + " ";
            }else{
              list[i][5] = "To be decided ";
            }
            list[i][6] = objResponse.processInstances[i].processInstanceInitQuserName;
          }
          console.log(JSON.stringify(list));
          createHtml(list,elResultDiv);
        }
        console.log( " Decoration XHR: finished " );
      };
      xhr.onerror = function() {
        alert("Request failed");
      };
  function createHtml(list,elResultDiv){
    list.sort(function(a, b){
	return (a > b ? 1 : -1);
    });
    console.log("sorted: " + JSON.stringify(list));
    for (let i=0; i < list.length; i++){
console.log(list[i][1]);
      let elNewAnchor = document.createElement("a");
          elNewAnchor.href = list[i][2];
          elNewAnchor.target = list[i][3];
          elNewAnchor.innerText += list[i][4];
          elNewAnchor.innerText += list[i][5];
          elNewAnchor.innerText += list[i][6];
      elResultDiv.append( list[i][1], elNewAnchor );
      elResultDiv.innerHTML += "<br>";
    }
  }
}
</script>

Capture

See also

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Questetra Support

Subscribe now to keep reading and get access to the full archive.

Continue reading

Scroll to Top