diff --git a/views/bootstrap/class.MyDocuments.php b/views/bootstrap/class.MyDocuments.php index 0be5f097d..bccf7c1c4 100644 --- a/views/bootstrap/class.MyDocuments.php +++ b/views/bootstrap/class.MyDocuments.php @@ -395,6 +395,238 @@ class SeedDMS_View_MyDocuments extends SeedDMS_Bootstrap_Style { } else printMLText("no_docs_to_look_at"); + $this->contentContainerEnd(); + } elseif($workflowmode == 'advanced') { + // Get document list for the current user. + $workflowStatus = $user->getWorkflowStatus(); + + // Create a comma separated list of all the documentIDs whose information is + // required. + $dList = array(); + foreach ($workflowStatus["u"] as $st) { + if (!in_array($st["document"], $dList)) { + $dList[] = $st["document"]; + } + } + foreach ($workflowStatus["g"] as $st) { + if (!in_array($st["document"], $dList)) { + $dList[] = $st["document"]; + } + } + $docCSV = ""; + foreach ($dList as $d) { + $docCSV .= (strlen($docCSV)==0 ? "" : ", ")."'".$d."'"; + } + + if (strlen($docCSV)>0) { + // Get the document information. + $queryStr = "SELECT `tblDocuments`.*, `tblDocumentLocks`.`userID` as `lockUser`, ". + "`tblDocumentContent`.`version`, `tblDocumentStatus`.*, `tblDocumentStatusLog`.`status`, ". + "`tblDocumentStatusLog`.`comment` AS `statusComment`, `tblDocumentStatusLog`.`date` as `statusDate`, ". + "`tblDocumentStatusLog`.`userID`, `oTbl`.`fullName` AS `ownerName`, `sTbl`.`fullName` AS `statusName` ". + "FROM `tblDocumentContent` ". + "LEFT JOIN `tblDocuments` ON `tblDocuments`.`id` = `tblDocumentContent`.`document` ". + "LEFT JOIN `tblDocumentStatus` ON `tblDocumentStatus`.`documentID` = `tblDocumentContent`.`document` ". + "LEFT JOIN `tblDocumentStatusLog` ON `tblDocumentStatusLog`.`statusID` = `tblDocumentStatus`.`statusID` ". + "LEFT JOIN `ttstatid` ON `ttstatid`.`maxLogID` = `tblDocumentStatusLog`.`statusLogID` ". + "LEFT JOIN `ttcontentid` ON `ttcontentid`.`maxVersion` = `tblDocumentStatus`.`version` AND `ttcontentid`.`document` = `tblDocumentStatus`.`documentID` ". + "LEFT JOIN `tblDocumentLocks` ON `tblDocuments`.`id`=`tblDocumentLocks`.`document` ". + "LEFT JOIN `tblUsers` AS `oTbl` on `oTbl`.`id` = `tblDocuments`.`owner` ". + "LEFT JOIN `tblUsers` AS `sTbl` on `sTbl`.`id` = `tblDocumentStatusLog`.`userID` ". + "WHERE `ttstatid`.`maxLogID`=`tblDocumentStatusLog`.`statusLogID` ". + "AND `ttcontentid`.`maxVersion` = `tblDocumentContent`.`version` ". + "AND `tblDocumentStatusLog`.`status` IN (".S_IN_WORKFLOW.", ".S_EXPIRED.") ". + "AND `tblDocuments`.`id` IN (" . $docCSV . ") ". + "ORDER BY `statusDate` DESC"; + + $resArr = $db->getResultArray($queryStr); + if (is_bool($resArr) && !$resArr) { + $this->contentHeading(getMLText("warning")); + $this->contentContainer(getMLText("internal_error_exit")); + $this->htmlEndPage(); + exit; + } + + // Create an array to hold all of these results, and index the array by + // document id. This makes it easier to retrieve document ID information + // later on and saves us having to repeatedly poll the database every time + // new document information is required. + $docIdx = array(); + foreach ($resArr as $res) { + + // verify expiry + if ( $res["expires"] && time()>$res["expires"]+24*60*60 ){ + if ( $res["status"]==S_IN_WORKFLOW ){ + $res["status"]=S_EXPIRED; + } + } + + $docIdx[$res["id"]][$res["version"]] = $res; + } + + // List the documents where a review has been requested. + $this->contentHeading(getMLText("documents_to_check")); + $this->contentContainerStart(); + $printheader=true; + $iRev = array(); + $dList = array(); + foreach ($workflowStatus["u"] as $st) { + + if ( isset($docIdx[$st["document"]][$st["version"]]) && !in_array($st["document"], $dList) ) { + $dList[] = $st["document"]; + $document = $dms->getDocument($st["document"]); + + if ($printheader){ + print ""; + print "\n\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n\n\n"; + $printheader=false; + } + + print "\n"; + $latestContent = $document->getLatestContent(); + $previewer->createPreview($latestContent); + print ""; + print ""; + print ""; + print ""; + print ""; + print "".(!$docIdx[$st["document"]][$st["version"]]["expires"] ? "-":getReadableDate($docIdx[$st["document"]][$st["version"]]["expires"])).""; + print "\n"; + } + } + foreach ($workflowStatus["g"] as $st) { + + if (!in_array($st["document"], $iRev) && isset($docIdx[$st["document"]][$st["version"]]) && !in_array($st["document"], $dList) /* && $docIdx[$st["documentID"]][$st["version"]]['owner'] != $user->getId() */) { + $dList[] = $st["document"]; + $document = $dms->getDocument($st["document"]); + + if ($printheader){ + print "
".getMLText("name")."".getMLText("owner")."".getMLText("version")."".getMLText("last_update")."".getMLText("expires")."
"; + if($previewer->hasPreview($latestContent)) { + print "getID()."&version=".$latestContent->getVersion()."&width=".$previewwidth."\" title=\"".htmlspecialchars($latestContent->getMimeType())."\">"; + } else { + print "getMimeIcon($latestContent->getFileType())."\" title=\"".htmlspecialchars($latestContent->getMimeType())."\">"; + } + print "".htmlspecialchars($docIdx[$st["document"]][$st["version"]]["name"])."".htmlspecialchars($docIdx[$st["document"]][$st["version"]]["ownerName"])."".$st["version"]."".$st["date"]." ". htmlspecialchars($docIdx[$st["document"]][$st["version"]]["statusName"]) ."
"; + print "\n\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n\n\n"; + $printheader=false; + } + + print "\n"; + $latestContent = $document->getLatestContent(); + $previewer->createPreview($latestContent); + print ""; + print ""; + print ""; + print ""; + print ""; + print "".(!$docIdx[$st["document"]][$st["version"]]["expires"] ? "-":getReadableDate($docIdx[$st["document"]][$st["version"]]["expires"])).""; + print "\n"; + } + } + if (!$printheader){ + echo "\n
".getMLText("name")."".getMLText("owner")."".getMLText("version")."".getMLText("last_update")."".getMLText("expires")."
"; + if($previewer->hasPreview($latestContent)) { + print "getID()."&version=".$latestContent->getVersion()."&width=".$previewwidth."\" title=\"".htmlspecialchars($latestContent->getMimeType())."\">"; + } else { + print "getMimeIcon($latestContent->getFileType())."\" title=\"".htmlspecialchars($latestContent->getMimeType())."\">"; + } + print "".htmlspecialchars($docIdx[$st["document"]][$st["version"]]["name"])."".htmlspecialchars($docIdx[$st["document"]][$st["version"]]["ownerName"])."".$st["version"]."".$st["date"]." ". htmlspecialchars($docIdx[$st["document"]][$st["version"]]["statusName"])."
"; + }else{ + printMLText("no_docs_to_check"); + } + $this->contentContainerEnd(); + } + + // Get list of documents owned by current user that are pending review or + // pending approval. + $queryStr = "SELECT `tblDocuments`.*, `tblDocumentLocks`.`userID` as `lockUser`, ". + "`tblDocumentContent`.`version`, `tblDocumentStatus`.*, `tblDocumentStatusLog`.`status`, ". + "`tblDocumentStatusLog`.`comment` AS `statusComment`, `tblDocumentStatusLog`.`date` as `statusDate`, ". + "`tblDocumentStatusLog`.`userID`, `oTbl`.`fullName` AS `ownerName`, `sTbl`.`fullName` AS `statusName` ". + "FROM `tblDocumentContent` ". + "LEFT JOIN `tblDocuments` ON `tblDocuments`.`id` = `tblDocumentContent`.`document` ". + "LEFT JOIN `tblDocumentStatus` ON `tblDocumentStatus`.`documentID` = `tblDocumentContent`.`document` ". + "LEFT JOIN `tblDocumentStatusLog` ON `tblDocumentStatusLog`.`statusID` = `tblDocumentStatus`.`statusID` ". + "LEFT JOIN `ttstatid` ON `ttstatid`.`maxLogID` = `tblDocumentStatusLog`.`statusLogID` ". + "LEFT JOIN `ttcontentid` ON `ttcontentid`.`maxVersion` = `tblDocumentStatus`.`version` AND `ttcontentid`.`document` = `tblDocumentStatus`.`documentID` ". + "LEFT JOIN `tblDocumentLocks` ON `tblDocuments`.`id`=`tblDocumentLocks`.`document` ". + "LEFT JOIN `tblUsers` AS `oTbl` on `oTbl`.`id` = `tblDocuments`.`owner` ". + "LEFT JOIN `tblUsers` AS `sTbl` on `sTbl`.`id` = `tblDocumentStatusLog`.`userID` ". + "WHERE `ttstatid`.`maxLogID`=`tblDocumentStatusLog`.`statusLogID` ". + "AND `ttcontentid`.`maxVersion` = `tblDocumentContent`.`version` ". + "AND `tblDocuments`.`owner` = '".$user->getID()."' ". + "AND `tblDocumentStatusLog`.`status` IN (".S_IN_WORKFLOW.") ". + "ORDER BY `statusDate` DESC"; + + $resArr = $db->getResultArray($queryStr); + if (is_bool($resArr) && !$resArr) { + $this->contentHeading(getMLText("warning")); + $this->contentContainer("Internal error. Unable to complete request. Exiting."); + $this->htmlEndPage(); + exit; + } + + $this->contentHeading(getMLText("documents_user_requiring_attention")); + $this->contentContainerStart(); + if (count($resArr)>0) { + + print ""; + print "\n\n"; + print ""; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n"; + print "\n\n\n"; + + foreach ($resArr as $res) { + $document = $dms->getDocument($res["documentID"]); + + // verify expiry + if ( $res["expires"] && time()>$res["expires"]+24*60*60 ){ + if ( $res["status"]==S_DRAFT_APP || $res["status"]==S_DRAFT_REV ){ + $res["status"]=S_EXPIRED; + } + } + + print "\n"; + $latestContent = $document->getLatestContent(); + $previewer->createPreview($latestContent); + print ""; + print "\n"; + print ""; + print ""; + print ""; + print ""; + print "\n"; + } + print "
".getMLText("name")."".getMLText("status")."".getMLText("version")."".getMLText("last_update")."".getMLText("expires")."
"; + if($previewer->hasPreview($latestContent)) { + print "getID()."&version=".$latestContent->getVersion()."&width=".$previewwidth."\" title=\"".htmlspecialchars($latestContent->getMimeType())."\">"; + } else { + print "getMimeIcon($latestContent->getFileType())."\" title=\"".htmlspecialchars($latestContent->getMimeType())."\">"; + } + print "" . htmlspecialchars($res["name"]) . "".getOverallStatusText($res["status"])."".$res["version"]."".$res["statusDate"]." ".htmlspecialchars($res["statusName"])."".(!$res["expires"] ? "-":getReadableDate($res["expires"]))."
"; + + } + else printMLText("no_docs_to_look_at"); + $this->contentContainerEnd(); }