start reports
This commit is contained in:
@@ -11,6 +11,16 @@ class User extends BaseModel {
|
||||
|
||||
protected $table = "users";
|
||||
|
||||
public function projectemployees()
|
||||
{
|
||||
return $this->hasMany( 'Projectemployee' );
|
||||
}
|
||||
|
||||
public function projectemployee()
|
||||
{
|
||||
return $this->hasOne( 'Projectemployee' );
|
||||
}
|
||||
|
||||
public function role()
|
||||
{
|
||||
return $this->belongsTo( 'Role', 'level', 'rolelevel' );
|
||||
@@ -18,7 +28,7 @@ class User extends BaseModel {
|
||||
|
||||
public static function getAllUsers( $archive )
|
||||
{
|
||||
$users = User::selectRaw("*, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname")
|
||||
$users = User::selectRaw( "*, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" )
|
||||
->orderBy( 'lastname' );
|
||||
|
||||
if ( $archive == 'F' ) $users = $users->whereArchive( 'F' );
|
||||
@@ -68,5 +78,23 @@ class User extends BaseModel {
|
||||
User::whereId( $userID )->delete();
|
||||
}
|
||||
|
||||
public static function getUniqueProjectUsers()
|
||||
{
|
||||
//TODO: date range
|
||||
$projectusers = User::selectRaw( "
|
||||
users.id,
|
||||
CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname,
|
||||
SUBSTR(MD5(users.id), 1, 6) AS slug" )
|
||||
->join( 'projectemployees AS PEM', 'PEM.user_id', '=', 'users.id' )
|
||||
->with( [
|
||||
'projectemployee.project' => function ( $q ) {
|
||||
$q->selectRaw( "id, YEAR(startdate) AS instroom, COALESCE(YEAR(enddate), '') AS uitstroom" );
|
||||
}] )
|
||||
->distinct()
|
||||
->get();
|
||||
|
||||
return $projectusers;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user