SeedDMS_Core_DMS::search() support searching for date of last document status change

This commit is contained in:
Uwe Steinmann 2021-03-15 16:07:57 +01:00
parent 4ef7d3b06e
commit b103d9f30d
2 changed files with 31 additions and 10 deletions

View File

@ -1462,7 +1462,7 @@ class SeedDMS_Core_DMS {
if(is_array($query)) {
foreach(array('limit', 'offset', 'logicalmode', 'searchin', 'startFolder', 'owner', 'status', 'creationstartdate', 'creationenddate', 'modificationstartdate', 'modificationenddate', 'categories', 'attributes', 'mode', 'expirationstartdate', 'expirationenddate') as $paramname)
${$paramname} = isset($query[$paramname]) ? $query[$paramname] : ${$paramname};
foreach(array('orderby') as $paramname)
foreach(array('orderby', 'statusstartdate', 'statusenddate') as $paramname)
${$paramname} = isset($query[$paramname]) ? $query[$paramname] : '';
$query = isset($query['query']) ? $query['query'] : '';
}
@ -1558,7 +1558,7 @@ class SeedDMS_Core_DMS {
if ($creationstartdate) {
$startdate = SeedDMS_Core_DMS::makeTimeStamp($creationstartdate['hour'], $creationstartdate['minute'], $creationstartdate['second'], $creationstartdate['year'], $creationstartdate["month"], $creationstartdate["day"]);
if ($startdate) {
$searchCreateDate .= "`tblFolders`.`date` >= ".$startdate;
$searchCreateDate .= "`tblFolders`.`date` >= ".$this->db->qstr($startdate);
}
}
if ($creationenddate) {
@ -1567,7 +1567,7 @@ class SeedDMS_Core_DMS {
/** @noinspection PhpUndefinedVariableInspection */
if($startdate)
$searchCreateDate .= " AND ";
$searchCreateDate .= "`tblFolders`.`date` <= ".$stopdate;
$searchCreateDate .= "`tblFolders`.`date` <= ".$this->db->qstr($stopdate);
}
}
@ -1772,7 +1772,7 @@ class SeedDMS_Core_DMS {
if ($creationstartdate) {
$startdate = SeedDMS_Core_DMS::makeTimeStamp($creationstartdate['hour'], $creationstartdate['minute'], $creationstartdate['second'], $creationstartdate['year'], $creationstartdate["month"], $creationstartdate["day"]);
if ($startdate) {
$searchCreateDate .= "`tblDocuments`.`date` >= ".$startdate;
$searchCreateDate .= "`tblDocuments`.`date` >= ".$this->db->qstr($startdate);
}
}
if ($creationenddate) {
@ -1780,7 +1780,7 @@ class SeedDMS_Core_DMS {
if ($stopdate) {
if($searchCreateDate)
$searchCreateDate .= " AND ";
$searchCreateDate .= "`tblDocuments`.`date` <= ".$stopdate;
$searchCreateDate .= "`tblDocuments`.`date` <= ".$this->db->qstr($stopdate);
}
}
if ($modificationstartdate) {
@ -1796,7 +1796,7 @@ class SeedDMS_Core_DMS {
if ($stopdate) {
if($searchCreateDate)
$searchCreateDate .= " AND ";
$searchCreateDate .= "`tblDocumentContent`.`date` <= ".$stopdate;
$searchCreateDate .= "`tblDocumentContent`.`date` <= ".$this->db->qstr($stopdate);
}
}
$searchExpirationDate = '';
@ -1805,7 +1805,7 @@ class SeedDMS_Core_DMS {
if ($startdate) {
if($searchExpirationDate)
$searchExpirationDate .= " AND ";
$searchExpirationDate .= "`tblDocuments`.`expires` >= ".$startdate;
$searchExpirationDate .= "`tblDocuments`.`expires` >= ".$this->db->qstr($startdate);
}
}
if ($expirationenddate) {
@ -1813,7 +1813,24 @@ class SeedDMS_Core_DMS {
if ($stopdate) {
if($searchExpirationDate)
$searchExpirationDate .= " AND ";
$searchExpirationDate .= "`tblDocuments`.`expires` <= ".$stopdate;
$searchExpirationDate .= "`tblDocuments`.`expires` <= ".$this->db->qstr($stopdate);
}
}
$searchStatusDate = '';
if ($statusstartdate) {
$startdate = $statusstartdate['year'].'-'.$statusstartdate["month"].'-'.$statusstartdate["day"].' '.$statusstartdate['hour'].':'.$statusstartdate['minute'].':'.$statusstartdate['second'];
if ($startdate) {
if($searchStatusDate)
$searchStatusDate .= " AND ";
$searchStatusDate .= "`tblDocumentStatusLog`.`date` >= ".$this->db->qstr($startdate);
}
}
if ($statusenddate) {
$stopdate = $statusenddate['year'].'-'.$statusenddate["month"].'-'.$statusenddate["day"].' '.$statusenddate['hour'].':'.$statusenddate['minute'].':'.$statusenddate['second'];
if ($stopdate) {
if($searchStatusDate)
$searchStatusDate .= " AND ";
$searchStatusDate .= "`tblDocumentStatusLog`.`date` <= ".$this->db->qstr($stopdate);
}
}
@ -1859,6 +1876,9 @@ class SeedDMS_Core_DMS {
if (strlen($searchExpirationDate)>0) {
$searchQuery .= " AND (".$searchExpirationDate.")";
}
if (strlen($searchStatusDate)>0) {
$searchQuery .= " AND (".$searchStatusDate.")";
}
if ($searchAttributes) {
$searchQuery .= " AND (".implode(" AND ", $searchAttributes).")";
}
@ -1868,7 +1888,7 @@ class SeedDMS_Core_DMS {
$searchQuery .= " AND `tblDocumentStatusLog`.`status` IN (".implode(',', $status).")";
}
if($searchKey || $searchOwner || $searchCategories || $searchCreateDate || $searchExpirationDate || $searchAttributes || $status) {
if($searchKey || $searchOwner || $searchCategories || $searchCreateDate || $searchExpirationDate || $searchStatusDate || $searchAttributes || $status) {
// Count the number of rows that the search will produce.
$resArr = $this->db->getResultArray("SELECT COUNT(*) AS num FROM (SELECT DISTINCT `tblDocuments`.`id` ".$searchQuery.") a");
$totalDocs = 0;

View File

@ -12,7 +12,7 @@
<email>uwe@steinmann.cx</email>
<active>yes</active>
</lead>
<date>2021-01-27</date>
<date>2021-03-15</date>
<time>13:44:55</time>
<version>
<release>5.1.22</release>
@ -30,6 +30,7 @@
- add new parameter to SeedDMS_Core_DMS->getDocumentList() for skipping expired documents
- add parameter $incdisabled to SeedDMS_Core_Folder::getNotifyList()
- do not validate value in SeedDMS_Core_Attribute::setValue(), it should have been done before
- SeedDMS_Core_DMS::search() can search for last date of document status change
</notes>
<contents>
<dir baseinstalldir="SeedDMS" name="/">