Merge branch 'master' of bitbucket.org:pensare/dbois

# Conflicts:
#	application/controllers/projects/EmployeeHoursController.php
#	application/views/pages/employeehours_view.php
#	public/js/lib/modules/projects/employeehoursModule.js
This commit is contained in:
2018-04-02 17:34:19 +02:00
15 changed files with 137 additions and 69 deletions
@@ -56,13 +56,15 @@ class EmployeeHoursController extends MY_Controller {
if ( $hourType == 'PROJECTS' )
{
$projectemployeeID = Projectemployee::select( 'id' )
$projectemployee = Projectemployee::select( 'id' )
->whereUserId( $data['employee_id'] )
->whereprojectId( $projectID )
->first();
$data['projectemployee_id'] = $projectemployeeID;
$data['projectemployee_id'] = $projectemployee->id;
unset( $data['employee_id'] );
$data['hourtype_id'] = $data['hourtype_id'] - 8;
$employeehourID = Projecthour::saveProjecthour( $employeehourID, $data );
}
else
@@ -15,7 +15,7 @@ class ProjectsController extends MY_Controller {
if ( AUTHENTICATED == FALSE ) die( 'NO ACCESS' );
$models = [];
$models = ['projects/Invoices_model'];
$libraries = [];
$this->load->model( $models );
@@ -38,6 +38,9 @@ class ProjectsController extends MY_Controller {
{
$project = Project::getProject( $projectID );
$project->outstanding =
$this->Invoices_model->getOutstandingPerProject( $project->id );
$this->json( $project );
}
@@ -23,4 +23,20 @@ class Invoices_model extends MY_Model {
return $invoiced;
}
public function getOutstandingPerProject( $projectID )
{
$this->sql = "
SELECT (own_revenue + other_revenue) - SUM(INV.invoiceamount) AS outstanding
FROM invoices INV
JOIN projects PRJ
ON PRJ.id = INV.project_id
JOIN offers OFF
ON PRJ.id = OFF.project_id
WHERE PRJ.id = {$projectID} ";
$invoiced = $this->get_query_row( 'outstanding' );
return $invoiced;
}
}
+20
View File
@@ -168,6 +168,26 @@
</small>
</div>
</div>
<div class="form-group row">
<label class="col-xl-3 form-control-label">
kosten derden
</label>
<div class="col-xl-4">
<div class="input-group input-group-icon">
<span class="input-group-addon">
<i class="icon fa-euro"></i>
</span>
<input type="text"
placeholder="eigen omzet"
class="form-control align-right"
data-bind="textInput:costs,
event:{keyup:validateNumber}">
</div>
<small>
kosten derden (incl btw)
</small>
</div>
</div>
<div class="form-group row">
<label class="col-xl-3 form-control-label">
acceptatie datum
@@ -72,6 +72,11 @@
</button>
</th>
</tr>
<tr>
<th colspan="4">
<b><h5>openstaand: <span data-bind="text:dbo.helpers.numberWithPoints(Math.round(outstanding()))"></span></h5></b>
</th>
</tr>
</tfoot>
</table>
</div>
@@ -86,7 +86,7 @@
</div>
<div class="col-md-3">
<div class="form-group row">
<h4 class="form-control-label">eigenomzet:
<h4 class="form-control-label">eigen omzet:
<i class="icon fa-euro"> </i><span data-bind="text:ownRevenue"></span>
</h4>
</div>
+6 -6
View File
@@ -55,19 +55,19 @@
<!-- <div class="col-md-5">-->
<!-- --><?php //$this->load->view( 'modals/partials/_projectoffers' ); ?>
<!-- </div>-->
<div class="col-md-7">
<div class="col-md-8">
<?php $this->load->view( 'modals/partials/_projectcosts' ); ?>
</div>
<div class="col-md-5">
<?php $this->load->view('modals/partials/_forecasts'); ?>
<div class="col-md-4">
<?php $this->load->view( 'modals/partials/_reservations' ); ?>
</div>
</div>
<div class="row">
<div class="col-md-9">
<div class="col-md-8">
<?php $this->load->view( 'modals/partials/_invoices' ); ?>
</div>
<div class="col-md-3">
<?php $this->load->view( 'modals/partials/_reservations' ); ?>
<div class="col-md-4">
<?php $this->load->view('modals/partials/_forecasts'); ?>
</div>
</div>
</div>
@@ -22,7 +22,6 @@
optionsText:'fullname',
optionsValue:'id',
value:$root.selectedEmployeeID,
optionsCaption:'alle...',
event:{change:refreshEmployeehours}"></select>
</div>
</div>
@@ -42,7 +41,7 @@
</thead>
<tbody data-bind="foreach:employeehours">
<tr>
<td data-bind="css:{'red-line': id == 0}">
<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"
@@ -52,16 +51,17 @@
value:employee_id,
optionsCaption: 'selecteer...',
visible:inEdit(),
enable: ! $root.selectedEmployeeID,
event:{change:$root.changeEmployee}"></select>
</td>
<td data-bind="css:{'red-line': id == 0}">
<td data-bind="css:{'red-line': id() == 0}">
<span data-bind="text:hourdate, visible:! inEdit()"></span>
<input class="form-control form-control-sm"
data-bind="datepicker:{dateFormat: 'dd-mm-yy' },
value:hourdate, visible:inEdit(),
event:{change:$root.saveEmployeehour}"
</td>
<td data-bind="css:{'red-line': id == 0}">
<td data-bind="css:{'red-line': id() == 0}">
<span data-bind="text:dbo.helpers.findArrayElement('id', 'description', hourtype_id(), $root.hourtypes()),
visible: ! inEdit()"></span>
<select class="form-control form-control-sm"
@@ -73,7 +73,7 @@
visible:inEdit(),
event:{change:$root.saveEmployeehours}"></select>
</td>
<td data-bind="css:{'red-line': id == 0}">
<td data-bind="css:{'red-line': id() == 0}">
<!-- ko if: hourType() == 'PROJECTS' -->
<span data-bind="text:dbo.helpers.findArrayElement('projectID', 'projectname', projectID(), projects()),
visible: ! inEdit()"></span>
@@ -83,10 +83,11 @@
optionsValue:'projectID',
value:projectID,
optionsCaption:'selecteer...',
visible:inEdit()"></select>
visible:inEdit(),
event:{change:$root.saveEmployeehours}"></select>
<!-- /ko -->
</td>
<td class="align-right" data-bind="css:{'red-line': id == 0}">
<td class="align-right" data-bind="css:{'red-line': id() == 0}">
<span data-bind=" visible: ! inEdit()">
<span data-bind="text:hours"></span>
uur
@@ -97,7 +98,7 @@
data-bind="textInput:hours, visible:inEdit,
event:{change:$root.saveEmployeehours,keyup:$root.validateNumber.bind($data, 'hours')}"/>
</td>
<td data-bind="css:{'red-line': id == 0}">
<td data-bind="css:{'red-line': id() == 0}">
<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>
@@ -7,7 +7,7 @@
<select class="form-control form-control-sm"
data-bind="options:years,
optionsText:'year',
optionsValue: 'id',
optionsValue: 'year',
value:selectedYear,
event:{change:refreshTab}"></select>
</div>
@@ -22,17 +22,17 @@
</th>
<!-- /ko -->
<th class="rotate">
<div><span>totaal</span></div>
<div><span>eigen budget beschikbaar (ex btw)</span></div>
</th>
<th class="rotate">
<div><span>budget (ex btw)</span></div>
</th>
<th class="rotate">
<div><span>derden (ex btw)</span></div>
</th>
<th class="rotate">
<div><span>beschikbaar</span></div>
<div><span>totaal geschreven omzet</span></div>
</th>
<!-- <th class="rotate">-->
<!-- <div><span>derden (ex btw)</span></div>-->
<!-- </th>-->
<!-- <th class="rotate">-->
<!-- <div><span>beschikbaar</span></div>-->
<!-- </th>-->
<th class="rotate">
<div><span>saldo</span></div>
</th>
@@ -58,21 +58,21 @@
<span data-bind="text:revenues"></span>
</td>
<!-- /ko -->
<th class="align-right">
<td class="align-right">
<span data-bind="text:ownRevenue"></span>
</td>
<td class="align-right">
<span data-bind="text:totalEmployeeRevenues"></span>
</th>
<td class="align-right">
<span data-bind="text:budget"></span>
</td>
<td class="align-right">
<span data-bind="text:externCosts"></span>
</td>
<th class="align-right">
<span data-bind="text:budgetAvailable"></span>
</th>
<th class="align-right">
<span data-bind="text:saldo"></span>
<span data-bind="text:availableRevenue"></span>
</th>
<!-- <td class="align-right">-->
<!-- <span data-bind="text:externCosts"></span>-->
<!-- </td>-->
<!-- <th class="align-right">-->
<!-- <span data-bind="text:saldo"></span>-->
<!-- </th>-->
<th class="align-right">
<span data-bind="text:workInProgress"></span>
</th>
@@ -91,21 +91,21 @@
<span data-bind="text:totalRevenue"></span>
</th>
<!-- /ko -->
<th class="align-right">
<span data-bind="text:totalOwnRevenue"></span>
</th>
<th class="align-right">
<span data-bind="text:totalEmployeeRevenues"></span>
</th>
<th class="align-right">
<span data-bind="text:totalBudget"></span>
</th>
<th class="align-right">
<span data-bind="text:totalCosts"></span>
</th>
<th class="align-right">
<span data-bind="text:totalAvailableBudget"></span>
</th>
<th class="align-right">
<span data-bind="text:totalSaldo"></span>
<span data-bind="text:totalAvailableRevenues"></span>
</th>
<!-- <th class="align-right">-->
<!-- <span data-bind="text:totalCosts"></span>-->
<!-- </th>-->
<!-- <th class="align-right">-->
<!-- <span data-bind="text:totalSaldo"></span>-->
<!-- </th>-->
<th class="align-right">
<span data-bind="text:totalWorkInProgress"></span>
</th>
+5 -2
View File
@@ -21,6 +21,7 @@ $( function () {
offerleader_id : ko.observable(),
own_revenue : ko.observable(),
other_revenue : ko.observable(),
costs : ko.observable(),
hasProject : ko.observable(),
init: function ( callback = false ) {
@@ -58,6 +59,7 @@ $( function () {
offernumber : vm.offernumber(),
own_revenue : vm.own_revenue(),
other_revenue : vm.other_revenue(),
costs : vm.costs(),
startdate : vm.startdate(),
acceptance_chance: vm.acceptance_chance(),
accepteddate : vm.accepteddate(),
@@ -68,7 +70,7 @@ $( function () {
if ( data.createProject ) {
tellMe( {
title : 'project aanmaken',
message : 'De offerte is goedgekeurt maar nog niet gekoppeld aan een project, wilt u een project aanmaken?',
message : 'De offerte is goedgekeurd maar nog niet gekoppeld aan een project, wilt u een project aanmaken?',
notify : true,
noText : 'Nee, maak geen project aan',
yesText : 'Ja, maak een project aan',
@@ -136,7 +138,8 @@ $( function () {
vm.accepteddate( offer.accepteddate || null );
vm.rejectdate( offer.rejectdate || null );
vm.own_revenue( offer.own_revenue || 0 );
vm.other_revenue( offer.other_revenue || 0 )
vm.other_revenue( offer.other_revenue || 0 );
vm.costs( offer.costs || 0 );
},
showOfferModal: function () {
+11 -7
View File
@@ -41,6 +41,9 @@ $( function () {
projectname : ko.observable(),
years : ko.observableArray( dbo.years ),
months : ko.observableArray( dbo.monthArray ),
outstanding : ko.observable(),
toForecast : ko.observable(),
totalForecast : ko.observable(),
init: function () {
var vm = dbo.editProjectModal;
@@ -700,14 +703,15 @@ $( function () {
vm.enddate( dbo.helpers.mysql2date( data.enddate ) );
vm.projectnumber( data.projectnumber );
vm.projectname( data.projectname );
vm.outstanding( data.outstanding );
vm.projectEmployees.removeAll();
vm.projecthours.removeAll();
$.each( data.projectemployees, function ( i, p ) {
_.each( data.projectemployees, function ( p ) {
vm.projectEmployees.push( new vm.Projectemployee( p ) );
} );
$.each( data.projectemployees, function ( i, p ) {
_.each( data.projectemployees, function ( p ) {
var fullname = p.user ? p.user.fullname : '#NB';
$.each( p.projecthours, function ( b, q ) {
vm.projecthours.push( new vm.Projecthour( q, fullname ) );
@@ -715,12 +719,12 @@ $( function () {
} );
vm.projectcosts.removeAll();
$.each( data.projectcosts, function ( i, p ) {
_.each( data.projectcosts, function ( p ) {
vm.projectcosts.push( new vm.Projectcost( p ) );
} );
vm.offers.removeAll();
$.each( data.offers, function ( i, p ) {
_.each( data.offers, function ( p, i ) {
if ( i == 0 ) {
vm.ownRevenue( p.own_revenue );
vm.otherRevenue( p.other_revenue );
@@ -729,17 +733,17 @@ $( function () {
} );
vm.invoices.removeAll();
$.each( data.invoices, function ( i, p ) {
_.each( data.invoices, function ( p ) {
vm.invoices.push( new vm.Invoice( p ) );
} );
vm.forecasts.removeAll();
$.each( data.forecasts, function ( i, p ) {
_.each( data.forecasts, function ( p ) {
vm.forecasts.push( new vm.Forecast( p ) );
} );
vm.reservations.removeAll();
$.each( data.reservations, function ( i, p ) {
_.each( data.reservations, function ( p ) {
vm.reservations.push( new vm.Reservation( p ) );
} );
@@ -27,6 +27,8 @@ dbo.employeehoursInit = function () {
init: function () {
var vm = dbo.employeehoursModel;
vm.busy = true;
vm.months( dbo.monthArray );
vm.years( dbo.years );
@@ -42,6 +44,7 @@ dbo.employeehoursInit = function () {
} );
vm.selectedEmployeeID( dbo.currentUser.id )
vm.busy = false;
vm.refreshEmployeehours();
} );
} );
@@ -89,7 +92,7 @@ dbo.employeehoursInit = function () {
if ( self.hourType() == 'PROJECTS' && !self.projectID() ) return;
var submitDATA = {
id : self.id,
id : self.id(),
employee_id: self.employee_id(),
hourdate : self.hourdate(),
hourtype_id: self.hourtype_id(),
@@ -99,11 +102,12 @@ dbo.employeehoursInit = function () {
};
dbo.employeehoursDataService.saveEmployeehour( submitDATA, function ( data ) {
self.id = data.employeehourID;
self.id( data.employeehourID );
} );
},
editEmployeehour: function () {
dbo.employeehoursModel.saveEmployeehours( this );
this.inEdit( !this.inEdit() );
},
@@ -129,7 +133,7 @@ dbo.employeehoursInit = function () {
modalClass: 'modal-warning'
}, function ( response ) {
if ( response ) {
dbo.employeehoursDataService.removeEmployeehour( self.id, function ( data ) {
dbo.employeehoursDataService.removeEmployeehour( self.id(), function ( data ) {
if ( data.result ) {
vm.refreshEmployeehours();
} else {
@@ -147,6 +151,8 @@ dbo.employeehoursInit = function () {
refreshEmployeehours: function () {
var vm = dbo.employeehoursModel;
if( vm.busy == true ) return;
var employeeID = vm.selectedEmployeeID() || 0;
vm.employeehours.removeAll();
@@ -185,7 +191,7 @@ dbo.employeehoursInit = function () {
var vm = dbo.employeehoursModel;
var self = this;
self.id = data.id;
self.id = ko.observable( data.id );
self.employee_id = ko.observable( data.employee_id );
self.hourtype_id = ko.observable( data.hourtype_id );
self.hourdate = ko.observable( data.hourdate );
@@ -218,4 +224,4 @@ dbo.employeehoursInit = function () {
ko.applyBindings( dbo.employeehoursModel, document.getElementById( 'EMPLOYEEHOURS' ) );
}
}
}
@@ -24,9 +24,11 @@ dbo.monthlyemployeehoursInit = function () {
recap : ko.observableArray( [] ),
totalPerEmployee : ko.observableArray( [] ),
totalEmployeeRevenues : ko.observable(),
totalAvailableRevenues : ko.observable(),
totalEmployeeHours : ko.observable(),
totalEmployeeAvailableHours: ko.observable(),
totalBudget : ko.observable(),
totalOwnRevenue : ko.observable(),
totalCosts : ko.observable(),
totalAvailableBudget : ko.observable(),
totalSaldo : ko.observable(),
@@ -37,12 +39,8 @@ dbo.monthlyemployeehoursInit = function () {
var vm = dbo.monthlyEmployeeHoursModel;
dbo.reportsDataService.getUsedYears( function ( data ) {
vm.years.removeAll();
$.each( data, function ( i, p ) {
vm.years.push( {id: p.year, year: p.year} );
} );
vm.selectedYear( (new Date()).getFullYear() );
vm.years( dbo.years )
vm.selectedYear( dbo.currentYear );
} );
vm.initModule();
@@ -51,11 +49,13 @@ dbo.monthlyemployeehoursInit = function () {
initModule: function () {
var vm = dbo.monthlyEmployeeHoursModel;
vm.totalBudget( 0 );
vm.totalOwnRevenue( 0 );
vm.totalCosts( 0 );
vm.totalAvailableBudget( 0 );
vm.totalSaldo( 0 );
vm.totalWorkInProgress( 0 );
vm.totalEmployeeRevenues( 0 );
vm.totalAvailableRevenues(0)
vm.totalEmployeeHours( 0 );
vm.totalEmployeeAvailableHours( 0 );
vm.totalPerEmployee.removeAll();
@@ -78,11 +78,13 @@ dbo.monthlyemployeehoursInit = function () {
vm.recap.push( new vm.Project( p ) )
} );
vm.totalBudget( dbo.helpers.thousandSeparator( vm.totalBudget() ) );
vm.totalOwnRevenue( dbo.helpers.thousandSeparator( vm.totalOwnRevenue() ) );
vm.totalCosts( dbo.helpers.thousandSeparator( vm.totalCosts() ) );
vm.totalAvailableBudget( dbo.helpers.thousandSeparator( vm.totalAvailableBudget() ) );
vm.totalSaldo( dbo.helpers.thousandSeparator( vm.totalSaldo() ) );
vm.totalWorkInProgress( dbo.helpers.thousandSeparator( vm.totalWorkInProgress() ) );
vm.totalEmployeeRevenues( dbo.helpers.thousandSeparator( vm.totalEmployeeRevenues() ) );
vm.totalAvailableRevenues( dbo.helpers.thousandSeparator( vm.totalAvailableRevenues() ) );
vm.totalEmployeeHours( dbo.helpers.thousandSeparator( vm.totalEmployeeHours() ) );
_.each( vm.totalPerEmployee(), function ( p ) {
p.totalRevenue( dbo.helpers.thousandSeparator( p.totalRevenue() ) );
@@ -286,8 +288,10 @@ dbo.monthlyemployeehoursInit = function () {
self.revenues = dbo.helpers.thousandSeparator( data.budget );
self.hours = data.hours;
self.totalEmpoloyeeRevenues = 0;
self.availableRevenue = data.own_revenue - data.projectEuros;
self.externCosts = dbo.helpers.thousandSeparator( data.projectcosts );
self.budget = dbo.helpers.thousandSeparator( data.budget );
self.ownRevenue = dbo.helpers.thousandSeparator( data.own_revenue );
self.budgetAvailable = dbo.helpers.thousandSeparator( data.budgetAvailable );
self.saldo = dbo.helpers.thousandSeparator( data.saldo );
@@ -300,10 +304,12 @@ dbo.monthlyemployeehoursInit = function () {
self.totalEmployeeRevenues = data.projectEuros;
self.totalEmployeeHours = data.projectHours;
self.hoursAvailable = data.hoursAvailable;
vm.totalAvailableRevenues( vm.totalAvailableRevenues() + self.availableRevenue );
vm.totalEmployeeRevenues( vm.totalEmployeeRevenues() + Number( self.totalEmployeeRevenues ) );
vm.totalEmployeeHours( vm.totalEmployeeHours() + Number( self.totalEmployeeHours ) );
vm.totalEmployeeAvailableHours( vm.totalEmployeeAvailableHours() + Number( self.hoursAvailable ) );
self.totalEmployeeRevenues = dbo.helpers.thousandSeparator( self.totalEmployeeRevenues );
self.availableRevenue = dbo.helpers.thousandSeparator( self.availableRevenue );
self.workInProgress = dbo.helpers.thousandSeparator( data.workInProgress );
self.hoursAvailable = data.hoursAvailable;
@@ -319,8 +325,9 @@ dbo.monthlyemployeehoursInit = function () {
var vm = dbo.monthlyEmployeeHoursModel;
vm.totalBudget( vm.totalBudget() + Number( data.budget ) );
vm.totalOwnRevenue( vm.totalOwnRevenue() + Number( data.own_revenue ) );
vm.totalCosts( vm.totalCosts() + Number( data.projectcosts ) );
vm.totalAvailableBudget( vm.totalAvailableBudget() + Number( data.budgetAvailable ) );
vm.totalAvailableBudget( vm.totalAvailableBudget() + Number( data.ownRevenueAvailable ) );
vm.totalSaldo( vm.totalSaldo() + Number( data.saldo ) );
vm.totalWorkInProgress( vm.totalWorkInProgress() + Number( data.workInProgress ) );
+1
View File
@@ -105,6 +105,7 @@ dbo.offersService = {
this.acceptance_chance = data.acceptance_chance ? data.acceptance_chance : 0;
this.own_revenue = data.own_revenue;
this.other_revenue = data.other_revenue;
this.costs = data.costs;
this.archive = data.archive;
}
};