From 0441ba7b817c0bffd52d8fb7a1e131b53a0ea4fa Mon Sep 17 00:00:00 2001 From: Theo Weijmer Date: Thu, 8 Feb 2018 17:01:22 +0100 Subject: [PATCH] start reports --- .../controllers/beheer/UsersController.php | 7 ++ .../reports/EmployeeHoursController.php | 34 +++++++++ application/models/eloquent/User.php | 30 +++++++- .../views/pages/monthlyemployeehours_view.php | 37 ++++++++++ application/views/partials/_js.php | 1 + .../monthlyemployeehours/employee_view.php | 3 + .../monthlyemployeehours/euro_view.php | 1 + .../monthlyemployeehours/hours_view.php | 1 + public/js/lib/dataservices/userDataservice.js | 7 ++ .../reports/monthlyEmployeeHoursModule.js | 70 +++++++++++++++++++ 10 files changed, 190 insertions(+), 1 deletion(-) create mode 100644 application/controllers/reports/EmployeeHoursController.php create mode 100644 application/views/pages/monthlyemployeehours_view.php create mode 100644 application/views/reports/monthlyemployeehours/employee_view.php create mode 100644 application/views/reports/monthlyemployeehours/euro_view.php create mode 100644 application/views/reports/monthlyemployeehours/hours_view.php create mode 100644 public/js/lib/modules/reports/monthlyEmployeeHoursModule.js diff --git a/application/controllers/beheer/UsersController.php b/application/controllers/beheer/UsersController.php index 43a1296..0cd4b81 100644 --- a/application/controllers/beheer/UsersController.php +++ b/application/controllers/beheer/UsersController.php @@ -34,6 +34,13 @@ class usersController extends MY_Controller { $this->json( $users ); } + public function getUniqueprojectEmployees() + { + $projectEmployees = User::getUniqueProjectUsers(); + + $this->json( $projectEmployees ); + } + public function saveUser() { $userValidation = new UserValidation(); diff --git a/application/controllers/reports/EmployeeHoursController.php b/application/controllers/reports/EmployeeHoursController.php new file mode 100644 index 0000000..350c97f --- /dev/null +++ b/application/controllers/reports/EmployeeHoursController.php @@ -0,0 +1,34 @@ +load->model( $models ); + $this->load->library( $libraries ); + } + public function index() + { + + } + + public function getMonthlyEmployeeHoursPerProject() + { + } + + +} \ No newline at end of file diff --git a/application/models/eloquent/User.php b/application/models/eloquent/User.php index 7f76b77..9f461eb 100644 --- a/application/models/eloquent/User.php +++ b/application/models/eloquent/User.php @@ -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; + } + } \ No newline at end of file diff --git a/application/views/pages/monthlyemployeehours_view.php b/application/views/pages/monthlyemployeehours_view.php new file mode 100644 index 0000000..99f75f4 --- /dev/null +++ b/application/views/pages/monthlyemployeehours_view.php @@ -0,0 +1,37 @@ +
+
+
+ +
+
+ +
\ No newline at end of file diff --git a/application/views/partials/_js.php b/application/views/partials/_js.php index 20fa50f..8808e15 100644 --- a/application/views/partials/_js.php +++ b/application/views/partials/_js.php @@ -68,6 +68,7 @@ + diff --git a/application/views/reports/monthlyemployeehours/employee_view.php b/application/views/reports/monthlyemployeehours/employee_view.php new file mode 100644 index 0000000..bd54e30 --- /dev/null +++ b/application/views/reports/monthlyemployeehours/employee_view.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/application/views/reports/monthlyemployeehours/euro_view.php b/application/views/reports/monthlyemployeehours/euro_view.php new file mode 100644 index 0000000..1bc8b53 --- /dev/null +++ b/application/views/reports/monthlyemployeehours/euro_view.php @@ -0,0 +1 @@ +

EURO'S

\ No newline at end of file diff --git a/application/views/reports/monthlyemployeehours/hours_view.php b/application/views/reports/monthlyemployeehours/hours_view.php new file mode 100644 index 0000000..f2bc9cd --- /dev/null +++ b/application/views/reports/monthlyemployeehours/hours_view.php @@ -0,0 +1 @@ +

hours

\ No newline at end of file diff --git a/public/js/lib/dataservices/userDataservice.js b/public/js/lib/dataservices/userDataservice.js index 566be88..1a4d65d 100644 --- a/public/js/lib/dataservices/userDataservice.js +++ b/public/js/lib/dataservices/userDataservice.js @@ -21,6 +21,13 @@ dbo.userDataService = { } ); }, + getUniqueProjectEmployees:function(callback){ + $.post('index.php/beheer/usersController/getUniqueprojectEmployees', 'json') + .done(function(data){ + callback(data); + }); + }, + checkUsername: function ( username, callback ) { $.post( 'index.php/beheer/userController/checkUsername', 'json' ) .done( function ( data ) { diff --git a/public/js/lib/modules/reports/monthlyEmployeeHoursModule.js b/public/js/lib/modules/reports/monthlyEmployeeHoursModule.js new file mode 100644 index 0000000..93a7328 --- /dev/null +++ b/public/js/lib/modules/reports/monthlyEmployeeHoursModule.js @@ -0,0 +1,70 @@ +/** + * Created by Pensare Software. + * User: Theo Weijmer + * Date: 08/02/2018 + * Time: 15:32 + */ + +dbo.monthlyemployeehoursInit = function () { + + if ( dbo.monthlyEmployeeHoursModel !== undefined ) { + + dbo.monthlyEmployeeHoursModel.initModule(); + + } else { + + dbo.monthlyEmployeeHoursModel = { + + uniqueEmployees: ko.observableArray( [] ), + sluggy : ko.observable( 'euro' ), + + init: function () { + var vm = dbo.monthlyEmployeeHoursModel; + + vm.initModule(); + }, + + initModule: function () { + var vm = dbo.monthlyEmployeeHoursModel; + dbo.userDataService.getUniqueProjectEmployees( function ( data ) { + vm.uniqueEmployees.removeAll(); + $.each( data, function ( i, p ) { + vm.uniqueEmployees.push(new vm.UniqueEmployee(p) ) + } ); + } ); + }, + + setActivetab: function ( tab ) { + var vm = dbo.monthlyEmployeeHoursModel; + + vm.sluggy( tab ); + }, + + UniqueEmployee : function(data){ + var vm = dbo.monthlyEmployeeHoursModel; + var self = this; + + self.id = data.id; + self.fullname = data.fullname; + self.slug = data.slug; + + self.myData = ko.observableArray([]); + + for(var i=1; i<5; i++){ + self.myData.push( new vm.Detail(data.fullname)); + } + }, + + Detail : function(data){ + console.log( data ); + this.test = data; + } + }; + + dbo.monthlyEmployeeHoursModel.init(); + + ko.applyBindings( dbo.monthlyEmployeeHoursModel, document.getElementById( "MONTHLYEMPLOYEEHOURS" ) ); + } + + +} \ No newline at end of file