mirror of
https://git.code.sf.net/p/seeddms/code
synced 2024-11-26 15:32:13 +00:00
add revision workflow
This commit is contained in:
parent
68be1ad42e
commit
a590fec967
|
@ -30,7 +30,7 @@ define("S_DRAFT_APP", 1);
|
|||
/*
|
||||
* Document is released. A document is in release state either when
|
||||
* it needs no review or approval after uploaded or has been reviewed
|
||||
* and/or approved..
|
||||
* and/or approved.
|
||||
*/
|
||||
define("S_RELEASED", 2);
|
||||
|
||||
|
@ -40,6 +40,12 @@ define("S_RELEASED", 2);
|
|||
*/
|
||||
define("S_IN_WORKFLOW", 3);
|
||||
|
||||
/*
|
||||
* Document is in a revision workflow. A revision workflow is started
|
||||
* some time after the document has been released.
|
||||
*/
|
||||
define("S_IN_REVISION", 4);
|
||||
|
||||
/*
|
||||
* Document was rejected. A document is in rejected state when
|
||||
* the review failed or approval was not given.
|
||||
|
@ -2856,6 +2862,57 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
return $this->_receiptStatus;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Get the current revision status of the document content
|
||||
* The revision status is a list of revisions
|
||||
*
|
||||
* @return array list of revisions
|
||||
*/
|
||||
function getRevisionStatus($limit=1) { /* {{{ */
|
||||
$db = $this->_document->_dms->getDB();
|
||||
|
||||
if (!is_numeric($limit)) return false;
|
||||
|
||||
// Retrieve the current status of each assigned reviewer for the content
|
||||
// represented by this object.
|
||||
// FIXME: caching was turned off to make list of review log in ViewDocument
|
||||
// possible
|
||||
if (1 || !isset($this->_revisionStatus)) {
|
||||
/* First get a list of all revisions for this document content */
|
||||
$queryStr=
|
||||
"SELECT revisionID FROM tblDocumentRevisers WHERE `version`='".$this->_version
|
||||
."' AND `documentID` = '". $this->_document->getID() ."' ";
|
||||
$recs = $db->getResultArray($queryStr);
|
||||
if (is_bool($recs) && !$recs)
|
||||
return false;
|
||||
$this->_revisionStatus = array();
|
||||
if($recs) {
|
||||
foreach($recs as $rec) {
|
||||
$queryStr=
|
||||
"SELECT `tblDocumentRevisers`.*, `tblDocumentRevisionLog`.`revisionLogID`, ".
|
||||
"`tblDocumentRevisionLog`.`status`, ".
|
||||
"`tblDocumentRevisionLog`.`comment`, ".
|
||||
"`tblDocumentRevisionLog`.`date`, ".
|
||||
"`tblDocumentRevisionLog`.`userID`, `tblUsers`.`fullName`, `tblGroups`.`name` AS `groupName` ".
|
||||
"FROM `tblDocumentRevisers` ".
|
||||
"LEFT JOIN `tblDocumentRevisionLog` USING (`revisionID`) ".
|
||||
"LEFT JOIN `tblUsers` on `tblUsers`.`id` = `tblDocumentRevisers`.`required` ".
|
||||
"LEFT JOIN `tblGroups` on `tblGroups`.`id` = `tblDocumentRevisers`.`required` ".
|
||||
"WHERE `tblDocumentRevisers`.`revisionID` = '". $rec['revisionID'] ."' ".
|
||||
"ORDER BY `tblDocumentRevisionLog`.`revisionLogID` DESC LIMIT ".(int) $limit;
|
||||
|
||||
$res = $db->getResultArray($queryStr);
|
||||
if (is_bool($res) && !$res) {
|
||||
unset($this->_revisionStatus);
|
||||
return false;
|
||||
}
|
||||
$this->_revisionStatus = array_merge($this->_revisionStatus, $res);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $this->_revisionStatus;
|
||||
} /* }}} */
|
||||
|
||||
function addIndReviewer($user, $requestUser, $listadmin=false) { /* {{{ */
|
||||
$db = $this->_document->_dms->getDB();
|
||||
|
||||
|
@ -3414,6 +3471,113 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
return 0;
|
||||
} /* }}} */
|
||||
|
||||
function addIndReviser($user, $requestUser, $listadmin=false) { /* {{{ */
|
||||
$db = $this->_document->_dms->getDB();
|
||||
|
||||
$userID = $user->getID();
|
||||
|
||||
// Get the list of users and groups with read access to this document.
|
||||
if($this->_document->getAccessMode($user) < M_READ) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
// Check to see if the user has already been added to the reviser list.
|
||||
$revisionStatus = $user->getRevisionStatus($this->_document->getID(), $this->_version);
|
||||
if (is_bool($revisionStatus) && !$revisionStatus) {
|
||||
return -1;
|
||||
}
|
||||
$indstatus = false;
|
||||
if (count($revisionStatus["indstatus"]) > 0) {
|
||||
$indstatus = array_pop($revisionStatus["indstatus"]);
|
||||
if($indstatus["status"]!=-2) {
|
||||
// User is already on the list of recipients; return an error.
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
|
||||
// Add the user into the revisers database.
|
||||
if (!$indstatus || ($indstatus && $indstatus["status"]!=-2)) {
|
||||
$queryStr = "INSERT INTO `tblDocumentRevisers` (`documentID`, `version`, `type`, `required`) ".
|
||||
"VALUES ('". $this->_document->getID() ."', '". $this->_version ."', '0', '". $userID ."')";
|
||||
$res = $db->getResult($queryStr);
|
||||
if (is_bool($res) && !$res) {
|
||||
return -1;
|
||||
}
|
||||
$revisionID = $db->getInsertID();
|
||||
}
|
||||
else {
|
||||
$revisionID = isset($indstatus["revisionID"]) ? $indstatus["revisionID"] : NULL;
|
||||
}
|
||||
|
||||
$queryStr = "INSERT INTO `tblDocumentRevisionLog` (`revisionID`, `status`, `comment`, `date`, `userID`) ".
|
||||
"VALUES ('". $revisionID ."', '0', '', CURRENT_TIMESTAMP, '". $requestUser->getID() ."')";
|
||||
$res = $db->getResult($queryStr);
|
||||
if (is_bool($res) && !$res) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
} /* }}} */
|
||||
|
||||
function addGrpReviser($group, $requestUser) { /* {{{ */
|
||||
$db = $this->_document->_dms->getDB();
|
||||
|
||||
$groupID = $group->getID();
|
||||
|
||||
// Get the list of users and groups with read access to this document.
|
||||
if (!isset($this->_readAccessList)) {
|
||||
// TODO: error checking.
|
||||
$this->_readAccessList = $this->_document->getReadAccessList();
|
||||
}
|
||||
$approved = false;
|
||||
foreach ($this->_readAccessList["groups"] as $appGroup) {
|
||||
if ($groupID == $appGroup->getID()) {
|
||||
$approved = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$approved) {
|
||||
return -2;
|
||||
}
|
||||
|
||||
// Check to see if the group has already been added to the review list.
|
||||
$revisionStatus = $group->getRevisionStatus($this->_document->getID(), $this->_version);
|
||||
if (is_bool($revisionStatus) && !$revisionStatus) {
|
||||
return -1;
|
||||
}
|
||||
$status = false;
|
||||
if (count($revisionStatus["status"]) > 0) {
|
||||
$status = array_pop($revisionStatus["status"]);
|
||||
if($status["status"]!=-2) {
|
||||
// User is already on the list of recipients; return an error.
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
|
||||
// Add the group into the recipients database.
|
||||
if (!$status || ($status && $status["status"]!=-2)) {
|
||||
$queryStr = "INSERT INTO `tblDocumentRevisers` (`documentID`, `version`, `type`, `required`) ".
|
||||
"VALUES ('". $this->_document->getID() ."', '". $this->_version ."', '1', '". $groupID ."')";
|
||||
$res = $db->getResult($queryStr);
|
||||
if (is_bool($res) && !$res) {
|
||||
return -1;
|
||||
}
|
||||
$revisionID = $db->getInsertID();
|
||||
}
|
||||
else {
|
||||
$revisionID = isset($status["revisionID"]) ? $status["revisionID"] : NULL;
|
||||
}
|
||||
|
||||
$queryStr = "INSERT INTO `tblDocumentRevisionLog` (`revisionID`, `status`, `comment`, `date`, `userID`) ".
|
||||
"VALUES ('". $revisionID ."', '0', '', CURRENT_TIMESTAMP, '". $requestUser->getID() ."')";
|
||||
$res = $db->getResult($queryStr);
|
||||
if (is_bool($res) && !$res) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Add a receipt to the document content
|
||||
*
|
||||
|
@ -3521,6 +3685,113 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
}
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Add a revision to the document content
|
||||
*
|
||||
* This method will add an entry to the table tblDocumentRevisionLog.
|
||||
* It will first check if the user is ment to revision the document version.
|
||||
* It not the return value is -3.
|
||||
* Next it will check if the users has been removed from the list of
|
||||
* recipients. In that case -4 will be returned.
|
||||
* If the given revision has been set by the user before, it cannot
|
||||
* be set again and 0 will be returned. Іf the review could be succesfully
|
||||
* added, the review log id will be returned.
|
||||
*
|
||||
* @see SeedDMS_Core_DocumentContent::setApprovalByInd()
|
||||
* @param object $user user doing the revision
|
||||
* @param object $requestUser user asking for the revision, this is mostly
|
||||
* @param integer $status the status of the revision, possible values are
|
||||
* 0=unprocessed (maybe used to reset a status)
|
||||
* 1=received,
|
||||
* -2=user is deleted (use {link
|
||||
* SeedDMS_Core_DocumentContent::delIndRecipient} instead)
|
||||
* the user currently logged in.
|
||||
* @return integer new revision log id
|
||||
*/
|
||||
function setRevisionByInd($user, $requestUser, $status, $comment) { /* {{{ */
|
||||
$db = $this->_document->_dms->getDB();
|
||||
|
||||
// Check to see if the user can be removed from the review list.
|
||||
$revisionStatus = $user->getRevisionStatus($this->_document->getID(), $this->_version);
|
||||
if (is_bool($revisionStatus) && !$revisionStatus) {
|
||||
return -1;
|
||||
}
|
||||
if (count($revisionStatus["indstatus"])==0) {
|
||||
// User is not assigned to revision this document. No action required.
|
||||
// Return an error.
|
||||
return -3;
|
||||
}
|
||||
$indstatus = array_pop($revisionStatus["indstatus"]);
|
||||
if ($indstatus["status"]==-2) {
|
||||
// User has been deleted from recipients
|
||||
return -4;
|
||||
}
|
||||
// Check if the status is really different from the current status
|
||||
if ($indstatus["status"] == $status)
|
||||
return 0;
|
||||
|
||||
$queryStr = "INSERT INTO `tblDocumentRevisionLog` (`revisionID`, `status`,
|
||||
`comment`, `date`, `userID`) ".
|
||||
"VALUES ('". $indstatus["revisionID"] ."', '".
|
||||
(int) $status ."', ".$db->qstr($comment).", CURRENT_TIMESTAMP, '".
|
||||
$requestUser->getID() ."')";
|
||||
$res=$db->getResult($queryStr);
|
||||
if (is_bool($res) && !$res)
|
||||
return -1;
|
||||
else {
|
||||
$revisionLogID = $db->getInsertID();
|
||||
return $revisionLogID;
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Add a revision to the document content
|
||||
*
|
||||
* This method is similar to
|
||||
* {@see SeedDMS_Core_DocumentContent::setRevisionByInd()} but adds a revision
|
||||
* for a group instead of a user.
|
||||
*
|
||||
* @param object $group group doing the revision
|
||||
* @param object $requestUser user asking for the revision, this is mostly
|
||||
* the user currently logged in.
|
||||
* @return integer new revision log id
|
||||
*/
|
||||
function setRevisionByGrp($group, $requestUser, $status, $comment) { /* {{{ */
|
||||
$db = $this->_document->_dms->getDB();
|
||||
|
||||
// Check to see if the user can be removed from the recipient list.
|
||||
$revisionStatus = $group->getRevisionStatus($this->_document->getID(), $this->_version);
|
||||
if (is_bool($revisionStatus) && !$revisionStatus) {
|
||||
return -1;
|
||||
}
|
||||
if (count($revisionStatus)==0) {
|
||||
// User is not assigned to revision this document. No action required.
|
||||
// Return an error.
|
||||
return -3;
|
||||
}
|
||||
if ($revisionStatus[0]["status"]==-2) {
|
||||
// Group has been deleted from recipients
|
||||
return -4;
|
||||
}
|
||||
|
||||
// Check if the status is really different from the current status
|
||||
if ($revisionStatus[0]["status"] == $status)
|
||||
return 0;
|
||||
|
||||
$queryStr = "INSERT INTO `tblDocumentRevisionLog` (`recipientsID`, `status`,
|
||||
`comment`, `date`, `userID`) ".
|
||||
"VALUES ('". $revisionStatus[0]["recipientsID"] ."', '".
|
||||
(int) $status ."', ".$db->qstr($comment).", CURRENT_TIMESTAMP, '".
|
||||
$requestUser->getID() ."')";
|
||||
$res=$db->getResult($queryStr);
|
||||
if (is_bool($res) && !$res)
|
||||
return -1;
|
||||
else {
|
||||
$revisionLogID = $db->getInsertID();
|
||||
return $revisionLogID;
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
function delIndReviewer($user, $requestUser) { /* {{{ */
|
||||
$db = $this->_document->_dms->getDB();
|
||||
|
||||
|
@ -3653,7 +3924,7 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
$userID = $user->getID();
|
||||
|
||||
// Check to see if the user can be removed from the recipient list.
|
||||
$receiptStatus = $user->getReceiptStatus($this->_document->getID(), $this->_version);
|
||||
$revisionStatus = $user->getReceiptStatus($this->_document->getID(), $this->_version);
|
||||
if (is_bool($receiptStatus) && !$receiptStatus) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -3711,6 +3982,70 @@ class SeedDMS_Core_DocumentContent extends SeedDMS_Core_Object { /* {{{ */
|
|||
return 0;
|
||||
} /* }}} */
|
||||
|
||||
function delIndReviser($user, $requestUser) { /* {{{ */
|
||||
$db = $this->_document->_dms->getDB();
|
||||
|
||||
$userID = $user->getID();
|
||||
|
||||
// Check to see if the user can be removed from the reviser list.
|
||||
$revisionStatus = $user->getRevisionStatus($this->_document->getID(), $this->_version);
|
||||
if (is_bool($revisionStatus) && !$revisionStatus) {
|
||||
return -1;
|
||||
}
|
||||
if (count($revisionStatus["indstatus"])==0) {
|
||||
// User is not assigned to revision this document. No action required.
|
||||
// Return an error.
|
||||
return -3;
|
||||
}
|
||||
$indstatus = array_pop($revisionStatus["indstatus"]);
|
||||
if ($indstatus["status"]!=0) {
|
||||
// User has already submitted a revision or has already been deleted;
|
||||
// return an error.
|
||||
return -3;
|
||||
}
|
||||
|
||||
$queryStr = "INSERT INTO `tblDocumentRevisionLog` (`revisionID`, `status`, `comment`, `date`, `userID`) ".
|
||||
"VALUES ('". $indstatus["revisionID"] ."', '-2', '', CURRENT_TIMESTAMP, '". $requestUser->getID() ."')";
|
||||
$res = $db->getResult($queryStr);
|
||||
if (is_bool($res) && !$res) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
} /* }}} */
|
||||
|
||||
function delGrpReviser($group, $requestUser) { /* {{{ */
|
||||
$db = $this->_document->_dms->getDB();
|
||||
|
||||
$groupID = $group->getID();
|
||||
|
||||
// Check to see if the user can be removed from the reviser list.
|
||||
$revisionStatus = $group->getRevisionStatus($this->_document->getID(), $this->_version);
|
||||
if (is_bool($revisionStatus) && !$revisionStatus) {
|
||||
return -1;
|
||||
}
|
||||
if (count($revisionStatus["status"])==0) {
|
||||
// User is not assigned to revision this document. No action required.
|
||||
// Return an error.
|
||||
return -3;
|
||||
}
|
||||
$status = array_pop($revisionStatus["status"]);
|
||||
if ($tatus["status"]!=0) {
|
||||
// User has already submitted a revision or has already been deleted;
|
||||
// return an error.
|
||||
return -3;
|
||||
}
|
||||
|
||||
$queryStr = "INSERT INTO `tblDocumentRevisionLog` (`revisionID`, `status`, `comment`, `date`, `userID`) ".
|
||||
"VALUES ('". $status["revisionID"] ."', '-2', '', CURRENT_TIMESTAMP, '". $requestUser->getID() ."')";
|
||||
$res = $db->getResult($queryStr);
|
||||
if (is_bool($res) && !$res) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Set state of workflow assigned to the document content
|
||||
*
|
||||
|
|
|
@ -310,6 +310,28 @@ class SeedDMS_Core_Group {
|
|||
}
|
||||
}
|
||||
|
||||
$receiptStatus = $this->getReceiptStatus();
|
||||
foreach ($receiptStatus as $r) {
|
||||
$queryStr = "INSERT INTO `tblDocumentReceiptLog` (`receiptID`, `status`, `comment`, `date`, `userID`) ".
|
||||
"VALUES ('". $r["receiptID"] ."', '-2', 'Recipients group removed from process', CURRENT_TIMESTAMP, '". $user->getID() ."')";
|
||||
$res=$db->getResult($queryStr);
|
||||
if(!$res) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$revisionStatus = $this->getRevisionStatus();
|
||||
foreach ($revisionStatus as $r) {
|
||||
$queryStr = "INSERT INTO `tblDocumentRevisionLog` (`revisionID`, `status`, `comment`, `date`, `userID`) ".
|
||||
"VALUES ('". $r["revisionID"] ."', '-2', 'Revisers group removed from process', CURRENT_TIMESTAMP, '". $user->getID() ."')";
|
||||
$res=$db->getResult($queryStr);
|
||||
if(!$res) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$db->commitTransaction();
|
||||
|
||||
return true;
|
||||
|
@ -410,5 +432,37 @@ class SeedDMS_Core_Group {
|
|||
return $status;
|
||||
} /* }}} */
|
||||
|
||||
function getRevisionStatus($documentID=null, $version=null) { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
|
||||
$status = array();
|
||||
|
||||
// See if the group is assigned as a reviser.
|
||||
$queryStr = "SELECT `tblDocumentRevisers`.*, `tblDocumentRevisionLog`.`status`, ".
|
||||
"`tblDocumentRevisionLog`.`comment`, `tblDocumentRevisionLog`.`date`, ".
|
||||
"`tblDocumentRevisionLog`.`userID` ".
|
||||
"FROM `tblDocumentRevisers` ".
|
||||
"LEFT JOIN `tblDocumentRevisionLog` USING (`revisionID`) ".
|
||||
"WHERE `tblDocumentRevisers`.`type`='1' ".
|
||||
($documentID==null ? "" : "AND `tblDocumentRevisers`.`documentID` = '". (int) $documentID ."' ").
|
||||
($version==null ? "" : "AND `tblDocumentRevisers`.`version` = '". (int) $version ."' ").
|
||||
"AND `tblDocumentRevisers`.`required`='". $this->_id ."' ";
|
||||
$resArr = $db->getResultArray($queryStr);
|
||||
if (is_bool($resArr) && $resArr == false)
|
||||
return false;
|
||||
if (count($resArr)>0) {
|
||||
foreach ($resArr as $res) {
|
||||
if(isset($status["status"][$res['documentID']])) {
|
||||
if($status["status"][$res['documentID']]['date'] < $res['date']) {
|
||||
$status["status"][$res['documentID']] = $res;
|
||||
}
|
||||
} else {
|
||||
$status["status"][$res['documentID']] = $res;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $status;
|
||||
} /* }}} */
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -686,6 +686,28 @@ class SeedDMS_Core_User {
|
|||
}
|
||||
}
|
||||
|
||||
$receiptStatus = $this->getReceiptStatus();
|
||||
foreach ($receiptStatus["indstatus"] as $ri) {
|
||||
$queryStr = "INSERT INTO `tblDocumentReceiptLog` (`receiptID`, `status`, `comment`, `date`, `userID`) ".
|
||||
"VALUES ('". $ri["receiptID"] ."', '-2', 'Recipient removed from process', CURRENT_TIMESTAMP, '". $user->getID() ."')";
|
||||
$res=$db->getResult($queryStr);
|
||||
if(!$res) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$revisionStatus = $this->getRevisionStatus();
|
||||
foreach ($revisionStatus["indstatus"] as $ri) {
|
||||
$queryStr = "INSERT INTO `tblDocumentRevisionLog` (`revisionID`, `status`, `comment`, `date`, `userID`) ".
|
||||
"VALUES ('". $ri["revisionID"] ."', '-2', 'Reviser removed from process', CURRENT_TIMESTAMP, '". $user->getID() ."')";
|
||||
$res=$db->getResult($queryStr);
|
||||
if(!$res) {
|
||||
$db->rollbackTransaction();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$db->commitTransaction();
|
||||
return true;
|
||||
} /* }}} */
|
||||
|
@ -901,11 +923,6 @@ class SeedDMS_Core_User {
|
|||
function getReviewStatus($documentID=null, $version=null) { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
|
||||
/*
|
||||
if (!$db->createTemporaryTable("ttreviewid")) {
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
$status = array("indstatus"=>array(), "grpstatus"=>array());
|
||||
|
||||
// See if the user is assigned as an individual reviewer.
|
||||
|
@ -995,27 +1012,7 @@ 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.
|
||||
/*
|
||||
$queryStr = "SELECT `tblDocumentApprovers`.*, `tblDocumentApproveLog`.`status`, ".
|
||||
"`tblDocumentApproveLog`.`comment`, `tblDocumentApproveLog`.`date`, ".
|
||||
"`tblDocumentApproveLog`.`userID` ".
|
||||
"FROM `tblDocumentApprovers` ".
|
||||
"LEFT JOIN `tblDocumentApproveLog` USING (`approveID`) ".
|
||||
"LEFT JOIN `ttapproveid` on `ttapproveid`.`maxLogID` = `tblDocumentApproveLog`.`approveLogID` ".
|
||||
"WHERE `ttapproveid`.`maxLogID`=`tblDocumentApproveLog`.`approveLogID` ".
|
||||
($documentID==null ? "" : "AND `tblDocumentApprovers`.`documentID` = '". $documentID ."' ").
|
||||
($version==null ? "" : "AND `tblDocumentApprovers`.`version` = '". $version ."' ").
|
||||
"AND `tblDocumentApprovers`.`type`='0' ".
|
||||
"AND `tblDocumentApprovers`.`required`='". $this->_id ."' ";
|
||||
*/
|
||||
$queryStr =
|
||||
"SELECT `tblDocumentApprovers`.*, `tblDocumentApproveLog`.`status`, ".
|
||||
"`tblDocumentApproveLog`.`comment`, `tblDocumentApproveLog`.`date`, ".
|
||||
|
@ -1045,20 +1042,6 @@ class SeedDMS_Core_User {
|
|||
|
||||
// See if the user is the member of a group that has been assigned to
|
||||
// approve the document version.
|
||||
/*
|
||||
$queryStr = "SELECT `tblDocumentApprovers`.*, `tblDocumentApproveLog`.`status`, ".
|
||||
"`tblDocumentApproveLog`.`comment`, `tblDocumentApproveLog`.`date`, ".
|
||||
"`tblDocumentApproveLog`.`userID` ".
|
||||
"FROM `tblDocumentApprovers` ".
|
||||
"LEFT JOIN `tblDocumentApproveLog` USING (`approveID`) ".
|
||||
"LEFT JOIN `tblGroupMembers` ON `tblGroupMembers`.`groupID` = `tblDocumentApprovers`.`required` ".
|
||||
"LEFT JOIN `ttapproveid` on `ttapproveid`.`maxLogID` = `tblDocumentApproveLog`.`approveLogID` ".
|
||||
"WHERE `ttapproveid`.`maxLogID`=`tblDocumentApproveLog`.`approveLogID` ".
|
||||
($documentID==null ? "" : "AND `tblDocumentApprovers`.`documentID` = '". $documentID ."' ").
|
||||
($version==null ? "" : "AND `tblDocumentApprovers`.`version` = '". $version ."' ").
|
||||
"AND `tblDocumentApprovers`.`type`='1' ".
|
||||
"AND `tblGroupMembers`.`userID`='". $this->_id ."'";
|
||||
*/
|
||||
$queryStr =
|
||||
"SELECT `tblDocumentApprovers`.*, `tblDocumentApproveLog`.`status`, ".
|
||||
"`tblDocumentApproveLog`.`comment`, `tblDocumentApproveLog`.`date`, ".
|
||||
|
@ -1108,11 +1091,6 @@ class SeedDMS_Core_User {
|
|||
function getReceiptStatus($documentID=null, $version=null) { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
|
||||
/*
|
||||
if (!$db->createTemporaryTable("ttreviewid")) {
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
$status = array("indstatus"=>array(), "grpstatus"=>array());
|
||||
|
||||
// See if the user is assigned as an individual recipient.
|
||||
|
@ -1171,6 +1149,84 @@ class SeedDMS_Core_User {
|
|||
return $status;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Get a list of revisions
|
||||
* This function returns a list of all revisions seperated by individual
|
||||
* and group revisions. If the document id
|
||||
* is passed, then only this document will be checked for revisions. The
|
||||
* same is true for the version of a document which limits the list
|
||||
* further.
|
||||
*
|
||||
* For a detaile description of the result array see
|
||||
* {link SeedDMS_Core_User::getApprovalStatus} which does the same for
|
||||
* approvals.
|
||||
*
|
||||
* @param int $documentID optional document id for which to retrieve the
|
||||
* revisions
|
||||
* @param int $version optional version of the document
|
||||
* @return array list of all revisions
|
||||
*/
|
||||
function getRevisionStatus($documentID=null, $version=null) { /* {{{ */
|
||||
$db = $this->_dms->getDB();
|
||||
|
||||
$status = array("indstatus"=>array(), "grpstatus"=>array());
|
||||
|
||||
// See if the user is assigned as an individual reviser.
|
||||
$queryStr = "SELECT `tblDocumentRevisers`.*, `tblDocumentRevisionLog`.`status`, ".
|
||||
"`tblDocumentRevisionLog`.`comment`, `tblDocumentRevisionLog`.`date`, ".
|
||||
"`tblDocumentRevisionLog`.`userID` ".
|
||||
"FROM `tblDocumentRevisers` ".
|
||||
"LEFT JOIN `tblDocumentRevisionLog` USING (`revisionID`) ".
|
||||
"WHERE `tblDocumentRevisers`.`type`='0' ".
|
||||
($documentID==null ? "" : "AND `tblDocumentRevisers`.`documentID` = '". (int) $documentID ."' ").
|
||||
($version==null ? "" : "AND `tblDocumentRevisers`.`version` = '". (int) $version ."' ").
|
||||
"AND `tblDocumentRevisers`.`required`='". $this->_id ."' ".
|
||||
"ORDER BY `tblDocumentRevisionLog`.`revisionLogID` DESC";
|
||||
$resArr = $db->getResultArray($queryStr);
|
||||
if (is_bool($resArr) && $resArr === false)
|
||||
return false;
|
||||
if (count($resArr)>0) {
|
||||
foreach ($resArr as $res) {
|
||||
if(isset($status["indstatus"][$res['documentID']])) {
|
||||
if($status["indstatus"][$res['documentID']]['date'] < $res['date']) {
|
||||
$status["indstatus"][$res['documentID']] = $res;
|
||||
}
|
||||
} else {
|
||||
$status["indstatus"][$res['documentID']] = $res;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// See if the user is the member of a group that has been assigned to
|
||||
// revision the document version.
|
||||
$queryStr = "SELECT `tblDocumentRevisers`.*, `tblDocumentRevisionLog`.`status`, ".
|
||||
"`tblDocumentRevisionLog`.`comment`, `tblDocumentRevisionLog`.`date`, ".
|
||||
"`tblDocumentRevisionLog`.`userID` ".
|
||||
"FROM `tblDocumentRevisers` ".
|
||||
"LEFT JOIN `tblDocumentRevisionLog` USING (`revisionID`) ".
|
||||
"LEFT JOIN `tblGroupMembers` ON `tblGroupMembers`.`groupID` = `tblDocumentRevisers`.`required` ".
|
||||
"WHERE `tblDocumentRevisers`.`type`='1' ".
|
||||
($documentID==null ? "" : "AND `tblDocumentRevisers`.`documentID` = '". (int) $documentID ."' ").
|
||||
($version==null ? "" : "AND `tblDocumentRevisers`.`version` = '". (int) $version ."' ").
|
||||
"AND `tblGroupMembers`.`userID`='". $this->_id ."' ".
|
||||
"ORDER BY `tblDocumentRevisionLog`.`revisionLogID` DESC";
|
||||
$resArr = $db->getResultArray($queryStr);
|
||||
if (is_bool($resArr) && $resArr === false)
|
||||
return false;
|
||||
if (count($resArr)>0) {
|
||||
foreach ($resArr as $res) {
|
||||
if(isset($status["grpstatus"][$res['documentID']])) {
|
||||
if($status["grpstatus"][$res['documentID']]['date'] < $res['date']) {
|
||||
$status["grpstatus"][$res['documentID']] = $res;
|
||||
}
|
||||
} else {
|
||||
$status["grpstatus"][$res['documentID']] = $res;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $status;
|
||||
} /* }}} */
|
||||
|
||||
/**
|
||||
* Get a list of documents with a workflow
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue
Block a user