Diversen opmerkingen Peter (23-08-2019)
This commit is contained in:
@@ -53,6 +53,13 @@ class usersController extends MY_Controller {
|
||||
$this->json( $usersWithProjects );
|
||||
}
|
||||
|
||||
public function getUserActiveProjects($userID)
|
||||
{
|
||||
$userActiveProjects = User::getUserActiveProjects($userID);
|
||||
|
||||
$this->json( $userActiveProjects );
|
||||
}
|
||||
|
||||
public function getUniqueprojectEmployees()
|
||||
{
|
||||
$projectEmployees = User::getUniqueProjectUsers();
|
||||
|
||||
@@ -133,6 +133,8 @@ class ProjectsController extends MY_Controller {
|
||||
|
||||
$projectID = Project::saveProject( $projectID, $project );
|
||||
|
||||
Offer::syncProjectname( $projectID );
|
||||
|
||||
$this->json( ['success' => TRUE, 'projectID' => $projectID] );
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class MY_Controller extends CI_Controller {
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->version = '1.00.06';
|
||||
$this->version = '1.00.10';
|
||||
|
||||
$this->load->library( 'beheer/session/RetrieveUserSession' );
|
||||
|
||||
|
||||
@@ -72,11 +72,25 @@ class Offer extends BaseModel {
|
||||
else
|
||||
{
|
||||
Offer::whereId( $offerID )->update( $offer );
|
||||
|
||||
$offer = self::find( $offerID );
|
||||
|
||||
if ( ! is_null( $offer->project_id ) ) Project::syncOffername( $offer );
|
||||
}
|
||||
|
||||
return $offerID;
|
||||
}
|
||||
|
||||
public static function syncProjectname( $projectID )
|
||||
{
|
||||
$project = Project::find( $projectID );
|
||||
|
||||
$offer = self::find( $projectID );
|
||||
|
||||
$offer->offername = $project->projectname;
|
||||
$offer->save();
|
||||
}
|
||||
|
||||
public static function removeOffer( $offerID )
|
||||
{
|
||||
Offer::whereId( $offerID )->delete();
|
||||
|
||||
@@ -172,6 +172,11 @@ class Project extends BaseModel {
|
||||
}
|
||||
|
||||
return $projectID;
|
||||
}
|
||||
|
||||
public static function syncOffername( $offer )
|
||||
{
|
||||
self::whereId( $offer->project_id )
|
||||
->update( ['projectname' => $offer->offername] );
|
||||
}
|
||||
}
|
||||
@@ -63,6 +63,19 @@ class User extends BaseModel {
|
||||
return $usersWithProjects;
|
||||
}
|
||||
|
||||
public static function getUserActiveProjects( $userID )
|
||||
{
|
||||
$usersActiveProjects =
|
||||
User::selectRaw( "PRJ.id AS projectID, projectname, projectnumber, CONCAT(projectnumber, '-', projectname) AS projectFull" )
|
||||
->join( 'projectemployees AS PRE', 'PRE.user_id', '=', 'users.id' )
|
||||
->join( 'projects AS PRJ', 'PRJ.id', '=', 'PRE.project_id' )
|
||||
->where( 'PRJ.archive', '=', 'F' )
|
||||
->where( 'users.id', '=', $userID )
|
||||
->get();
|
||||
|
||||
return $usersActiveProjects;
|
||||
}
|
||||
|
||||
public static function checkUsername( $username )
|
||||
{
|
||||
$username = strtoupper( $username );
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<div class="panel panel-bordered panel-primary panel-line">
|
||||
<div class="panel-heading panel-heading-project">
|
||||
<h3 class="">
|
||||
Reserveringen (incl. btw)
|
||||
budget onderaannemers (incl. btw)
|
||||
</h3>
|
||||
</div>
|
||||
<div class="panel-body panel-body-project">
|
||||
|
||||
@@ -28,87 +28,61 @@
|
||||
<table class="table table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="table-tealish-header">medewerker</th>
|
||||
<th class="table-tealish-header">datum</th>
|
||||
<th class="table-tealish-header">soort uren</th>
|
||||
<th class="table-tealish-header">project</th>
|
||||
<th class="table-tealish-header" style="min-width:100px;">uren</th>
|
||||
<th class="table-tealish-header"> </th>
|
||||
<th class="table-tealish-header" width="15%">datum</th>
|
||||
<th class="table-tealish-header" width="35%">soort uren</th>
|
||||
<th class="table-tealish-header" width="35%">project</th>
|
||||
<th class="table-tealish-header" width="10%" style="min-width:100px;">uren</th>
|
||||
<th class="table-tealish-header" width="5%"> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-bind="foreach:employeehours">
|
||||
<tr>
|
||||
<td data-bind="css:{'red-line': id() == 0}">
|
||||
<span data-bind="text:dbo.helpers.findArrayElement('id', 'fullname', employee_id(), $root.employees()),
|
||||
visible: ! inEdit()"></span>
|
||||
<select class="form-control form-control-sm"
|
||||
data-bind="options:$root.employees,
|
||||
optionsText:'fullname',
|
||||
optionsValue:'id',
|
||||
value:employee_id,
|
||||
optionsCaption: 'selecteer...',
|
||||
visible:inEdit(),
|
||||
enable: ! $root.selectedEmployeeID,
|
||||
event:{change:$root.changeEmployee}"></select>
|
||||
</td>
|
||||
<td data-bind="css:{'red-line': id() == 0}">
|
||||
<span data-bind="text:hourdate, visible:! inEdit()"></span>
|
||||
<td data-bind="css:{'red-line': dirty}">
|
||||
<input class="form-control form-control-sm"
|
||||
data-bind="datepicker:{dateFormat: 'dd-mm-yy' },
|
||||
value:hourdate, visible:inEdit(),
|
||||
value:hourdate,
|
||||
event:{change:$root.saveEmployeehour}"
|
||||
</td>
|
||||
<td data-bind="css:{'red-line': id() == 0}">
|
||||
<span data-bind="text:dbo.helpers.findArrayElement('id', 'description', hourtype_id(), $root.hourtypes()),
|
||||
visible: ! inEdit()"></span>
|
||||
<td data-bind="css:{'red-line': dirty}">
|
||||
<select class="form-control form-control-sm"
|
||||
data-bind="options:$root.hourtypes,
|
||||
optionsText:'description',
|
||||
optionsValue:'id',
|
||||
value:hourtype_id,
|
||||
optionsCaptiuon:'selecteer...',
|
||||
visible:inEdit(),
|
||||
optionsCaption:'selecteer...',
|
||||
event:{change:$root.saveEmployeehours}"></select>
|
||||
</td>
|
||||
<td data-bind="css:{'red-line': id() == 0}">
|
||||
<td data-bind="css:{'red-line': dirty}">
|
||||
<!-- ko if: hourType() == 'PROJECTS' -->
|
||||
<span data-bind="text:dbo.helpers.findArrayElement('projectID', 'projectname', projectID(), projects()),
|
||||
visible: ! inEdit()"></span>
|
||||
<select class="form-control form-control-sm"
|
||||
data-bind="options:projects,
|
||||
optionsText:'projectname',
|
||||
data-bind="options:$root.projects,
|
||||
optionsText:'projectFull',
|
||||
optionsValue:'projectID',
|
||||
value:projectID,
|
||||
optionsCaption:'selecteer...',
|
||||
visible:inEdit(),
|
||||
event:{change:$root.saveEmployeehours}"></select>
|
||||
<!-- /ko -->
|
||||
<!-- ko if: hourType() == 'OFFERS' -->
|
||||
<span data-bind="text:dbo.helpers.findArrayElement('id', 'offername', projectID(), $root.offersWithoutProject()),
|
||||
visible: ! inEdit()"></span>
|
||||
<select class="form-control form-control-sm"
|
||||
data-bind="options:$root.offersWithoutProject,
|
||||
optionsText:'offername',
|
||||
optionsValue:'id',
|
||||
value:projectID,
|
||||
optionsCaption:'selecteer...',
|
||||
visible:inEdit(),
|
||||
event:{change:$root.saveEmployeehours}"></select>
|
||||
<!-- /ko -->
|
||||
</td>
|
||||
<td class="align-right" data-bind="css:{'red-line': id() == 0}">
|
||||
<span data-bind=" visible: ! inEdit()">
|
||||
<span data-bind="text:hours"></span>
|
||||
uur
|
||||
</span>
|
||||
<input type="text"
|
||||
<td class="align-right" data-bind="css:{'red-line': dirty}">
|
||||
<input type="number"
|
||||
class="form-control form-control-sm align-right"
|
||||
paceholder="uren"
|
||||
data-bind="textInput:hours, visible:inEdit,
|
||||
event:{change:$root.saveEmployeehours,keyup:$root.validateNumber.bind($data, 'hours')}"/>
|
||||
data-bind="textInput:hours,
|
||||
enable:canFillInHours,
|
||||
event:{keyup:$root.saveDelayedEmployeehours,
|
||||
change: $root.saveDelayedEmployeehours}"/>
|
||||
</td>
|
||||
<td data-bind="css:{'red-line': id() == 0}">
|
||||
<i class="icon fa-edit pointer" title="wijzig" data-bind="click:$root.editEmployeehour"></i>
|
||||
<td data-bind="css:{'red-line': dirty}">
|
||||
<!-- <i class="icon fa-edit pointer" title="wijzig" data-bind="click:$root.editEmployeehour"></i>-->
|
||||
<i class="icon fa-trash redish pointer" title="verwijder"
|
||||
data-bind="click:$root.removeEmployeehour"></i>
|
||||
</td>
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
<span data-bind="text:acceptance_chance"></span> %
|
||||
</td>
|
||||
<td data-bind="click:$root.selectOffer" class="pointer align-right">
|
||||
€ <span data-bind="text:Math.round((acceptance_chance * own_revenue) / 100)"></span>
|
||||
€ <span data-bind="text:chanceOwnRevenue"></span>
|
||||
</td>
|
||||
<!-- <td data-bind="click:$root.selectOffer" class="pointer">-->
|
||||
<!-- <span data-bind="text:accepteddate"></span>-->
|
||||
@@ -78,6 +78,19 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="4" class="align-right table-tealish-header">
|
||||
Totaal
|
||||
</th>
|
||||
<th class="align-right table-tealish-header">
|
||||
€ <span data-bind="text:totalOwnRevenue"></span>
|
||||
</th>
|
||||
<th class=" table-tealish-header"> </th>
|
||||
<th class="align-right table-tealish-header">
|
||||
€ <span data-bind="text:totalChanceOwnRevenue"></span>
|
||||
</th>
|
||||
<th class=" table-tealish-header"> </th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5" class="">
|
||||
<button class="btn btn-primary btn-round btn-sm" data-bind="click:newOffer">
|
||||
|
||||
@@ -77,6 +77,25 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th colspan="4" class="align-right table-tealish-header">
|
||||
Totaal
|
||||
</th>
|
||||
<th class="align-right table-tealish-header">
|
||||
€ <span data-bind="text:totalOwnRevenue"></span>
|
||||
</th>
|
||||
<th class="align-right table-tealish-header">
|
||||
€ <span data-bind="text:totalOtherrevenue"></span>
|
||||
</th>
|
||||
<th class="align-right table-tealish-header">
|
||||
€ <span data-bind="text:totalCosts"></span>
|
||||
</th>
|
||||
<th class="align-right table-tealish-header">
|
||||
€ <span data-bind="text:total"></span>
|
||||
</th>
|
||||
<th class="align-right table-tealish-header"></th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="5" class="">
|
||||
<!-- <button class="btn btn-primary btn-round btn-sm" data-bind="click:newProject">-->
|
||||
|
||||
@@ -10,13 +10,13 @@
|
||||
<th width="3%"> </th>
|
||||
<th width="17%">project</th>
|
||||
<th width="10%" class="align-right">Kosten derden</th>
|
||||
<th width="10%" class="align-right">gefactureerd</th>
|
||||
<th width="10%" class="align-right">gereserveerd</th>
|
||||
<th width="10%" class="align-right">factuur INK</th>
|
||||
<th width="10%" class="align-right">budget onderaannemers</th>
|
||||
<th width="10%" class="align-right">betaald</th>
|
||||
<th width="10%" class="align-right">saldo te<br />betalen</th>
|
||||
<th width="10%" class="align-right">betaald via<br />reserveringen</th>
|
||||
<th width="10%" class="align-right">saldo reservering</th>
|
||||
<th width="10%" class="align-right">saldo te<br />factureren</th>
|
||||
<th width="10%" class="align-right">saldo facturen INK</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<!-- ko foreach:projects -->
|
||||
|
||||
@@ -35,6 +35,13 @@ dbo.userDataService = {
|
||||
} );
|
||||
},
|
||||
|
||||
getUserActiveProjects: function ( userID, callback ) {
|
||||
$.getJSON( 'index.php/beheer/usersController/getUserActiveProjects/' + userID )
|
||||
.done( function ( data ) {
|
||||
callback( data );
|
||||
} );
|
||||
},
|
||||
|
||||
getUniqueProjectEmployees: function ( callback ) {
|
||||
$.post( 'index.php/beheer/usersController/getUniqueprojectEmployees', 'json' )
|
||||
.done( function ( data ) {
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
dbo.employeehoursInit = function () {
|
||||
|
||||
var timeout;
|
||||
|
||||
if ( dbo.employeehoursModel !== undefined ) {
|
||||
dbo.employeehoursModel.init();
|
||||
} else {
|
||||
@@ -24,6 +26,7 @@ dbo.employeehoursInit = function () {
|
||||
busy : false,
|
||||
selectedEmployeeID : ko.observable(),
|
||||
offersWithoutProject: ko.observableArray( [] ),
|
||||
projects : ko.observableArray( [] ),
|
||||
|
||||
init: function () {
|
||||
var vm = dbo.employeehoursModel;
|
||||
@@ -36,17 +39,15 @@ dbo.employeehoursInit = function () {
|
||||
vm.selectedMonth( dbo.currentMonth );
|
||||
vm.selectedYear( dbo.currentYear );
|
||||
|
||||
vm.selectedEmployeeID( dbo.currentUser.id );
|
||||
|
||||
dbo.userDataService.getAllUsers( 'F', function ( data ) {
|
||||
vm.employees( data );
|
||||
|
||||
dbo.employeehoursDataService.getHourtypes( function ( data ) {
|
||||
vm.hourtypes( data );
|
||||
dbo.offerDataService.getOffersWithoutProject( function ( data ) {
|
||||
vm.offersWithoutProject( data );
|
||||
dbo.userDataService.getUserWithprojects( function ( data ) {
|
||||
vm.employees.removeAll();
|
||||
_.each( data, function ( p ) {
|
||||
vm.employees.push( new vm.Employee( p ) );
|
||||
} );
|
||||
vm.selectedEmployeeID( dbo.currentUser.id )
|
||||
|
||||
vm.busy = false;
|
||||
vm.refreshEmployeehours();
|
||||
} );
|
||||
@@ -73,26 +74,42 @@ dbo.employeehoursInit = function () {
|
||||
hourtype_id: employeeHour ? employeeHour.hourtype_id() : 9,
|
||||
project_id : employeeHour ? employeeHour.projectID() : null,
|
||||
hours : 0,
|
||||
inEdit : true
|
||||
inEdit : true,
|
||||
dirty : true
|
||||
};
|
||||
|
||||
vm.employeehours.push( new vm.Employeehour( employeehour ) );
|
||||
},
|
||||
|
||||
toggleArchive: function () {
|
||||
var vm = dbo.employeeemployeehoursModel;
|
||||
var vm = dbo.employeehoursModel;
|
||||
|
||||
vm.archive( !vm.archive() );
|
||||
|
||||
vm.refreshHours();
|
||||
},
|
||||
|
||||
saveDelayedEmployeehours: function () {
|
||||
var vm = dbo.employeehoursModel;
|
||||
var self = this;
|
||||
self.dirty( true );
|
||||
if ( timeout ) {
|
||||
clearTimeout( timeout );
|
||||
timeout = null;
|
||||
}
|
||||
timeout = setTimeout( function () {
|
||||
vm.saveEmployeehours( self );
|
||||
}, 300 );
|
||||
},
|
||||
|
||||
saveEmployeehours: function ( self = false ) {
|
||||
self.dirty( true );
|
||||
if ( !self ) self = this;
|
||||
|
||||
if ( !self.employee_id() ) return;
|
||||
if ( !self.hourtype_id() ) return;
|
||||
if ( !self.hourdate() ) return;
|
||||
if ( self.hours() <= 0 ) return;
|
||||
if ( self.hourType() == 'PROJECTS' && !self.projectID() ) return;
|
||||
if ( self.hourType() == 'OFFERS' && !self.projectID() ) return;
|
||||
|
||||
@@ -108,6 +125,7 @@ dbo.employeehoursInit = function () {
|
||||
|
||||
dbo.employeehoursDataService.saveEmployeehour( submitDATA, function ( data ) {
|
||||
self.id( data.employeehourID );
|
||||
self.dirty( false );
|
||||
} );
|
||||
},
|
||||
|
||||
@@ -195,6 +213,7 @@ dbo.employeehoursInit = function () {
|
||||
this.type = 'PROJECT';
|
||||
this.projectID = data.project.id;
|
||||
this.project = data.project.projectnumber + ' - ' + data.project.projectname;
|
||||
this.projectname = data.project.projectnumber + ' - ' + data.project.projectname;
|
||||
},
|
||||
|
||||
Offer: function ( data, employeeID ) {
|
||||
@@ -215,24 +234,19 @@ dbo.employeehoursInit = function () {
|
||||
self.hours = ko.observable( data.hours );
|
||||
self.inEdit = ko.observable( data.inEdit || false );
|
||||
self.projectID = ko.observable( data.project_id );
|
||||
self.dirty = ko.observable( data.dirty || false );
|
||||
self.hourType = ko.pureComputed( function () {
|
||||
return dbo.helpers.findArrayElement( 'id', 'key', this.hourtype_id(), vm.hourtypes() );
|
||||
}, this );
|
||||
self.canFillInHours = ko.pureComputed( function () {
|
||||
if ( self.hourType() == 'PROJECTS' || self.hourType() == 'OFFERS' ) {
|
||||
if ( !self.projectID() ) {
|
||||
self.hours( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
vm.setEmployeeProjects( self );
|
||||
},
|
||||
|
||||
setEmployeeProjects: function ( self ) {
|
||||
var vm = dbo.employeehoursModel;
|
||||
|
||||
var employeeProjects =
|
||||
dbo.helpers.findArrayElement( 'id', 'projecten', self.employee_id(), vm.employees() );
|
||||
self.projects = ko.observableArray( [] );
|
||||
_.each( employeeProjects, function ( p ) {
|
||||
self.projects.push( {
|
||||
projectID : p.projectID,
|
||||
projectname: p.project
|
||||
} );
|
||||
return true;
|
||||
} );
|
||||
}
|
||||
};
|
||||
@@ -240,5 +254,11 @@ dbo.employeehoursInit = function () {
|
||||
dbo.employeehoursModel.init();
|
||||
|
||||
ko.applyBindings( dbo.employeehoursModel, document.getElementById( 'EMPLOYEEHOURS' ) );
|
||||
|
||||
dbo.employeehoursModel.selectedEmployeeID.subscribe( function () {
|
||||
dbo.userDataService.getUserActiveProjects( dbo.currentUser.id, function ( data ) {
|
||||
dbo.employeehoursModel.projects( data );
|
||||
} );
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,8 @@ dbo.offersInit = function () {
|
||||
search : ko.observable( '' ),
|
||||
order : ko.observable( 'offernumber' ),
|
||||
direction : ko.observable(),
|
||||
totalOwnRevenue : ko.observable( 0 ),
|
||||
totalChanceOwnRevenue: ko.observable( 0 ),
|
||||
|
||||
init: function () {
|
||||
var service = dbo.offersService;
|
||||
|
||||
@@ -22,6 +22,11 @@ dbo.projectsInit = function () {
|
||||
search : ko.observable(),
|
||||
order : ko.observable( 'projectnumber' ),
|
||||
direction : ko.observable(),
|
||||
totalOwnRevenue : ko.observable( 0 ),
|
||||
totalOtherrevenue: ko.observable( 0 ),
|
||||
totalCosts : ko.observable( 0 ),
|
||||
total : ko.observable( 0 ),
|
||||
|
||||
|
||||
init: function () {
|
||||
var vm = dbo.projectsModel;
|
||||
@@ -140,6 +145,10 @@ dbo.projectsInit = function () {
|
||||
}
|
||||
|
||||
dbo.projectDataService.getAllProjects( projectsObject, function ( data ) {
|
||||
vm.totalOwnRevenue(0);
|
||||
vm.totalOtherrevenue(0);
|
||||
vm.totalCosts(0);
|
||||
vm.total(0);
|
||||
vm.projects.removeAll();
|
||||
$.each( data, function ( i, p ) {
|
||||
vm.projects.push( new vm.Project( p ) );
|
||||
@@ -164,6 +173,13 @@ dbo.projectsInit = function () {
|
||||
self.totalOtherrevenue = Number( data.offer.other_revenue );
|
||||
self.costs = Number( data.offer.costs );
|
||||
self.total = Number( data.offer.own_revenue ) + Number( data.offer.other_revenue ) + Number( data.offer.costs );
|
||||
|
||||
vm.totalOwnRevenue( vm.totalOwnRevenue() + self.totalOwnrevenue )
|
||||
vm.totalOtherrevenue( vm.totalOtherrevenue() + self.totalOtherrevenue )
|
||||
vm.totalCosts( vm.totalCosts() + self.costs )
|
||||
vm.total( Math.round(vm.total() + self.total) )
|
||||
|
||||
|
||||
},
|
||||
|
||||
Revenue: function ( data ) {
|
||||
|
||||
@@ -108,12 +108,15 @@ dbo.offersService = {
|
||||
dbo.offerDataService.getAllOffers( offersObject, function ( data ) {
|
||||
vm.offers.removeAll();
|
||||
$.each( data, function ( i, p ) {
|
||||
vm.totalOwnRevenue( 0 );
|
||||
vm.totalChanceOwnRevenue( 0 );
|
||||
vm.offers.push( new self.Offer( p ) );
|
||||
} );
|
||||
} );
|
||||
},
|
||||
|
||||
Offer: function ( data ) {
|
||||
var vm = dbo.offersModel;
|
||||
this.id = data.id;
|
||||
this.offernumber = data.offernumber;
|
||||
this.offername = data.offername;
|
||||
@@ -127,9 +130,14 @@ dbo.offersService = {
|
||||
this.rejectdate = data.rejectdate ? dbo.helpers.mysql2date( data.rejectdate ) : null;
|
||||
this.accepteddate = data.accepteddate ? dbo.helpers.mysql2date( data.accepteddate ) : null;
|
||||
this.acceptance_chance = data.acceptance_chance ? data.acceptance_chance : 0;
|
||||
this.own_revenue = data.own_revenue;
|
||||
this.other_revenue = data.other_revenue;
|
||||
this.own_revenue = data.own_revenue;
|
||||
this.chanceOwnRevenue = Math.round( (Number( data.own_revenue ) * data.acceptance_chance) / 100 );
|
||||
this.costs = data.costs;
|
||||
this.archive = data.archive;
|
||||
|
||||
vm.totalOwnRevenue( Number( vm.totalOwnRevenue() ) + Number( this.own_revenue ) );
|
||||
vm.totalChanceOwnRevenue( Number( vm.totalChanceOwnRevenue() ) + Number( this.chanceOwnRevenue ) );
|
||||
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user