Diverse aanpassing nav mail Peter
This commit is contained in:
@@ -48,7 +48,7 @@ class Project extends BaseModel {
|
||||
|
||||
public function vat()
|
||||
{
|
||||
return $this->belongsTo('Vat');
|
||||
return $this->belongsTo( 'Vat' );
|
||||
}
|
||||
|
||||
public function projectleader()
|
||||
@@ -65,11 +65,11 @@ class Project extends BaseModel {
|
||||
{
|
||||
$projects = Project::getBaseProject();
|
||||
|
||||
$projects = $projects->selectRaw('projects.*')
|
||||
->join('customers AS CUS', 'CUS.id', '=', 'projects.customer_id')
|
||||
->join('users AS USR', 'USR.id', '=', 'projects.projectleader_id')
|
||||
->where('projects.projectnumber', 'LIKE', "%{$search}%")
|
||||
->orderBy($order, $direction);
|
||||
$projects = $projects->selectRaw( 'projects.*' )
|
||||
->join( 'customers AS CUS', 'CUS.id', '=', 'projects.customer_id' )
|
||||
->join( 'users AS USR', 'USR.id', '=', 'projects.projectleader_id' )
|
||||
->where( 'projects.projectnumber', 'LIKE', "%{$search}%" )
|
||||
->orderBy( $order, $direction );
|
||||
|
||||
if ( $archive == 'F' ) $projects = $projects->where( 'projects.archive', '=', 'F' );
|
||||
|
||||
@@ -96,7 +96,7 @@ class Project extends BaseModel {
|
||||
Project::whereId( $projectID )->delete();
|
||||
}
|
||||
|
||||
public static function getActiveProjects()
|
||||
public static function getActiveProjects($archive = 'T')
|
||||
{
|
||||
$projects = Project::selectRaw( "projects.id, YEAR(projects.startdate) AS instroom, YEAR(projects.enddate) AS uitstroom, projectnumber, current_financial_year,
|
||||
projectname, CUS.name, OFF.own_revenue, OFF.other_revenue" )
|
||||
@@ -104,15 +104,22 @@ class Project extends BaseModel {
|
||||
->join( 'offers AS OFF', 'OFF.project_id', '=', 'projects.id' )
|
||||
->groupBy( 'projects.id' )
|
||||
->groupBy( 'OFF.own_revenue' )
|
||||
->groupBy( 'OFF.other_revenue' )
|
||||
->get();
|
||||
->groupBy( 'OFF.other_revenue' );
|
||||
|
||||
if( $archive == 'F') $projects = $projects->where('projects.archive', '=', 'F');
|
||||
|
||||
$projects = $projects->get();
|
||||
|
||||
return $projects;
|
||||
}
|
||||
|
||||
public static function getProjectsForReport()
|
||||
public static function getProjectsForReport( $orderType, $orderDirection, $archive = 'F' )
|
||||
{
|
||||
$projects = self::getBaseProject()->get();
|
||||
$projects = self::getBaseProject();
|
||||
|
||||
if ( $archive == 'F' ) $projects = $projects->whereArchive( 'F' );
|
||||
|
||||
$projects = $projects->orderBy( $orderType, $orderDirection )->get();
|
||||
|
||||
return $projects;
|
||||
}
|
||||
@@ -128,9 +135,9 @@ class Project extends BaseModel {
|
||||
'projectemployees.user' => function ( $q ) {
|
||||
$q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" );
|
||||
}] )
|
||||
->with('vat')
|
||||
->with(['forecasts'])
|
||||
->with(['reservations'])
|
||||
->with( 'vat' )
|
||||
->with( ['forecasts'] )
|
||||
->with( ['reservations'] )
|
||||
->with( 'projectemployees.projecthours' )
|
||||
->with( 'projectcosts.external' )
|
||||
->with( 'invoices.payments' )
|
||||
|
||||
@@ -27,7 +27,7 @@ class Projecthour extends BaseModel {
|
||||
|
||||
public static function getMonthlyEmployeeHoursPerProject( $employeeID, $year )
|
||||
{
|
||||
$projectHours = ProjecthoursPerEmployeePerMonth::fire($employeeID, $year);
|
||||
$projectHours = ProjecthoursPerEmployeePerMonth::fire( $employeeID, $year );
|
||||
|
||||
return $projectHours;
|
||||
}
|
||||
@@ -61,5 +61,21 @@ class Projecthour extends BaseModel {
|
||||
Projecthour::whereId( $projecthourID )->delete();
|
||||
}
|
||||
|
||||
public static function getTotalHoursPerProject( $projectID )
|
||||
{
|
||||
$totalProjecthours =
|
||||
self::selectRaw( "CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname,
|
||||
SUM(IF(hourtype_id = 1, hours, 0)) AS declarable,
|
||||
SUM(IF(hourtype_id = 1, hours * tarif, 0)) AS revenues,
|
||||
SUM(IF(hourtype_id != 1, hours, 0)) AS nondeclarable" )
|
||||
->join( 'projectemployees AS PRE', 'PRE.id', '=', 'projecthours.projectemployee_id' )
|
||||
->join( 'users AS USR', 'USR.id', '=', 'PRE.user_id' )
|
||||
->groupBy( 'USR.id' )
|
||||
->where( 'PRE.project_id', '=', $projectID )
|
||||
->get();
|
||||
|
||||
return $totalProjecthours;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -49,7 +49,21 @@ class QEmployeeHours {
|
||||
if( $month != 0 ) $sql .= "AND MONTH(hourdate) = '$month' ";
|
||||
$sql .= "
|
||||
GROUP BY PEM.user_id, MONTH(hourdate)
|
||||
UNION
|
||||
SELECT PH.projectemployee_id AS user_id,
|
||||
MONTH(hourdate) monthID,
|
||||
SUM(hours) AS projecthours,
|
||||
0 AS profitablehours,
|
||||
SUM(IF(hourtype_id = 3, hours, 0)) AS nonprofitablehours,
|
||||
0 AS revenues,
|
||||
0 AS nonprojecthours
|
||||
FROM projecthours PH
|
||||
WHERE YEAR(hourdate) = '{$year}' ";
|
||||
if( $month != 0 ) $sql .= "AND MONTH(hourdate) = '$month' ";
|
||||
$sql .= "
|
||||
GROUP BY PH.projectemployee_id, MONTH(hourdate)
|
||||
) AS Q1
|
||||
|
||||
JOIN users AS USR
|
||||
ON USR.id = Q1.user_id
|
||||
GROUP BY user_id ";
|
||||
|
||||
Reference in New Issue
Block a user