Wijzigingen nav opmerking Peter 24-12-2018

This commit is contained in:
2019-01-02 16:57:41 +01:00
parent 9569522c83
commit efcd9f2c09
19 changed files with 201 additions and 44 deletions
+7 -4
View File
@@ -26,15 +26,18 @@ class Offer extends BaseModel {
return $this->belongsTo( 'Customer' );
}
public static function getAllOffers( $projectID, $archive = 'F' )
public static function getAllOffers( $projectID, $archive = 'F', $search, $order, $direction )
{
$offers = Offer::orderBy( 'startdate' )
$offers = Offer::selectRAW('offers.*')
->join('customers AS CUS', 'CUS.id', '=', 'offers.customer_id')
->with( 'customer' )
->with( 'project' );
->with( 'project' )
->where('offernumber', 'LIKE', "%{$search}%")
->orderBy($order, $direction);
if ( $projectID ) $offers = $offers->whereProjectId( $projectID );
if ( $archive == 'F' ) $offers = $offers->whereArchive( 'F' );
if ( $archive == 'F' ) $offers = $offers->where( 'offers.archive', '=', 'F' );
$offers = $offers->get();
+8 -2
View File
@@ -61,11 +61,17 @@ class Project extends BaseModel {
return $this->belongsTo( 'Customer' );
}
public static function getAllProjects( $archive = 'F' )
public static function getAllProjects( $archive, $search, $order, $direction )
{
$projects = Project::getBaseProject();
if ( $archive == 'F' ) $projects = $projects->whereArchive( 'F' );
$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' );
$projects = $projects->get();
+4 -1
View File
@@ -54,7 +54,10 @@ class User extends BaseModel {
{
$usersWithProjects =
User::selectRaw( "users.id, CONCAT(users.firstname, ' ', users.middlename, ' ', users.lastname) AS fullname" )
->with( 'projectemployees.project' )
->with( [
'projectemployees.project' => function ( $q ) {
$q->whereArchive( 'F' );
}] )
->get();
return $usersWithProjects;
@@ -35,7 +35,10 @@ class EmployeehoursMonthly {
USR.id AS employee_id,
hours,
DATE_FORMAT(hourdate, '%d-%m-%Y') AS hourdate,
PEM.project_id
CASE
WHEN hourtype_id = 3 THEN offer_id
ELSE PEM.project_id
END AS project_id
FROM projecthours PRH
JOIN projectemployees PEM
ON PEM.id = PRH.projectemployee_id