Diversen nav opmerkingen

This commit is contained in:
2018-05-03 19:54:32 +02:00
parent 6bc0b37f06
commit 860c5db95a
18 changed files with 405 additions and 143 deletions
@@ -5,8 +5,8 @@
* Date: 21/04/2018
* Time: 20:08
*/
//include_once('../application/models/eloquent/Employeetarget.php');
//include_once('../application/models/eloquent/Employeetarget.php');
class EmployeeTargetController extends MY_Controller {
@@ -30,5 +30,26 @@ class EmployeeTargetController extends MY_Controller {
$this->json( $employeeTargets );
}
public function saveEmployeeTarget()
{
$employeeTargetValidation = new EmployeeTargetValidation();
if ( ! $employeeTargetValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $employeeTargetValidation->getErrorMessages()] );
$target = $this->input->post();
$targetID = $target['id'];
unset( $target['id'] );
$target['endmonth'] = $target['endmonth'] ? $target['endmonth'] : NULL;
$target['endyear'] = $target['endyear'] ? $target['endyear'] : NULL;
$targetID = Employeetarget::saveTarget( $targetID, $target );
$this->json( ['success' => TRUE, 'targetID' => $targetID] );
}
}
@@ -51,6 +51,11 @@ class ReportsController extends MY_Controller {
$result = $query->result();
foreach($result as $user)
{
$user->targethours = Employeetarget::getTargetHoursPerEmployee( $user->user_id, $year, $month);
}
$this->json( $result );
}
@@ -27,22 +27,30 @@ class ReservationsController extends MY_Controller {
{
$projects[ $result->projectID ] = [
'projectnumber' => $result->projectnumber,
'costs' => 0,
'reservation' => 0,
'payed' => 0,
'saldo' => 0,
'saldoToPay' => 0,
'other_revenue' => 0,
'customers' => []
];
}
$projects[ $result->projectID ]['reservation'] += $result->reservation;
$projects[ $result->projectID ]['costs'] += $result->costs;
$projects[ $result->projectID ]['payed'] += $result->payed;
$projects[ $result->projectID ]['saldo'] += $result->saldo;
$projects[ $result->projectID ]['saldoToPay'] += $result->saldoToPay;
$projects[ $result->projectID ]['other_revenue'] = $result->other_revenue;
$projects[ $result->projectID ]['externals'][] = [
'external' => $result->contactperson,
'reservation' => $result->reservation,
'costs' => $result->costs,
'payed' => $result->payed,
'saldo' => $result->saldo
'saldo' => $result->saldo,
'saldoToPay' => $result->saldoToPay
];
}
@@ -0,0 +1,40 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 10/07/16
* Time: 13:35
*/
require_once( APPPATH . 'libraries/validation/inputValidations/BaseValidation.php' );
class EmployeeTargetValidation extends BaseValidation {
protected $validationFields = [
'user_id' => [
'validations' => 'required|integer',
'fieldname' => 'gebruiker'
],
'startmonth' => [
'validations' => 'required|decimal',
'fieldname' => 'startmaand'
],
'startyear' => [
'validations' => 'required|integer',
'fieldname' => 'startjaar'
],
'target' =>[
'validations' => 'integer',
'fieldname' => 'uren target'
]
];
public function __construct()
{
parent::__construct();
$this->ci =& get_instance();
}
}
@@ -15,4 +15,48 @@ class Employeetarget extends BaseModel {
return $this->belongsTo( 'User' );
}
public static function saveTarget( $targetID, $target )
{
$target = (array) $target;
if ( $targetID == 0 )
{
$target = self::create( $target );
$targetID = $target['id'];
}
else
{
self::whereId( $targetID )->update( $target );
}
return $targetID;
}
public static function getTargetHoursPerEmployee( $employeeID, $year, $monthID )
{
$months = $monthID == 0 ? [1,2,3,4,5,6,7,8,9,10,11,12] : [$monthID];
$targetHours = 0;
foreach($months as $month)
{
$targetHours += self::getCurrentMonthTarget( $employeeID, $year, $month);
}
return $targetHours;
}
public static function getCurrentMonthTarget( $employeeID, $year, $month )
{
$monthTarget = Self::whereUserId($employeeID)
->where('startyear', '<=', $year)
->where('startmonth', '<=', $month)
->orderBy('startyear', 'DESC')
->orderBy('startmonth', 'DESC');
if( $monthTarget->count() == 0 ) return 0;
return $monthTarget->first()->target;
}
}
@@ -14,12 +14,12 @@ class QEmployeeHours {
SELECT monthID,
user_id,
CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname,
SUM(projecthours) AS projecthours,
SUM(profitablehours) AS profitablehours,
SUM(nonprofitablehours) AS nonprofitablehours,
SUM(revenues) AS revenues,
SUM(nonprojecthours) AS nonprojecthours,
SUM(projecthours + nonprojecthours) AS totalhours,
ROUND(SUM(projecthours), 0) AS projecthours,
ROUND(SUM(profitablehours), 0) AS profitablehours,
ROUND(SUM(nonprofitablehours), 0) AS nonprofitablehours,
ROUND(SUM(revenues), 0) AS revenues,
ROUND(SUM(nonprojecthours), 0) AS nonprojecthours,
ROUND(SUM(projecthours + nonprojecthours), 0) AS totalhours,
targethours
FROM (
SELECT employee_id AS user_id,
@@ -10,31 +10,47 @@ class ReservationTotals {
public static function fire()
{
$sql = "SELECT projectID, externalID, reservation, payed, (reservation - payed) AS saldo, PRJ.projectnumber, EXT.contactperson
// UNION ALL wordt gebruikt voor een full outer join
$sql = "SELECT Q5.project_id AS projectID, external_id AS externalID,
costs, reservation, payed, (reservation - payed) AS saldo,
(costs - payed) AS saldoToPay, PRJ.projectnumber, EXT.contactperson,
ROUND(( (other_revenue * (100 + (SELECT vatrate from vats where active='T' LIMIT 1))) / 100 ), 0) other_revenue
FROM (
SELECT COALESCE(RES.project_id, PRC.project_id) AS projectID,
COALESCE(RES.external_id, PRC.external_id) AS externalID,
SUM(COALESCE(reservationamount, 0)) AS reservation,
SUM(COALESCE(payed, 0)) AS payed
FROM reservations RES
LEFT JOIN projectcosts PRC
ON RES.project_id = PRC.project_id AND RES.external_id = PRC.external_id
GROUP BY COALESCE(RES.project_id, PRC.project_id), COALESCE(PRC.external_id, PRC.external_id)
SELECT COALESCE(reservation, 0) AS reservation, costs, payed, Q2.external_id, Q2.project_id
FROM (
SELECT SUM(reservationamount) AS reservation, external_id, project_id
FROM reservations
GROUP BY external_id, project_id
) Q1
RIGHT JOIN
(
SELECT SUM(costs) AS costs, SUM(payed) AS payed, external_id, project_id
FROM projectcosts
GROUP BY external_id, project_id
) Q2
ON Q1.external_id = Q2.external_id AND Q1.project_id = Q2.project_id
UNION ALL
SELECT COALESCE(RES.project_id, PRC.project_id) AS projectID,
COALESCE(RES.external_id, PRC.external_id) AS externalID,
SUM(COALESCE(reservationamount, 0)) AS reservation,
SUM(COALESCE(payed, 0)) AS payed
FROM reservations RES
RIGHT JOIN projectcosts PRC
ON RES.project_id = PRC.project_id AND RES.external_id = PRC.external_id
WHERE RES.id IS NULL
GROUP BY COALESCE(RES.project_id, PRC.project_id), COALESCE(RES.external_id, PRC.external_id)
SELECT reservation, COALESCE(costs, 0), COALESCE(payed, 0), Q3.external_id, Q3.project_id
FROM (
SELECT SUM(reservationamount) AS reservation, external_id, project_id
FROM reservations
GROUP BY external_id, project_id
) Q3
LEFT JOIN
(
SELECT SUM(costs) AS costs, SUM(payed) AS payed, external_id, project_id, id
FROM projectcosts
GROUP BY external_id, project_id
) Q4
ON Q3.external_id = Q4.external_id AND Q3.project_id = Q4.project_id
WHERE Q4.id IS NULL
) Q5
JOIN projects PRJ
ON PRJ.id = Q3.projectID
ON PRJ.id = Q5.project_id
JOIN externals EXT
ON EXT.id = Q3.externalID ";
ON EXT.id = Q5.external_id
JOIN offers OFF
ON PRJ.id = OFF.project_id ";
return $sql;
}
@@ -1,5 +1,5 @@
<div class="modal modal-fade-in-scale-up modal-primary" tabindex="-1" id="employee-target-modal">
<div class="modal-dialog" role="document">
<div class="modal-dialog" role="document" style="width:700px;">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">toevoegen / wijzigen medewerker uren
@@ -10,7 +10,7 @@
</div>
<div class="modal-body">
<div class="row">
<div class="col-md-10 col-md-offset-1">
<div class="col-md-12">
<table class="table table-condensed">
<thead>
<tr>
@@ -19,60 +19,72 @@
<th colspan="2">&nbsp;</th>
</tr>
<tr>
<th>maand</th>
<th>jaar</th>
<th>maand</th>
<th>jaar</th>
<th>target per maand</th>
<th width="25%">maand</th>
<th width="17%">jaar</th>
<th width="25%">maand</th>
<th width="17%">jaar</th>
<th width="16%" title="target per maand">target p/m</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
<!-- ko foreach:employeeTargets -->
<tr>
<td>
<select data-bind="options:years,
<td data-bind="css:{'red-line': ! saved()}">
<select data-bind="options:$root.months,
optionsText:'month',
optionsValue:'monthID',
value:startmonth,
disable: ! changeable(),
event:{change:$root.setUnsaved}"
class="form-control">
</select>
</td>
<td data-bind="css:{'red-line': ! saved()}">
<select data-bind="options:$root.years,
optionsText:'year',
optionsValue:'year',
value:startyear,
disable: ! changeable()"
disable: ! changeable(),
event:{change:$root.setUnsaved}"
class="form-control">
</select>
</td>
<td>
<select data-bind="options:months,
<td data-bind="css:{'red-line': ! saved()}">
<select data-bind="options:$root.months,
optionsText:'month',
optionsValue:'month_id',
value:startmonth,
disable: ! changeable()"
optionsValue:'monthID',
value:endmonth,
disable: ! changeable(),
optionsCaption:'selecteer...',
event:{change:$root.setUnsaved}"
class="form-control">
</select>
</td>
<td>
<select data-bind="options:years,
<td data-bind="css:{'red-line': ! saved()}">
<select data-bind="options:$root.years,
optionsText:'year',
optionsValue:'year',
value:endyear,
disable: ! changeable()"
disable: ! changeable(),
optionsCaption:'selecteer...',
event:{change:$root.setUnsaved}"
class="form-control">
</select>
</td>
<td>
<select data-bind="options:months,
optionsText:'month',
optionsValue:'month_id',
value:endmonth"
class="form-control">
</select>
</td>
<td>
<td data-bind="css:{'red-line': ! saved()}">
<input type="text"
class="form-control"
data-bind="textInput:target">
data-bind="textInput:target,
disable: ! changeable(),
event:{keyup:$root.checkNumeric},
event:{change:$root.setUnsaved}">
</td>
<td>
<td data-bind="css:{'red-line': ! saved()}">
<button class="btn btn-success"
data-bind="disable: ! validTarget()">
data-bind="disable: ! validTarget(),
click:$root.saveEmployeeTarget,
visible: changeable()">
opslaan
</button>
</td>
@@ -83,7 +95,7 @@
<tr>
<th colspan="6">
<i class="icon fa-plus-square-o pull-right pointer"
data-bind="click:addEmployeeTarget"></i>
data-bind="click:addEmployeeTarget, visible:newTarget()"></i>
</th>
</tr>
</tfoot>
@@ -5,12 +5,10 @@
<label>jaar</label>
</div>
<div class="col-md-2">
<div class="col-md-2">
<input type="text" class="form-control" data-bind="textInput:selectedYear, event:{keyup:checkYear}" >
<input type="text" class="form-control" data-bind="textInput:selectedYear, event:{keyup:checkYear}">
<div class="invalid-feedback" data-bind="visible: ! validYear()">geen geldig jaar</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="nav-tabs-horizontal">
@@ -24,7 +22,7 @@
</ul>
<div class="tab-content">
<div class="tab-pane active">
<?php $this->load->view('reports/employeehours/employeemonthhours_view'); ?>
<?php $this->load->view( 'reports/employeehours/employeemonthhours_view' ); ?>
</div>
</div>
</div>
@@ -1,15 +1,11 @@
<div id="OUTGOINGINVOICES">
<div class="row">
<div class="col-xl-1">
<div class="col-md-1">
<label>jaar</label>
</div>
<div class="col-xl-3">
<select class="form-control form-control-sm"
data-bind="options:years,
optionsText:'year',
optionsValue: 'id',
value:selectedYear,
event:{change:refreshInvoiceDetails}"></select>
<div class="col-md-2">
<input type="text" class="form-control" data-bind="textInput:selectedYear, event:{keyup:checkYear}">
<div class="invalid-feedback" data-bind="visible: ! validYear()">geen geldig jaar</div>
</div>
</div>
<div class="row">
+42 -2
View File
@@ -1,14 +1,18 @@
<div id="RESERVATIONS">
<div class="row">
<div class="col-md-6">
<div class="col-md-12">
<table class="table table-condensed">
<thead>
<tr>
<th width="5px">&nbsp;</th>
<th>project</th>
<th class="align-right">Budget derden</th>
<th class="align-right">gefactureerd</th>
<th class="align-right">gereserveerd</th>
<th class="align-right">betaald</th>
<th class="align-right">saldo</th>
<th class="align-right">saldo te betalen</th>
<th class="align-right">saldo reservering</th>
<th class="align-right">saldo te factureren</th>
</tr>
</thead>
<!-- ko foreach:projects -->
@@ -25,15 +29,27 @@
<th>
<span data-bind="text:projectnumber"></span>
</th>
<th class="align-right" data-bind="visible: ! showExternals()">
<span data-bind="text:otherRevenue"></span>
</th>
<th class="align-right" data-bind="visible: ! showExternals()">
<span data-bind="text:costs"></span>
</th>
<th class="align-right" data-bind="visible: ! showExternals()">
<span data-bind="text:reservation"></span>
</th>
<th class="align-right" data-bind="visible: ! showExternals()">
<span data-bind="text:payed"></span>
</th>
<th class="align-right" data-bind="visible: ! showExternals()">
<span data-bind="text:saldoToPay"></span>
</th>
<th class="align-right" data-bind="visible: ! showExternals()">
<span data-bind="text:saldo"></span>
</th>
<th class="align-right" data-bind="visible: ! showExternals()">
<span data-bind="text:saldoInvoices"></span>
</th>
</tr>
<!-- ko if:showExternals() -->
<!-- ko foreach: externals -->
@@ -42,30 +58,50 @@
<td>
<span data-bind="text:externalName"></span>
</td>
<td>&nbsp</td>
<td class="align-right">
<span data-bind="text:costs"></span>
</td>
<td class="align-right">
<span data-bind="text:reservation"></span>
</td>
<td class="align-right">
<span data-bind="text:payed"></span>
</td>
<td class="align-right">
<span data-bind="text:saldoToPay"></span>
</td>
<td class="align-right">
<span data-bind="text:saldo"></span>
</td>
<td>&nbsp;</td>
</tr>
<!-- /ko -->
<!-- /ko -->
<!-- ko if:showExternals() -->
<tr class="subtotal">
<th colspan="2">Totaal</th>
<th class="align-right">
<span data-bind="text:otherRevenue"></span>
</th>
<th class="align-right">
<span data-bind="text:costs"></span>
</th>
<th class="align-right">
<span data-bind="text:reservation"></span>
</th>
<th class="align-right">
<span data-bind="text:payed"></span>
</th>
<th class="align-right">
<span data-bind="text:saldoToPay"></span>
</th>
<th class="align-right">
<span data-bind="text:saldo"></span>
</th>
<th class="align-right">
<span data-bind="text:saldoInvoices"></span>
</th>
</tr>
<!-- /ko -->
</tbody>
@@ -73,9 +109,13 @@
<tfoot>
<tr class="grandtotal">
<th colspan="2">Grand totaal</th>
<th class="align-right"><span data-bind="text:otherRevenue"></span></th>
<th class="align-right"><span data-bind="text:costs"></span></th>
<th class="align-right"><span data-bind="text:reservation"></span></th>
<th class="align-right"><span data-bind="text:payed"></span></th>
<th class="align-right"><span data-bind="text:saldoToPay"></span></th>
<th class="align-right"><span data-bind="text:saldo"></span></th>
<th class="align-right"><span data-bind="text:saldoInvoices"></span></th>
</tr>
</tfoot>
</table>
@@ -8,7 +8,7 @@
<th class="rotate"><div><span>uren niet declarabel</span></div></th>
<th class="rotate"><div><span>uren indirect</span></div></th>
<th class="rotate"><div><span>totaal bestede uren</span></div></th>
<th class="rotate"><div><span>uren target(1.600 jaar)</span></div></th>
<th class="rotate"><div><span>uren jaartarget</span></div></th>
<th class="rotate"><div><span>aandeel uren besteed tov target</span></div></th>
<th class="rotate"><div><span>bezettingsgraad totaal<br />aantal gewerkte uren</span></div></th>
<th class="rotate"><div><span>bezettingsgraad t.o.v. target<br />factureerbare uren</span></div></th>
@@ -14,8 +14,12 @@ dbo.employeeTargetDataService = {
} );
},
addEmployeeTarget: function ( employeeID, callback ) {
$.post()
saveEmployeeTarget: function ( submitDATA, callback ) {
$.post( 'index.php/beheer/employeetargetController/saveEmployeeTarget', submitDATA, function () {
}, 'json' )
.done( function ( data ) {
callback( data );
} );
}
+6
View File
@@ -91,5 +91,11 @@ dbo.helpers = {
if ( !myNumber ) return 0;
return myNumber.toString().replace( /\B(?=(\d{3})+(?!\d))/g, "." );
},
isNumeric: function ( n ) {
return !isNaN( parseFloat( n ) ) && isFinite( n );
}
}
+74 -17
View File
@@ -11,12 +11,20 @@ $( function () {
employeeTargets: ko.observableArray( [] ),
employeeID : null,
months : ko.observableArray( [] ),
years : ko.observableArray( [] ),
targetLength : [],
newTarget : ko.observable( true ),
busy : false,
init: function ( employeeID ) {
var vm = dbo.employeeTargetModel;
vm.employeeID = employeeID;
vm.months( dbo.monthArray );
vm.years( dbo.years );
vm.showModal();
vm.refreshEmployeeTargets();
@@ -28,55 +36,104 @@ $( function () {
addEmployeeTarget: function () {
var vm = dbo.employeeTargetModel;
var targetLength = vm.employeeTargets().length;
var lastDate = null
if ( targetLength > 0 )
var lastDate = vm.employeeTargets[targetLength - 1].enddate();
var lastYear = dbo.currentYear;
var lastMonth = dbo.currentMonth;
var data = {
startdate: lastDate,
enddate : null,
id : 0,
user_id : vm.employeeID,
startyear : lastYear,
startmonth: lastMonth,
endyear : null,
endmonth : null,
target : 0
}
vm.employeeTargets.push( new vm.Employeetarget( data ) );
vm.employeeTargets.push( new vm.Employeetarget( data, (vm.targetLength - 1), false ) );
},
checkNumeric: function () {
this.target( dbo.helpers.validateNumber( this.target() ) );
},
saveEmployeeTarget: function () {
// if
var vm = dbo.employeeTargetModel;
var self = this;
var submitDATA = {
id : self.id,
user_id : vm.employeeID,
startmonth: self.startmonth(),
startyear : self.startyear(),
endmonth : self.endmonth() || 0,
endyear : self.endyear() || 0,
target : self.target()
}
dbo.employeeTargetDataService.saveEmployeeTarget( submitDATA, function ( data ) {
if ( !data.success ) return self.saved( false );
self.saved( true );
self.id = data.targetID;
} );
},
setUnsaved: function () {
var vm = dbo.employeeTargetModel;
if ( vm.busy ) return;
this.saved( false );
},
refreshEmployeeTargets: function () {
var vm = dbo.employeeTargetModel;
vm.busy = true;
dbo.employeeTargetDataService.getEmployeeTargets( vm.employeeID, function ( data ) {
vm.employeeTargets.removeAll();
var targetLength = data.length
var i=0;
vm.targetLength = data.length
var i = 0;
_.each( data, function ( p ) {
vm.employeeTargets.push( new vm.Employeetarget( p, targetLength, i ) );
vm.employeeTargets.push( new vm.Employeetarget( p, i, true ) );
i++;
} );
vm.busy = false;
} );
},
Employeetarget: function ( data, targetLength, i ) {
Employeetarget: function ( data, i, saved ) {
var vm = dbo.employeeTargetModel;
var self = this;
vm.newTarget( true );
self.id = data.id;
self.startyear = ko.observable( data.startyear );
self.startmonth = ko.observable( data.startmonth );
self.endyear = ko.observable( data.endyear );
self.endmonth = ko.observable( data.endmonth );
self.target = ko.observable( data.target );
self.saved = ko.observable( saved );
self.changeAble = ko.pureComputed( function () {
if(i == (targetLength - 1))
self.changeable = ko.pureComputed( function () {
if ( i == (vm.targetLength - 1) ) return true;
return true;
return false;
} );
self.validTarget = ko.pureComputed( function () {
if ( !self.endmonth() && !self.endyear() ) return true;
if ( !self.endmonth() || !self.endyear() ) return false;
if ( self.endyear() == self.startyear() && self.endmonth() > self.startmonth() ) return true;
if ( self.endyear() > self.startyear() && self.endmonth() ) return true;
return false;
} );
if ( ! self.endmonth() ) vm.newTarget( false );
if ( ! self.endyear() ) vm.newTarget( false );
}
};
+9 -19
View File
@@ -51,19 +51,14 @@ dbo.employeehoursreportInit = function () {
var vm = dbo.employeeHoursreportModel;
vm.initialize = true;
dbo.reportsDataService.getUsedYears( function ( data ) {
vm.years.removeAll();
_.each( data, function ( p ) {
vm.years.push( {id: p.year, year: p.year} );
} );
vm.selectedYear( (new Date()).getFullYear() );
vm.selectedMonthID( 0 );
vm.validYear( true );
vm.initialize = false;
vm.initModule();
} );
},
initModule: function () {
@@ -73,18 +68,13 @@ dbo.employeehoursreportInit = function () {
},
checkYear: function () {
var vm = dbo.monthlyEmployeeHoursModel;
if ( timeout ) {
clearTimeout( timeout );
timeout = null;
}
timeout = setTimeout( function () {
vm.validYear( true );
var vm = dbo.employeeHoursreportModel;
if ( !Number.isInteger( Number( vm.selectedYear() ) ) ) return vm.validYear( false );
if ( Number( vm.selectedYear() ) > 2100 ) return vm.validYear( false );
if ( Number( vm.selectedYear() ) < 2000 ) return vm.validYear( false );
vm.validYear( true );
vm.initModule();
}, 700 );
},
setActivetab: function ( tab ) {
@@ -125,7 +115,7 @@ dbo.employeehoursreportInit = function () {
vm.nonprofitablehoursTotaal( Math.round( vm.nonprofitablehoursTotaal() + Number( p.nonprofitablehours ) ) );
vm.nonprojecthoursTotaal( Math.round( vm.nonprojecthoursTotaal() + Number( p.nonprojecthours ) ) );
vm.totalhoursTotaal( Math.round( vm.totalhoursTotaal() + Number( p.totalhours ) ) );
vm.targetTotaal( Math.round( vm.targetTotaal() + Number( p.targethours / 12 ) ) );
vm.targetTotaal( Math.round( vm.targetTotaal() + Number( p.targethours ) ) );
vm.revenuesTotaal( Number( vm.revenuesTotaal() ) + Number( p.revenues ) );
chartData.labels.push( p.fullname );
@@ -135,7 +125,7 @@ dbo.employeehoursreportInit = function () {
} );
vm.occupancyRateTotalTotaal( Math.round( (vm.totalhoursTotaal() / vm.targetTotaal()) * 100 ) );
vm.occupancyRateHoursTotaal( Math.round( (vm.profitablehoursTotaal() / vm.totalhoursTotaal()) * 100 ) );
vm.occupancyRateInvoiceTotaal(Math.round( (vm.profitablehoursTotaal() / vm.targetTotaal()) * 100 ));
vm.occupancyRateInvoiceTotaal( Math.round( (vm.profitablehoursTotaal() / vm.targetTotaal()) * 100 ) );
vm.averageDayRateTotaal( Math.round( Number( vm.revenuesTotaal() ) / Number( vm.profitablehoursTotaal() ) ) * 8 );
vm.revenuesTotaal( dbo.helpers.thousandSeparator( vm.revenuesTotaal() ) );
@@ -160,10 +150,10 @@ dbo.employeehoursreportInit = function () {
this.nonprofitablehours = data.nonprofitablehours;
this.nonprojecthours = data.nonprojecthours;
this.totalhours = Math.round( data.totalhours );
this.target = Math.round( data.targethours / 12 );
this.occupancyRateTotal = Math.round( (data.totalhours / (data.targethours / 12)) * 100 );
this.target = dbo.helpers.numberWithPoints( Math.round( data.targethours ) );
this.occupancyRateTotal = Math.round( (data.totalhours / data.targethours) * 100 );
this.occupancyRateHours = Math.round( (data.profitablehours / data.totalhours) * 100 );
this.occupancyRateInvoice = Math.round( (data.profitablehours / (data.targethours / 12)) * 100 );
this.occupancyRateInvoice = Math.round( (data.profitablehours / data.targethours) * 100 );
this.revenues = dbo.helpers.thousandSeparator( data.revenues );
this.averageDayRate = Math.round( (data.revenues / data.profitablehours) * 8 );
}
@@ -23,24 +23,17 @@ dbo.outgoinginvoicesInit = function () {
months : ko.observableArray( dbo.monthArray ),
totalToInvoice : ko.observable(),
totalToInvoiceFuture: ko.observable(),
initialize : null,
validYear : ko.observable(),
init: function () {
var vm = dbo.outgoinginvoicesModel;
vm.initialize = true;
dbo.reportsDataService.getUsedYears( function ( data ) {
vm.years.removeAll();
_.each( data, function ( p ) {
vm.years.push( {id: p.year, year: p.year} );
} );
vm.selectedYear( (new Date()).getFullYear() );
vm.selectedMonthID( 0 );
vm.initialize = false;
vm.validYear(true);
vm.initModule();
} );
},
setActivetab: function ( tab ) {
@@ -55,6 +48,16 @@ dbo.outgoinginvoicesInit = function () {
vm.refreshInvoiceDetails();
},
checkYear: function () {
var vm = dbo.outgoinginvoicesModel;
if ( !Number.isInteger( Number( vm.selectedYear() ) ) ) return vm.validYear( false );
if ( Number( vm.selectedYear() ) > 2100 ) return vm.validYear( false );
if ( Number( vm.selectedYear() ) < 2000 ) return vm.validYear( false );
vm.validYear( true );
vm.initModule();
},
refreshInvoiceDetails: function () {
var vm = dbo.outgoinginvoicesModel;
+23 -1
View File
@@ -13,9 +13,13 @@ dbo.reservationsInit = function () {
dbo.reservationsModel = {
projects : ko.observableArray( [] ),
reservation: ko.observable(),
costs : ko.observable(),
reservation : ko.observable(),
payed : ko.observable(),
saldo : ko.observable(),
saldoToPay : ko.observable(),
otherRevenue : ko.observable(),
saldoInvoices: ko.observable(),
init: function () {
var vm = dbo.reservationsModel;
@@ -29,17 +33,25 @@ dbo.reservationsInit = function () {
dbo.reservationsDataservice.getReservations( function ( data ) {
vm.projects.removeAll();
vm.costs( 0 );
vm.reservation( 0 );
vm.payed( 0 );
vm.saldo( 0 );
vm.saldoToPay( 0 );
vm.otherRevenue( 0 );
vm.saldoInvoices( 0 );
_.each( data, function ( p ) {
vm.projects.push( new vm.Project( p ) );
} );
vm.costs( dbo.helpers.numberWithPoints( vm.costs() ) );
vm.reservation( dbo.helpers.numberWithPoints( vm.reservation() ) );
vm.payed( dbo.helpers.numberWithPoints( vm.payed() ) );
vm.saldo( dbo.helpers.numberWithPoints( vm.saldo() ) );
vm.saldoToPay( dbo.helpers.numberWithPoints( vm.saldoToPay() ) );
vm.otherRevenue( dbo.helpers.numberWithPoints( vm.otherRevenue() ) );
vm.saldoInvoices( dbo.helpers.numberWithPoints( vm.saldoInvoices() ) );
} );
},
@@ -52,14 +64,22 @@ dbo.reservationsInit = function () {
var self = this;
self.projectnumber = data.projectnumber;
self.costs = dbo.helpers.numberWithPoints( data.costs );
self.reservation = dbo.helpers.numberWithPoints( data.reservation );
self.payed = dbo.helpers.numberWithPoints( data.payed );
self.saldo = dbo.helpers.numberWithPoints( data.saldo );
self.saldoToPay = dbo.helpers.numberWithPoints( data.saldoToPay );
self.otherRevenue = dbo.helpers.numberWithPoints( data.other_revenue );
self.saldoInvoices = dbo.helpers.numberWithPoints( data.other_revenue - data.costs );
self.showExternals = ko.observable( false );
vm.costs( Number( vm.costs() ) + Number( data.costs ) );
vm.reservation( Number( vm.reservation() ) + Number( data.reservation ) );
vm.payed( Number( vm.payed() ) + Number( data.payed ) );
vm.saldo( Number( vm.saldo() ) + Number( data.saldo ) );
vm.saldoToPay( Number( vm.saldoToPay() ) + Number( data.saldoToPay ) );
vm.otherRevenue( Number( vm.otherRevenue() ) + Number( data.other_revenue ) );
vm.saldoInvoices( Number( vm.saldoInvoices() ) + Number( data.other_revenue - data.costs ) )
self.externals = ko.observableArray( [] );
_.each( data.externals, function ( p ) {
@@ -71,9 +91,11 @@ dbo.reservationsInit = function () {
var self = this;
self.externalName = data.external;
self.costs = dbo.helpers.numberWithPoints( data.costs );
self.reservation = dbo.helpers.numberWithPoints( data.reservation );
self.payed = dbo.helpers.numberWithPoints( data.payed );
self.saldo = dbo.helpers.numberWithPoints( data.saldo );
self.saldoToPay = dbo.helpers.numberWithPoints( data.saldoToPay );
}