diff --git a/SeedDMS_Core/Core/inc.ClassDMS.php b/SeedDMS_Core/Core/inc.ClassDMS.php index bf79f62ac..616c5c248 100644 --- a/SeedDMS_Core/Core/inc.ClassDMS.php +++ b/SeedDMS_Core/Core/inc.ClassDMS.php @@ -870,6 +870,7 @@ class SeedDMS_Core_DMS { * @param string $param2 set to true * if 'AppRevByMe', 'ReviseByMe', 'ReceiptByMe' shall return even documents * І have already taken care of. + * if 'ExpiredOwner' contains the date in days or as 'yyyy-mm-dd' * @param string $param3 sort list by this field * @param string $param4 order direction * @return array list of documents records @@ -1402,6 +1403,42 @@ class SeedDMS_Core_DMS { $queryStr = ''; } break; // }}} + case 'ExpiredOwner': // Documents expired and owned by me {{{ + if(is_int($param2)) { + $ts = mktime(0, 0, 0) + $param2 * 86400; + } elseif(is_string($param2)) { + $tmp = explode('-', $param2, 3); + if(count($tmp) != 3) + return false; + $ts = mktime(0, 0, 0, $tmp[1], $tmp[2], $tmp[0]); + } else + $ts = mktime(0, 0, 0)-365*86400; /* Start of today - 1 year */ + + $tsnow = mktime(0, 0, 0); /* Start of today */ + if($ts < $tsnow) { /* Check for docs expired in the past */ + $startts = $ts; + $endts = $tsnow+86400; /* Use end of day */ + } else { /* Check for docs which will expire in the future */ + $startts = $tsnow; + $endts = $ts+86400; /* Use end of day */ + } + + $queryStr .= + "WHERE `tblDocuments`.`expires` > ".$startts." AND `tblDocuments`.`expires` < ".$endts." "; + + $user = $param1; + $orderby = $param3; + if($param4 == 'desc') + $orderdir = 'DESC'; + else + $orderdir = 'ASC'; + $queryStr .= "AND `tblDocuments`.`owner` = '".$user->getID()."' "; + if ($orderby=='e') $queryStr .= "ORDER BY `expires`"; + else if ($orderby=='u') $queryStr .= "ORDER BY `statusDate`"; + else if ($orderby=='s') $queryStr .= "ORDER BY `status`"; + else $queryStr .= "ORDER BY `name`"; + $queryStr .= " ".$orderdir; + break; // }}} case 'WorkflowOwner': // Documents waiting for workflow trigger I'm owning {{{ $queryStr .= "WHERE 1=1 ";