fix search for documents with reception acknowledgement

This commit is contained in:
Uwe Steinmann 2016-11-22 17:58:28 +01:00
parent 662d9d0d85
commit 6cb5dec1a9

View File

@ -1422,9 +1422,14 @@ class SeedDMS_Core_DMS {
// Construct the SQL query that will be used to search the database.
//
if (!$this->db->createTemporaryTable("ttcontentid") || !$this->db->createTemporaryTable("ttstatid") || !$this->db->createTemporaryTable("ttreceiptid")) {
if (!$this->db->createTemporaryTable("ttcontentid") || !$this->db->createTemporaryTable("ttstatid")) {
return false;
}
if($reception) {
if (!$this->db->createTemporaryTable("ttreceiptid")) {
return false;
}
}
$searchQuery = "FROM `tblDocumentContent` ".
"LEFT JOIN `tblDocuments` ON `tblDocuments`.`id` = `tblDocumentContent`.`document` ".
@ -1470,8 +1475,26 @@ class SeedDMS_Core_DMS {
$searchQuery .= " AND `tblDocumentStatusLog`.`status` IN (".implode(',', $status).")";
}
if($reception)
$searchQuery .= " AND `tblDocumentReceiptLog`.`status` IN (".implode(',', $reception).")";
if($reception) {
$searchReception = array();
/* still waiting for users/groups to acknownledge reception */
if(in_array("missingaction", $reception))
$searchReception[] = "b.`status` IN (0)";
/* document has not been acknowledeged by at least one user/group */
if(in_array("hasrejection", $reception))
$searchReception[] = "b.`status` IN (-1)";
/* document has been acknowledeged by at least one user/group */
if(in_array("hasacknowledge", $reception))
$searchReception[] = "b.`status` IN (1)";
/* document has been acknowledeged by all users/groups !!! not working !!! */
if(in_array("completeacknowledge", $reception))
$searchReception[] = "b.`status` NOT IN (-1, 0)";
if($searchReception) {
$searchQuery .= " AND EXISTS (SELECT NULL FROM `tblDocumentRecipients` a LEFT JOIN `tblDocumentReceiptLog` b ON a.`receiptID`=b.`receiptID` LEFT JOIN `ttreceiptid` c ON c.`maxLogID` = b.`receiptLogID` WHERE ";
$searchQuery .= "c.`maxLogID`=b.`receiptLogID` AND `tblDocuments`.`id` = a.`documentID` ";
$searchQuery .= "AND (".implode(' OR ', $searchReception)."))";
}
}
if($searchKey || $searchOwner || $searchCategories || $searchCreateDate || $searchExpirationDate || $searchAttributes || $status || $reception) {
// Count the number of rows that the search will produce.