Sync changes v29.0.0 from IceHrmPro (https://icehrm.com/purchase-icehrmpro)
This commit is contained in:
@@ -8,14 +8,65 @@
|
||||
|
||||
namespace Documents\Common\Model;
|
||||
|
||||
use Classes\BaseService;
|
||||
use Classes\IceResponse;
|
||||
use Classes\ModuleAccess;
|
||||
use Employees\Common\Model\Employee;
|
||||
use Model\BaseModel;
|
||||
|
||||
class EmployeeDocument extends BaseModel
|
||||
{
|
||||
public $table = 'EmployeeDocuments';
|
||||
|
||||
private function getHiddenDocumentTypeIds()
|
||||
{
|
||||
}
|
||||
|
||||
// @codingStandardsIgnoreStart
|
||||
public function Find($whereOrderBy, $bindarr = false, $cache = false, $pkeysArr = false, $extra = array())
|
||||
{
|
||||
$find = '';
|
||||
$user = BaseService::getInstance()->getCurrentUser();
|
||||
|
||||
if ($user->user_level == 'Employee') {
|
||||
$find = ' visible_to = \'Owner\' AND ';
|
||||
$document = new Document();
|
||||
$hiddenDocumentTypes = $document->Find(
|
||||
"share_with_employee = ?",
|
||||
['No']
|
||||
);
|
||||
|
||||
$hiddenTypeIds = [];
|
||||
foreach ($hiddenDocumentTypes as $hiddenDocumentType) {
|
||||
$hiddenTypeIds[] = $hiddenDocumentType->id;
|
||||
}
|
||||
|
||||
if(count($hiddenTypeIds) > 0) {
|
||||
$find .= ' document NOT IN (\''.implode('\',\'', $hiddenTypeIds).'\') AND ';
|
||||
}
|
||||
|
||||
return parent::Find($find.$whereOrderBy, $bindarr, $pkeysArr, $extra);
|
||||
|
||||
} else if ($user->user_level == 'Manager') {
|
||||
// Original $whereOrderBy already contain employee selection
|
||||
// So here if isSubOrdinates is true if the query coming from Employee -> Document Management
|
||||
// In that case we need to show documents from sub ordinates
|
||||
// These docs can can be owner and manager both
|
||||
if (isset($isSubOrdinates) && $isSubOrdinates) {
|
||||
$find .= ' visible_to in (\'Owner\', \'Manager\') AND ';
|
||||
} else {
|
||||
// Here we are showing the documents for the manager
|
||||
// If someone upload a document for this manager and make it visible to manager,
|
||||
// that means only the manager of this manager can see the document
|
||||
// So it should not be visible to this manager
|
||||
$find .= ' visible_to in (\'Owner\') AND ';
|
||||
}
|
||||
}
|
||||
|
||||
return parent::Find($find.$whereOrderBy, $bindarr, $pkeysArr, $extra);
|
||||
}
|
||||
// @codingStandardsIgnoreEnd
|
||||
|
||||
public function getAdminAccess()
|
||||
{
|
||||
return array("get","element","save","delete");
|
||||
@@ -26,6 +77,8 @@ class EmployeeDocument extends BaseModel
|
||||
return array("get","element","save","delete");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function getUserAccess()
|
||||
{
|
||||
return array("get");
|
||||
|
||||
Reference in New Issue
Block a user