diff --git a/application/controllers/beheer/EmployeeTargetController.php b/application/controllers/beheer/EmployeeTargetController.php
index 63b1248..f35a620 100644
--- a/application/controllers/beheer/EmployeeTargetController.php
+++ b/application/controllers/beheer/EmployeeTargetController.php
@@ -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] );
+ }
+
}
\ No newline at end of file
diff --git a/application/controllers/reports/ReportsController.php b/application/controllers/reports/ReportsController.php
index 49404d7..2ec3db2 100644
--- a/application/controllers/reports/ReportsController.php
+++ b/application/controllers/reports/ReportsController.php
@@ -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 );
}
diff --git a/application/controllers/reports/ReservationsController.php b/application/controllers/reports/ReservationsController.php
index eb96895..6d50c1b 100644
--- a/application/controllers/reports/ReservationsController.php
+++ b/application/controllers/reports/ReservationsController.php
@@ -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
];
}
diff --git a/application/libraries/validation/inputValidations/EmployeeTargetValidation.php b/application/libraries/validation/inputValidations/EmployeeTargetValidation.php
new file mode 100644
index 0000000..ce96662
--- /dev/null
+++ b/application/libraries/validation/inputValidations/EmployeeTargetValidation.php
@@ -0,0 +1,40 @@
+ [
+ '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();
+ }
+}
\ No newline at end of file
diff --git a/application/models/eloquent/Employeetarget.php b/application/models/eloquent/Employeetarget.php
index 654c3e3..f958051 100644
--- a/application/models/eloquent/Employeetarget.php
+++ b/application/models/eloquent/Employeetarget.php
@@ -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;
+ }
+
}
\ No newline at end of file
diff --git a/application/models/eloquent/queries/QEmployeeHours.php b/application/models/eloquent/queries/QEmployeeHours.php
index 93691f0..8603af3 100644
--- a/application/models/eloquent/queries/QEmployeeHours.php
+++ b/application/models/eloquent/queries/QEmployeeHours.php
@@ -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,
diff --git a/application/models/eloquent/queries/ReservationTotals.php b/application/models/eloquent/queries/ReservationTotals.php
index 05ea508..7c7fd93 100644
--- a/application/models/eloquent/queries/ReservationTotals.php
+++ b/application/models/eloquent/queries/ReservationTotals.php
@@ -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)
- ) Q3
+ 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;
}
diff --git a/application/views/modals/employeetarget_modal.php b/application/views/modals/employeetarget_modal.php
index 424a304..4de94d6 100644
--- a/application/views/modals/employeetarget_modal.php
+++ b/application/views/modals/employeetarget_modal.php
@@ -1,16 +1,16 @@
-
+
-
+
@@ -19,60 +19,72 @@
| |
- | maand |
- jaar |
- maand |
- jaar |
- target per maand |
+ maand |
+ jaar |
+ maand |
+ jaar |
+ target p/m |
|
- |
- |
+
+
|
-
-
+
|
-
-
+
|
-
-
-
- |
-
+ |
+ data-bind="textInput:target,
+ disable: ! changeable(),
+ event:{keyup:$root.checkNumeric},
+ event:{change:$root.setUnsaved}">
|
-
+ |
|
@@ -83,7 +95,7 @@
|
+ data-bind="click:addEmployeeTarget, visible:newTarget()">
|
diff --git a/application/views/pages/employeehoursreport_view.php b/application/views/pages/employeehoursreport_view.php
index e72b696..932b80b 100644
--- a/application/views/pages/employeehoursreport_view.php
+++ b/application/views/pages/employeehoursreport_view.php
@@ -5,10 +5,8 @@
@@ -24,7 +22,7 @@
- load->view('reports/employeehours/employeemonthhours_view'); ?>
+ load->view( 'reports/employeehours/employeemonthhours_view' ); ?>
diff --git a/application/views/pages/outgoinginvoices_view.php b/application/views/pages/outgoinginvoices_view.php
index 3ab0340..8527a94 100644
--- a/application/views/pages/outgoinginvoices_view.php
+++ b/application/views/pages/outgoinginvoices_view.php
@@ -1,15 +1,11 @@
-
+
-
diff --git a/application/views/pages/reservations_view.php b/application/views/pages/reservations_view.php
index 2e4cb83..fe59513 100644
--- a/application/views/pages/reservations_view.php
+++ b/application/views/pages/reservations_view.php
@@ -1,14 +1,18 @@
-
+
| |
project |
+ Budget derden |
+ gefactureerd |
gereserveerd |
betaald |
- saldo |
+ saldo te betalen |
+ saldo reservering |
+ saldo te factureren |
@@ -25,15 +29,27 @@
|
+
+
+ |
+
+
+ |
|
|
+
+
+ |
|
+
+
+ |
@@ -42,30 +58,50 @@
|
+   |
+
+
+ |
|
|
+
+
+ |
|
+ |
| Totaal |
+
+
+ |
+
+
+ |
|
|
+
+
+ |
|
+
+
+ |
@@ -73,9 +109,13 @@
| Grand totaal |
+ |
+ |
|
|
+ |
|
+ |
diff --git a/application/views/reports/employeehours/employeemonthhours_view.php b/application/views/reports/employeehours/employeemonthhours_view.php
index 027803c..1ab79dc 100644
--- a/application/views/reports/employeehours/employeemonthhours_view.php
+++ b/application/views/reports/employeehours/employeemonthhours_view.php
@@ -8,7 +8,7 @@
uren niet declarabel |
uren indirect |
totaal bestede uren |
-
uren target(1.600 jaar) |
+
uren jaartarget |
aandeel uren besteed tov target |
bezettingsgraad totaal aantal gewerkte uren |
bezettingsgraad t.o.v. target factureerbare uren |
diff --git a/public/js/lib/dataservices/employeeTargetDataService.js b/public/js/lib/dataservices/employeeTargetDataService.js
index 84284f1..ce8ac73 100644
--- a/public/js/lib/dataservices/employeeTargetDataService.js
+++ b/public/js/lib/dataservices/employeeTargetDataService.js
@@ -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 );
+ } );
}
diff --git a/public/js/lib/helpers.js b/public/js/lib/helpers.js
index 34f8d72..c9fb3a4 100644
--- a/public/js/lib/helpers.js
+++ b/public/js/lib/helpers.js
@@ -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 );
}
+
+
}
\ No newline at end of file
diff --git a/public/js/lib/modals/employeeTargetModal.js b/public/js/lib/modals/employeeTargetModal.js
index fc815ad..21f26c9 100644
--- a/public/js/lib/modals/employeeTargetModal.js
+++ b/public/js/lib/modals/employeeTargetModal.js
@@ -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,
- target : 0
+ 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 );
}
};
diff --git a/public/js/lib/modules/reports/employeeHours.js b/public/js/lib/modules/reports/employeeHours.js
index 82af749..029fe7f 100644
--- a/public/js/lib/modules/reports/employeeHours.js
+++ b/public/js/lib/modules/reports/employeeHours.js
@@ -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.selectedYear( (new Date()).getFullYear() );
+ vm.selectedMonthID( 0 );
+ vm.validYear( true );
- vm.initialize = false;
+ vm.initialize = false;
- vm.initModule();
- } );
+ 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 );
- 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.initModule();
- }, 700 );
+ 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();
},
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 );
}
diff --git a/public/js/lib/modules/reports/outgoingInvoices.js b/public/js/lib/modules/reports/outgoingInvoices.js
index be2adf8..ad841c9 100644
--- a/public/js/lib/modules/reports/outgoingInvoices.js
+++ b/public/js/lib/modules/reports/outgoingInvoices.js
@@ -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.validYear(true);
- vm.selectedYear( (new Date()).getFullYear() );
- vm.selectedMonthID( 0 );
-
- vm.initialize = false;
-
- vm.initModule();
- } );
+ 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;
diff --git a/public/js/lib/modules/reports/reservations.js b/public/js/lib/modules/reports/reservations.js
index 0ce35b0..db40550 100644
--- a/public/js/lib/modules/reports/reservations.js
+++ b/public/js/lib/modules/reports/reservations.js
@@ -12,10 +12,14 @@ dbo.reservationsInit = function () {
} else {
dbo.reservationsModel = {
- projects : ko.observableArray( [] ),
- reservation: ko.observable(),
- payed : ko.observable(),
- saldo : ko.observable(),
+ projects : ko.observableArray( [] ),
+ 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 );
}