diff --git a/SeedDMS_Core/Core/inc.ClassDMS.php b/SeedDMS_Core/Core/inc.ClassDMS.php
index f240e39cd..922f9e918 100644
--- a/SeedDMS_Core/Core/inc.ClassDMS.php
+++ b/SeedDMS_Core/Core/inc.ClassDMS.php
@@ -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;
diff --git a/SeedDMS_Core/package.xml b/SeedDMS_Core/package.xml
index d9c5cccf7..fb059f999 100644
--- a/SeedDMS_Core/package.xml
+++ b/SeedDMS_Core/package.xml
@@ -12,7 +12,7 @@
uwe@steinmann.cx
yes
- 2021-01-27
+ 2021-03-15
5.1.22
@@ -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