get[Review|Approval]Status takes ttreviewid|ttapproveid into account

This commit is contained in:
Uwe Steinmann 2021-09-29 14:50:35 +02:00
parent 007e3faa0a
commit dc48e5da2c

View File

@ -1329,17 +1329,28 @@ class SeedDMS_Core_User { /* {{{ */
function getReviewStatus($documentID=null, $version=null) { /* {{{ */
$db = $this->_dms->getDB();
if (!$db->createTemporaryTable("ttreviewid", true)) {
return false;
}
$status = array("indstatus"=>array(), "grpstatus"=>array());
// See if the user is assigned as an individual reviewer.
// Attention: this method didn't use ttreviewid to filter out the latest
// log entry. This was added 2021-09-29 because $group->getReviewStatus()
// does it as well. The check below if the date is larger than the date
// of a previos entry is still required to just take the latest version
// of a document into account.
$queryStr = "SELECT `tblDocumentReviewers`.*, `tblDocumentReviewLog`.`status`, ".
"`tblDocumentReviewLog`.`comment`, `tblDocumentReviewLog`.`date`, ".
"`tblDocumentReviewLog`.`userID` ".
"FROM `tblDocumentReviewers` ".
"LEFT JOIN `tblDocumentReviewLog` USING (`reviewID`) ".
"WHERE `tblDocumentReviewers`.`type`='0' ".
"LEFT JOIN `ttreviewid` on `ttreviewid`.`maxLogID` = `tblDocumentReviewLog`.`reviewLogID` ".
"WHERE `ttreviewid`.`maxLogID`=`tblDocumentReviewLog`.`reviewLogID` ".
($documentID==null ? "" : "AND `tblDocumentReviewers`.`documentID` = '". (int) $documentID ."' ").
($version==null ? "" : "AND `tblDocumentReviewers`.`version` = '". (int) $version ."' ").
"AND `tblDocumentReviewers`.`type`='0' ".
"AND `tblDocumentReviewers`.`required`='". $this->_id ."' ".
"ORDER BY `tblDocumentReviewLog`.`reviewLogID` DESC";
$resArr = $db->getResultArray($queryStr);
@ -1364,10 +1375,12 @@ class SeedDMS_Core_User { /* {{{ */
"`tblDocumentReviewLog`.`userID` ".
"FROM `tblDocumentReviewers` ".
"LEFT JOIN `tblDocumentReviewLog` USING (`reviewID`) ".
"LEFT JOIN `ttreviewid` on `ttreviewid`.`maxLogID` = `tblDocumentReviewLog`.`reviewLogID` ".
"LEFT JOIN `tblGroupMembers` ON `tblGroupMembers`.`groupID` = `tblDocumentReviewers`.`required` ".
"WHERE `tblDocumentReviewers`.`type`='1' ".
"WHERE `ttreviewid`.`maxLogID`=`tblDocumentReviewLog`.`reviewLogID` ".
($documentID==null ? "" : "AND `tblDocumentReviewers`.`documentID` = '". (int) $documentID ."' ").
($version==null ? "" : "AND `tblDocumentReviewers`.`version` = '". (int) $version ."' ").
"AND `tblDocumentReviewers`.`type`='1' ".
"AND `tblGroupMembers`.`userID`='". $this->_id ."' ".
"ORDER BY `tblDocumentReviewLog`.`reviewLogID` DESC";
$resArr = $db->getResultArray($queryStr);
@ -1422,16 +1435,29 @@ class SeedDMS_Core_User { /* {{{ */
function getApprovalStatus($documentID=null, $version=null) { /* {{{ */
$db = $this->_dms->getDB();
if (!$db->createTemporaryTable("ttapproveid")) {
return false;
}
$status = array("indstatus"=>array(), "grpstatus"=>array());
// See if the user is assigned as an individual approver.
// Attention: this method didn't use ttapproveid to filter out the latest
// log entry. This was added 2021-09-29 because $group->getApprovalStatus()
// does it as well. The check below if the date is larger than the date
// of a previos entry is still required to just take the latest version
// of a document into account.
$queryStr =
"SELECT `tblDocumentApprovers`.*, `tblDocumentApproveLog`.`status`, ".
"`tblDocumentApproveLog`.`comment`, `tblDocumentApproveLog`.`date`, ".
"`tblDocumentApproveLog`.`userID` ".
"FROM `tblDocumentApprovers` ".
"LEFT JOIN `tblDocumentApproveLog` USING (`approveID`) ".
"WHERE `tblDocumentApprovers`.`type`='0' ".
"LEFT JOIN `ttapproveid` on `ttapproveid`.`maxLogID` = `tblDocumentApproveLog`.`approveLogID` ".
"WHERE `ttapproveid`.`maxLogID`=`tblDocumentApproveLog`.`approveLogID` ".
($documentID==null ? "" : "AND `tblDocumentApprovers`.`documentID` = '". (int) $documentID ."' ").
($version==null ? "" : "AND `tblDocumentApprovers`.`version` = '". (int) $version ."' ").
"AND `tblDocumentApprovers`.`type`='0' ".
"AND `tblDocumentApprovers`.`required`='". $this->_id ."' ".
"ORDER BY `tblDocumentApproveLog`.`approveLogID` DESC";
@ -1458,10 +1484,12 @@ class SeedDMS_Core_User { /* {{{ */
"`tblDocumentApproveLog`.`userID` ".
"FROM `tblDocumentApprovers` ".
"LEFT JOIN `tblDocumentApproveLog` USING (`approveID`) ".
"LEFT JOIN `ttapproveid` on `ttapproveid`.`maxLogID` = `tblDocumentApproveLog`.`approveLogID` ".
"LEFT JOIN `tblGroupMembers` ON `tblGroupMembers`.`groupID` = `tblDocumentApprovers`.`required` ".
"WHERE `tblDocumentApprovers`.`type`='1' ".
"WHERE `ttapproveid`.`maxLogID`=`tblDocumentApproveLog`.`approveLogID` ".
($documentID==null ? "" : "AND `tblDocumentApprovers`.`documentID` = '". (int) $documentID ."' ").
($version==null ? "" : "AND `tblDocumentApprovers`.`version` = '". (int) $version ."' ").
"AND `tblDocumentApprovers`.`type`='1' ".
"AND `tblGroupMembers`.`userID`='". $this->_id ."' ".
"ORDER BY `tblDocumentApproveLog`.`approveLogID` DESC";
$resArr = $db->getResultArray($queryStr);