* @copyright Copyright (C) 2002-2005 Markus Westphal, * 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli, * 2010-2012 Uwe Steinmann * @version Release: @package_version@ */ /** * Include parent class */ require_once("class.BlueStyle.php"); /** * Class which outputs the html page for ApprovalSummary view * * @category DMS * @package LetoDMS * @author Markus Westphal, Malcolm Cowe, Uwe Steinmann * @copyright Copyright (C) 2002-2005 Markus Westphal, * 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli, * 2010-2012 Uwe Steinmann * @version Release: @package_version@ */ class LetoDMS_View_ApprovalSummary extends LetoDMS_Blue_Style { function show() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; $db = $dms->getDB(); $this->htmlStartPage(getMLText("approval_summary")); $this->globalNavigation(); $this->pageNavigation(getMLText("my_documents"), "my_documents"); $this->contentHeading(getMLText("approval_summary")); $this->contentContainerStart(); if (!$db->createTemporaryTable("ttstatid")) { $this->exitError(getMLText("approval_summary"),getMLText("internal_error_exit")); } // TODO: verificare scadenza // Get document list for the current user. $approvalStatus = $user->getApprovalStatus(); // reverse order $approvalStatus["indstatus"]=array_reverse($approvalStatus["indstatus"],true); $approvalStatus["grpstatus"]=array_reverse($approvalStatus["grpstatus"],true); // Create a comma separated list of all the documentIDs whose information is // required. $dList = array(); foreach ($approvalStatus["indstatus"] as $st) { if (!in_array($st["documentID"], $dList)) { $dList[] = $st["documentID"]; } } foreach ($approvalStatus["grpstatus"] as $st) { if (!in_array($st["documentID"], $dList)) { $dList[] = $st["documentID"]; } } $docCSV = ""; foreach ($dList as $d) { $docCSV .= (strlen($docCSV)==0 ? "" : ", ")."'".$d."'"; } if (strlen($docCSV)>0) { $queryStr = "SELECT `tblDocuments`.*, `tblDocumentLocks`.`userID` as `lockUser`, ". "`tblDocumentStatus`.*, `tblDocumentStatusLog`.`status`, ". "`tblDocumentStatusLog`.`comment` AS `statusComment`, `tblDocumentStatusLog`.`date` as `statusDate`, ". "`tblDocumentStatusLog`.`userID`, `oTbl`.`fullName` AS `ownerName`, `sTbl`.`fullName` AS `statusName` ". "FROM `tblDocumentStatus` ". "LEFT JOIN `tblDocumentStatusLog` USING (`statusID`) ". "LEFT JOIN `ttstatid` on `ttstatid`.`maxLogID` = `tblDocumentStatusLog`.`statusLogID` ". "LEFT JOIN `tblDocuments` ON `tblDocuments`.`id` = `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 `tblDocuments`.`id` IN (" . $docCSV . ") ". "ORDER BY `statusDate` DESC"; $resArr = $db->getResultArray($queryStr); if (is_bool($resArr) && !$resArr) { $this->exitError(getMLText("approval_summary"),getMLText("internal_error_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_DRAFT_APP || $res["status"]==S_DRAFT_REV ){ $res["status"]=S_EXPIRED; } } $docIdx[$res["id"]][$res["version"]] = $res; } } $iRev = array(); $printheader = true; foreach ($approvalStatus["indstatus"] as $st) { if (isset($docIdx[$st["documentID"]][$st["version"]])) { 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"; print ""; print ""; print ""; print ""; print ""; print ""; print "\n"; } if ($st["status"]!=-2) { $iRev[] = $st["documentID"]; } } if (!$printheader) { echo "\n
".getMLText("name")."".getMLText("owner")."".getMLText("status")."".getMLText("version")."".getMLText("last_update")."".getMLText("expires")."
".htmlspecialchars($docIdx[$st["documentID"]][$st["version"]]["name"])."".htmlspecialchars($docIdx[$st["documentID"]][$st["version"]]["ownerName"])."".getOverallStatusText($docIdx[$st["documentID"]][$st["version"]]["status"])."".$st["version"]."".$st["date"]." ". htmlspecialchars($docIdx[$st["documentID"]][$st["version"]]["statusName"]) ."".(!$docIdx[$st["documentID"]][$st["version"]]["expires"] ? "-":getReadableDate($docIdx[$st["documentID"]][$st["version"]]["expires"]))."
\n"; }else{ printMLText("no_approval_needed"); } $this->contentContainerEnd(); $this->contentHeading(getMLText("group_approval_summary")); $this->contentContainerStart(); $printheader = true; foreach ($approvalStatus["grpstatus"] as $st) { if (!in_array($st["documentID"], $iRev) && isset($docIdx[$st["documentID"]][$st["version"]])) { 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"; print ""; print ""; print ""; print ""; print ""; print ""; print "\n"; } } if (!$printheader) { echo "\n
".getMLText("name")."".getMLText("owner")."".getMLText("status")."".getMLText("version")."".getMLText("last_update")."".getMLText("expires")."
".htmlspecialchars($docIdx[$st["documentID"]][$st["version"]]["name"])."".htmlspecialchars($docIdx[$st["documentID"]][$st["version"]]["ownerName"])."".getOverallStatusText($docIdx[$st["documentID"]][$st["version"]]["status"])."".$st["version"]."".$st["date"]." ". htmlspecialchars($docIdx[$st["documentID"]][$st["version"]]["statusName"]) ."".(!$docIdx[$st["documentID"]][$st["version"]]["expires"] ? "-":getReadableDate($docIdx[$st["documentID"]][$st["version"]]["expires"]))."
\n"; }else{ printMLText("empty_notify_list"); } $this->contentContainerEnd(); $this->htmlEndPage(); } /* }}} */ } ?>