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,22 +1329,33 @@ class SeedDMS_Core_User { /* {{{ */
function getReviewStatus($documentID=null, $version=null) { /* {{{ */ function getReviewStatus($documentID=null, $version=null) { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
if (!$db->createTemporaryTable("ttreviewid", true)) {
return false;
}
$status = array("indstatus"=>array(), "grpstatus"=>array()); $status = array("indstatus"=>array(), "grpstatus"=>array());
// See if the user is assigned as an individual reviewer. // 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`, ". $queryStr = "SELECT `tblDocumentReviewers`.*, `tblDocumentReviewLog`.`status`, ".
"`tblDocumentReviewLog`.`comment`, `tblDocumentReviewLog`.`date`, ". "`tblDocumentReviewLog`.`comment`, `tblDocumentReviewLog`.`date`, ".
"`tblDocumentReviewLog`.`userID` ". "`tblDocumentReviewLog`.`userID` ".
"FROM `tblDocumentReviewers` ". "FROM `tblDocumentReviewers` ".
"LEFT JOIN `tblDocumentReviewLog` USING (`reviewID`) ". "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 ."' "). ($documentID==null ? "" : "AND `tblDocumentReviewers`.`documentID` = '". (int) $documentID ."' ").
($version==null ? "" : "AND `tblDocumentReviewers`.`version` = '". (int) $version ."' "). ($version==null ? "" : "AND `tblDocumentReviewers`.`version` = '". (int) $version ."' ").
"AND `tblDocumentReviewers`.`type`='0' ".
"AND `tblDocumentReviewers`.`required`='". $this->_id ."' ". "AND `tblDocumentReviewers`.`required`='". $this->_id ."' ".
"ORDER BY `tblDocumentReviewLog`.`reviewLogID` DESC"; "ORDER BY `tblDocumentReviewLog`.`reviewLogID` DESC";
$resArr = $db->getResultArray($queryStr); $resArr = $db->getResultArray($queryStr);
if (is_bool($resArr) && $resArr === false) if (is_bool($resArr) && $resArr === false)
return false; return false;
if (count($resArr)>0) { if (count($resArr)>0) {
foreach ($resArr as $res) { foreach ($resArr as $res) {
if(isset($status["indstatus"][$res['documentID']])) { if(isset($status["indstatus"][$res['documentID']])) {
@ -1355,7 +1366,7 @@ class SeedDMS_Core_User { /* {{{ */
$status["indstatus"][$res['documentID']] = $res; $status["indstatus"][$res['documentID']] = $res;
} }
} }
} }
// See if the user is the member of a group that has been assigned to // See if the user is the member of a group that has been assigned to
// review the document version. // review the document version.
@ -1364,10 +1375,12 @@ class SeedDMS_Core_User { /* {{{ */
"`tblDocumentReviewLog`.`userID` ". "`tblDocumentReviewLog`.`userID` ".
"FROM `tblDocumentReviewers` ". "FROM `tblDocumentReviewers` ".
"LEFT JOIN `tblDocumentReviewLog` USING (`reviewID`) ". "LEFT JOIN `tblDocumentReviewLog` USING (`reviewID`) ".
"LEFT JOIN `ttreviewid` on `ttreviewid`.`maxLogID` = `tblDocumentReviewLog`.`reviewLogID` ".
"LEFT JOIN `tblGroupMembers` ON `tblGroupMembers`.`groupID` = `tblDocumentReviewers`.`required` ". "LEFT JOIN `tblGroupMembers` ON `tblGroupMembers`.`groupID` = `tblDocumentReviewers`.`required` ".
"WHERE `tblDocumentReviewers`.`type`='1' ". "WHERE `ttreviewid`.`maxLogID`=`tblDocumentReviewLog`.`reviewLogID` ".
($documentID==null ? "" : "AND `tblDocumentReviewers`.`documentID` = '". (int) $documentID ."' "). ($documentID==null ? "" : "AND `tblDocumentReviewers`.`documentID` = '". (int) $documentID ."' ").
($version==null ? "" : "AND `tblDocumentReviewers`.`version` = '". (int) $version ."' "). ($version==null ? "" : "AND `tblDocumentReviewers`.`version` = '". (int) $version ."' ").
"AND `tblDocumentReviewers`.`type`='1' ".
"AND `tblGroupMembers`.`userID`='". $this->_id ."' ". "AND `tblGroupMembers`.`userID`='". $this->_id ."' ".
"ORDER BY `tblDocumentReviewLog`.`reviewLogID` DESC"; "ORDER BY `tblDocumentReviewLog`.`reviewLogID` DESC";
$resArr = $db->getResultArray($queryStr); $resArr = $db->getResultArray($queryStr);
@ -1422,16 +1435,29 @@ class SeedDMS_Core_User { /* {{{ */
function getApprovalStatus($documentID=null, $version=null) { /* {{{ */ function getApprovalStatus($documentID=null, $version=null) { /* {{{ */
$db = $this->_dms->getDB(); $db = $this->_dms->getDB();
$status = array("indstatus"=>array(), "grpstatus"=>array()); 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 = $queryStr =
"SELECT `tblDocumentApprovers`.*, `tblDocumentApproveLog`.`status`, ". "SELECT `tblDocumentApprovers`.*, `tblDocumentApproveLog`.`status`, ".
"`tblDocumentApproveLog`.`comment`, `tblDocumentApproveLog`.`date`, ". "`tblDocumentApproveLog`.`comment`, `tblDocumentApproveLog`.`date`, ".
"`tblDocumentApproveLog`.`userID` ". "`tblDocumentApproveLog`.`userID` ".
"FROM `tblDocumentApprovers` ". "FROM `tblDocumentApprovers` ".
"LEFT JOIN `tblDocumentApproveLog` USING (`approveID`) ". "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 ."' "). ($documentID==null ? "" : "AND `tblDocumentApprovers`.`documentID` = '". (int) $documentID ."' ").
($version==null ? "" : "AND `tblDocumentApprovers`.`version` = '". (int) $version ."' "). ($version==null ? "" : "AND `tblDocumentApprovers`.`version` = '". (int) $version ."' ").
"AND `tblDocumentApprovers`.`type`='0' ".
"AND `tblDocumentApprovers`.`required`='". $this->_id ."' ". "AND `tblDocumentApprovers`.`required`='". $this->_id ."' ".
"ORDER BY `tblDocumentApproveLog`.`approveLogID` DESC"; "ORDER BY `tblDocumentApproveLog`.`approveLogID` DESC";
@ -1458,10 +1484,12 @@ class SeedDMS_Core_User { /* {{{ */
"`tblDocumentApproveLog`.`userID` ". "`tblDocumentApproveLog`.`userID` ".
"FROM `tblDocumentApprovers` ". "FROM `tblDocumentApprovers` ".
"LEFT JOIN `tblDocumentApproveLog` USING (`approveID`) ". "LEFT JOIN `tblDocumentApproveLog` USING (`approveID`) ".
"LEFT JOIN `ttapproveid` on `ttapproveid`.`maxLogID` = `tblDocumentApproveLog`.`approveLogID` ".
"LEFT JOIN `tblGroupMembers` ON `tblGroupMembers`.`groupID` = `tblDocumentApprovers`.`required` ". "LEFT JOIN `tblGroupMembers` ON `tblGroupMembers`.`groupID` = `tblDocumentApprovers`.`required` ".
"WHERE `tblDocumentApprovers`.`type`='1' ". "WHERE `ttapproveid`.`maxLogID`=`tblDocumentApproveLog`.`approveLogID` ".
($documentID==null ? "" : "AND `tblDocumentApprovers`.`documentID` = '". (int) $documentID ."' "). ($documentID==null ? "" : "AND `tblDocumentApprovers`.`documentID` = '". (int) $documentID ."' ").
($version==null ? "" : "AND `tblDocumentApprovers`.`version` = '". (int) $version ."' "). ($version==null ? "" : "AND `tblDocumentApprovers`.`version` = '". (int) $version ."' ").
"AND `tblDocumentApprovers`.`type`='1' ".
"AND `tblGroupMembers`.`userID`='". $this->_id ."' ". "AND `tblGroupMembers`.`userID`='". $this->_id ."' ".
"ORDER BY `tblDocumentApproveLog`.`approveLogID` DESC"; "ORDER BY `tblDocumentApproveLog`.`approveLogID` DESC";
$resArr = $db->getResultArray($queryStr); $resArr = $db->getResultArray($queryStr);