diff --git a/application/controllers/beheer/UsersController.php b/application/controllers/beheer/UsersController.php
index 0b90fdc..b499a50 100644
--- a/application/controllers/beheer/UsersController.php
+++ b/application/controllers/beheer/UsersController.php
@@ -60,12 +60,19 @@ class usersController extends MY_Controller {
$this->json( $userActiveProjects );
}
- public function getUniqueprojectEmployees()
- {
- $projectEmployees = User::getUniqueProjectUsers();
+ public function getUniqueprojectEmployees()
+ {
+ $projectEmployees = User::getUniqueProjectUsers();
- $this->json( $projectEmployees );
- }
+ $this->json( $projectEmployees );
+ }
+
+ public function getUniqueEmployeesWithActivity($archive)
+ {
+ $projectEmployees = Projectemployee::getUniqueEmployeesWithActivity($archive);
+
+ $this->json( $projectEmployees );
+ }
public function saveUser()
{
diff --git a/application/controllers/reports/ReportsController.php b/application/controllers/reports/ReportsController.php
index 96f245f..1dd5c0d 100644
--- a/application/controllers/reports/ReportsController.php
+++ b/application/controllers/reports/ReportsController.php
@@ -29,7 +29,10 @@ class ReportsController extends MY_Controller {
public function recapProjects( $archive )
{
- $recapprojects = new Recapprojects( $archive );
+ $field = $this->input->post('field');
+ $direction = $this->input->post('direction');
+
+ $recapprojects = new Recapprojects( $archive, $field, $direction );
$projects = $recapprojects->getProjects();
@@ -84,4 +87,4 @@ class ReportsController extends MY_Controller {
Project::whereId( $projectID )->update( ['current_financial_year' => $amount] );
}
-}
\ No newline at end of file
+}
diff --git a/application/libraries/reports/Recapprojects.php b/application/libraries/reports/Recapprojects.php
index 92f6217..f74f7cd 100644
--- a/application/libraries/reports/Recapprojects.php
+++ b/application/libraries/reports/Recapprojects.php
@@ -10,9 +10,11 @@ class Recapprojects {
private $ci;
private $index;
+ private $field;
private $archive;
private $project;
private $projects;
+ private $direction;
private $employeeHours;
private $invoicedYears = [];
private $projectTotals;
@@ -23,11 +25,13 @@ class Recapprojects {
private $projectEmployeeDetail;
private $projectEmployeeDetails;
- public function __construct( $archive )
+ public function __construct( $archive, $field, $direction )
{
$this->ci =& get_instance();
$this->archive = $archive;
+ $this->field = $field;
+ $this->direction = $direction;
$this->ci->load->Model( 'projects/Invoices_model' );
@@ -54,12 +58,14 @@ class Recapprojects {
private function setProjects()
{
- $this->projects = Project::getActiveProjects( $this->archive )->toArray();
+ $this->projects = Project::getActiveProjects(
+ $this->archive, $this->field, $this->direction )->toArray();
}
private function setUniqueEmployees()
{
- $this->uniqueEmployees = Projectemployee::getUniqueProjectEmployees();
+ $this->uniqueEmployees =
+ Projectemployee::getUniqueEmployeesWithActivity();
}
private function loopProjects()
@@ -272,4 +278,4 @@ class Recapprojects {
$this->index ++;
}
}
-}
\ No newline at end of file
+}
diff --git a/application/libraries/reports/invoice/Invoices.php b/application/libraries/reports/invoice/Invoices.php
index c2884f1..c011455 100644
--- a/application/libraries/reports/invoice/Invoices.php
+++ b/application/libraries/reports/invoice/Invoices.php
@@ -8,104 +8,105 @@
class Invoices {
- private $year;
- private $project;
- private $projects;
- private $monthPayment;
- private $monthPayments;
- private $monthForecast;
- private $monthForecasts;
- private $invoiceOverview;
- private $invoiceForecast;
- private $invoiceForecasts;
- private $invoiceOverviews = [];
- private $invoiceReport = [];
- private $orderType;
- private $orderDirection;
- private $archive;
+ private $year;
+ private $project;
+ private $projects;
+ private $monthPayment;
+ private $monthPayments;
+ private $monthForecast;
+ private $monthForecasts;
+ private $invoiceOverview;
+ private $invoiceForecast;
+ private $invoiceForecasts;
+ private $invoiceOverviews = [];
+ private $invoiceReport = [];
+ private $orderType;
+ private $orderDirection;
+ private $archive;
- public function __construct( $year, $orderType, $orderDirection, $archive )
- {
- $this->year = $year;
- $this->orderType = $orderType;
- $this->orderDirection = $orderDirection;
- $this->archive = $archive;
+ public function __construct( $year, $orderType, $orderDirection, $archive )
+ {
+ $this->year = $year;
+ $this->orderType = $orderType;
+ $this->orderDirection = $orderDirection;
+ $this->archive = $archive;
- $this->handle();
- }
+ $this->handle();
+ }
- public function getInvoiceReport()
- {
- return $this->invoiceReport;
- }
+ public function getInvoiceReport()
+ {
+ return $this->invoiceReport;
+ }
- private function handle()
- {
- $this->setProjects();
+ private function handle()
+ {
+ $this->setProjects();
- $this->loopProjects();
+ $this->loopProjects();
- $this->setInvoiceReport();
- }
+ //only projects with payments also archived projects
+ $this->setMonthPayments();
- private function setProjects()
- {
- $this->projects =
- Project::getProjectsForReport( $this->orderType, $this->orderDirection, $this->archive );
- }
+ $this->setInvoiceReport();
+ }
- private function loopProjects()
- {
- foreach ( $this->projects as $this->project )
- {
- $this->setInvoiceOverview();
+ private function setProjects()
+ {
+ $this->projects =
+ Project::getProjectsForReport( $this->orderType, $this->orderDirection, $this->archive );
+ }
- $this->setInvoiceForecasts();
+ private function loopProjects()
+ {
+ foreach ( $this->projects as $this->project )
+ {
+ $this->setInvoiceOverview();
- $this->setMonthForecasts();
+ $this->setInvoiceForecasts();
- $this->setMonthPayments();
- }
- }
+ $this->setMonthForecasts();
+ }
+ }
- private function setInvoiceOverview()
- {
- $this->invoiceOverview = new InvoiceOverview( $this->project, $this->year );
+ private function setInvoiceOverview()
+ {
+ $this->invoiceOverview = new InvoiceOverview( $this->project, $this->year );
- $this->invoiceOverviews[] = $this->invoiceOverview->getProjectDetails();
- }
+ $this->invoiceOverviews[] = $this->invoiceOverview->getProjectDetails();
+ }
- private function setInvoiceForecasts()
- {
- $this->invoiceForecast =
- new InvoiceForecast( $this->project, $this->invoiceOverview->getNeedinvoice(), $this->year );
+ private function setInvoiceForecasts()
+ {
+ $this->invoiceForecast =
+ new InvoiceForecast( $this->project, $this->invoiceOverview->getNeedinvoice(), $this->year );
- $this->invoiceForecasts[] = $this->invoiceForecast->getProjectDetails();
- }
+ $this->invoiceForecasts[] = $this->invoiceForecast->getProjectDetails();
+ }
- public function setMonthForecasts()
- {
- $this->monthForecast =
- new MonthForecast( $this->invoiceForecast, $this->project, $this->year );
+ public function setMonthForecasts()
+ {
+ $this->monthForecast =
+ new MonthForecast( $this->invoiceForecast, $this->project, $this->year );
- $this->monthForecasts[] = $this->monthForecast->getProjectDetails();
- }
+ $this->monthForecasts[] = $this->monthForecast->getProjectDetails();
+ }
- public function setMonthPayments()
- {
- $this->monthPayment =
- new MonthPayments( $this->project, $this->year );
+ public function setMonthPayments()
+ {
+ $monthPayment = new MonthPayments(
+ $this->year, $this->orderType, $this->orderDirection );
- $this->monthPayments[] = $this->monthPayment->getProjectDetails();
- }
+ $this->monthPayments = $monthPayment->getProjectDetails();
+ }
- private function setInvoiceReport()
- {
- $this->invoiceReport = [
- 'invoiceOverview' => $this->invoiceOverviews,
- 'forecasts' => $this->invoiceForecasts,
- 'monthForecasts' => $this->monthForecasts,
- 'monthPayments' => $this->monthPayments
- ];
- }
-}
\ No newline at end of file
+ private function setInvoiceReport()
+ {
+ $this->invoiceReport = [
+ 'invoiceOverview' => $this->invoiceOverviews,
+ 'forecasts' => $this->invoiceForecasts,
+ 'monthForecasts' => $this->monthForecasts,
+ 'monthPayments' => $this->monthPayments
+ ];
+ }
+}
diff --git a/application/libraries/reports/invoice/MonthPayments.php b/application/libraries/reports/invoice/MonthPayments.php
index 12eed37..cf301ee 100644
--- a/application/libraries/reports/invoice/MonthPayments.php
+++ b/application/libraries/reports/invoice/MonthPayments.php
@@ -8,96 +8,119 @@
class MonthPayments {
- private $year;
- private $project;
- private $payment;
- private $customer;
- private $projectname;
- private $monthPayments;
- private $projectDetails;
- private $totalProjectPayments;
+ private $year;
+ private $project;
+ private $payment;
+ private $customer;
+ private $projectname;
+ private $monthPayments;
+ private $projectDetails;
+ private $projectsWithPayments;
+ private $totalProjectPayments;
+ private $orderType;
+ private $orderDirection;
- public function __construct( $project, $year )
- {
- $this->project = $project;
- $this->year = $year;
+ public function __construct( $year, $orderType, $orderDirection )
+ {
+ $this->year = $year;
+ $this->orderType = $orderType;
+ $this->orderDirection = $orderDirection;
- $this->handle();
- }
+ $this->handle();
+ }
- public function getProjectDetails()
- {
- return $this->projectDetails;
- }
+ public function getProjectDetails()
+ {
+ return $this->projectDetails;
+ }
- private function handle()
- {
- $this->setProjectname();
+ private function handle()
+ {
+ $this->setProjectsWithPayments();
- $this->setCustomer();
+ $this->loopProjectsWithPayments();
+ }
- $this->setInitialsMonthPayments();
+ private function setProjectsWithPayments()
+ {
+ $projectsArray = Payment::getProjectsWithPayments( $this->year );
- $this->loopPayments();
+ $this->projectsWithPayments =
+ Project::getProjectsForReport(
+ $this->orderType, $this->orderDirection, FALSE, $projectsArray );
+ }
- $this->setProjectDetails();
- }
+ private function loopProjectsWithPayments()
+ {
+ foreach ( $this->projectsWithPayments as $this->project )
+ {
+ $this->setProjectname();
- private function setProjectname()
- {
- $this->projectname = $this->project->projectname . '(' . $this->project->projectnumber . ')';
- }
+ $this->setCustomer();
- private function setCustomer()
- {
- $this->customer = $this->project->customer->name;
- }
+ $this->setInitialsMonthPayments();
- private function setInitialsMonthPayments()
- {
- for ( $i = 1; $i <= 12; $i ++ )
- {
- $this->monthPayments[ $i ] = ['paymentamount' => 0];
- }
- }
+ $this->loopPayments();
- private function loopPayments()
- {
- foreach ( $this->project->invoices as $invoice )
- {
- foreach($invoice->payments as $this->payment)
- {
- $this->setMonthPayments();
+ $this->setProjectDetails();
+ }
+ }
- $this->setTotalProjectPayments();
- }
- }
- }
+ private function setProjectname()
+ {
+ $this->projectname = $this->project->projectname . '(' . $this->project->projectnumber . ')';
+ }
- private function setMonthPayments()
- {
- $paymentYear = date( 'Y', strtotime( $this->payment->paymentdate ) );
- $paymentMonth = date( 'n', strtotime( $this->payment->paymentdate ) );
+ private function setCustomer()
+ {
+ $this->customer = $this->project->customer->name;
+ }
- if ( $paymentYear == $this->year )
- $this->monthPayments[ $paymentMonth ]['paymentamount'] += $this->payment->paymentamount;
- }
+ private function setInitialsMonthPayments()
+ {
+ for ( $i = 1; $i <= 12; $i ++ )
+ {
+ $this->monthPayments[ $i ] = ['paymentamount' => 0];
+ }
+ }
- private function setTotalProjectPayments()
- {
- $paymentYear = date( 'Y', strtotime( $this->payment->paymentdate ) );
+ private function loopPayments()
+ {
+ foreach ( $this->project->invoices as $invoice )
+ {
+ foreach ( $invoice->payments as $this->payment )
+ {
+ $this->setMonthPayments();
- if ( $paymentYear == $this->year )
- $this->totalProjectPayments += $this->payment->paymentamount;
- }
+ $this->setTotalProjectPayments();
+ }
+ }
+ }
- private function setProjectDetails()
- {
- $this->projectDetails = [
- 'projectname' => $this->projectname,
- 'customer' => $this->customer,
- 'monthPayments' => $this->monthPayments,
- 'totalProjectPayments' => number_format( $this->totalProjectPayments, 0, ',', '.' )
- ];
- }
-}
\ No newline at end of file
+ private function setMonthPayments()
+ {
+ $paymentYear = date( 'Y', strtotime( $this->payment->paymentdate ) );
+ $paymentMonth = date( 'n', strtotime( $this->payment->paymentdate ) );
+
+ if ( $paymentYear == $this->year )
+ $this->monthPayments[ $paymentMonth ]['paymentamount'] += $this->payment->paymentamount;
+ }
+
+ private function setTotalProjectPayments()
+ {
+ $paymentYear = date( 'Y', strtotime( $this->payment->paymentdate ) );
+
+ if ( $paymentYear == $this->year )
+ $this->totalProjectPayments += $this->payment->paymentamount;
+ }
+
+ private function setProjectDetails()
+ {
+ $this->projectDetails[] = [
+ 'projectname' => $this->projectname,
+ 'customer' => $this->customer,
+ 'monthPayments' => $this->monthPayments,
+ 'totalProjectPayments' => number_format( $this->totalProjectPayments, 0, ',', '.' )
+ ];
+ }
+}
diff --git a/application/models/eloquent/Payment.php b/application/models/eloquent/Payment.php
index d3ff460..fa6ac0b 100644
--- a/application/models/eloquent/Payment.php
+++ b/application/models/eloquent/Payment.php
@@ -28,6 +28,17 @@ class Payment extends BaseModel {
return $projectPayment->payment;
}
+ public static function getProjectsWithPayments($year)
+ {
+ $projects = self::selectRaw('INV.project_id')
+ ->distinct()
+ ->join('invoices AS INV', 'INV.id', '=', 'payments.invoice_id')
+ ->whereRaw('DATE_FORMAT(INV.invoicedate, "%Y") = "'. $year.'"')
+ ->lists('project_id');
+
+ return $projects->toArray();
+ }
+
public static function savePayment( $paymentID, $payment )
{
$payment = (array) $payment;
@@ -50,4 +61,4 @@ class Payment extends BaseModel {
Payment::whereId( $paymentID )->delete();
}
-}
\ No newline at end of file
+}
diff --git a/application/models/eloquent/Project.php b/application/models/eloquent/Project.php
index 7736d28..54422af 100644
--- a/application/models/eloquent/Project.php
+++ b/application/models/eloquent/Project.php
@@ -96,7 +96,7 @@ class Project extends BaseModel {
Project::whereId( $projectID )->delete();
}
- public static function getActiveProjects( $archive = 'T' )
+ public static function getActiveProjects( $archive = 'T', $sortField = FALSE, $direction = FALSE )
{
$projects = Project::selectRaw( "projects.id, YEAR(projects.startdate) AS instroom, YEAR(projects.enddate) AS uitstroom, projectnumber, current_financial_year,
projectname, CUS.name, OFF.own_revenue, OFF.other_revenue" )
@@ -106,6 +106,8 @@ class Project extends BaseModel {
->groupBy( 'OFF.own_revenue' )
->groupBy( 'OFF.other_revenue' );
+ if ( $sortField ) $projects = $projects->orderBy( $sortField, $direction );
+
if ( $archive == 'F' ) $projects = $projects->where( 'projects.archive', '=', 'F' );
$projects = $projects->get();
@@ -113,12 +115,14 @@ class Project extends BaseModel {
return $projects;
}
- public static function getProjectsForReport( $orderType, $orderDirection, $archive = 'F' )
+ public static function getProjectsForReport( $orderType, $orderDirection, $archive = 'F', $projectsArray = FALSE )
{
$projects = self::getBaseProject();
if ( $archive == 'F' ) $projects = $projects->whereArchive( 'F' );
+ if ( is_array( $projectsArray ) ) $projects = $projects->whereIn( 'id', $projectsArray );
+
$projects = $projects->orderBy( $orderType, $orderDirection )->get();
return $projects;
diff --git a/application/models/eloquent/Projectemployee.php b/application/models/eloquent/Projectemployee.php
index d2d1579..4053cfc 100644
--- a/application/models/eloquent/Projectemployee.php
+++ b/application/models/eloquent/Projectemployee.php
@@ -8,94 +8,111 @@
class Projectemployee extends BaseModel {
- public function project()
- {
- return $this->belongsTo( 'Project' );
+ public function project()
+ {
+ return $this->belongsTo( 'Project' );
+ }
+
+ public function user()
+ {
+ return $this->belongsTo( 'User' );
+ }
+
+ public function projecthours()
+ {
+ return $this->hasMany( 'Projecthour' );
+ }
+
+ public static function getAvailableEmployees( $projectID )
+ {
+ $currentEmployees = Self::whereProjectId( $projectID )
+ ->lists( 'user_id' );
+
+ $availableEmployees = User::selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" )
+ ->whereNotIn( 'id', $currentEmployees )
+ ->whereArchive( 'F' )
+ ->get();
+
+ return $availableEmployees;
+ }
+
+ public static function getUniqueProjectEmployees()
+ {
+ $projectemployees = Projectemployee::selectRaw( "USR.id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" )
+ ->distinct()
+ ->join( 'users AS USR', 'USR.id', '=', 'projectemployees.user_id' )
+ ->get();
+
+ return $projectemployees;
+ }
+
+ public static function getUniqueEmployeesWithActivity( $archive = 'F' )
+ {
+ $projectemployees = Projectemployee::selectRaw( "USR.id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" )
+ ->distinct()
+ ->join( 'users AS USR', 'USR.id', '=', 'projectemployees.user_id' )
+ ->join( 'projectemployees AS PRE', 'PRE.user_id', '=', 'USR.id' )
+ ->join( 'projects AS PRJ', 'PRJ.id', '=', 'PRE.project_id' );
+
+ if ( $archive == 'F' ) $projectemployees = $projectemployees->where( 'PRJ.archive', '=', 'F' );
+
+ $projectemployees = $projectemployees->get();
+
+ return $projectemployees;
}
- public function user()
- {
- return $this->belongsTo( 'User' );
- }
+ public static function getProjectemployeeDetailsPerProject( $projectID )
+ {
+ $details = Projectemployee::selectRaw( 'USR.id, budget, project_id, ROUND(SUM(hours), 0) AS hours, ROUND(SUM(hours * tarif), 0) AS revenues, projectemployees.id AS projectemployeeID' )
+ ->join( 'users AS USR', 'USR.id', '=', 'projectemployees.user_id' )
+ ->join( 'projecthours AS PRH', 'PRH.projectemployee_id', '=', 'projectemployees.id' )
+ ->where( 'projectemployees.project_id', '=', $projectID )
+ ->where( 'PRH.hourtype_id', '=', 1 )
+ ->where( 'budget', '!=', 0 )
+ ->groupBy( 'projectemployees.id' )
+ ->havingRaw( 'ROUND(SUM(hours), 0) > 0' )
+ ->get();
- public function projecthours()
- {
- return $this->hasMany( 'Projecthour' );
- }
+ return $details;
+ }
- public static function getAvailableEmployees( $projectID )
- {
- $currentEmployees = Self::whereProjectId( $projectID )
- ->lists( 'user_id' );
+ public static function firstOrCreateProjectemployee( $userID, $projectID )
+ {
+ $projectemployee = self::whereUserId( $userID )->whereProjectId( $projectID );
- $availableEmployees = User::selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" )
- ->whereNotIn( 'id', $currentEmployees )
- ->whereArchive( 'F' )
- ->get();
+ if ( $projectemployee->count() > 0 ) return $projectemployee->first();
- return $availableEmployees;
- }
+ $user = User::find( $userID );
- public static function getUniqueProjectEmployees()
- {
- $projectemployees = Projectemployee::selectRaw( "USR.id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" )
- ->distinct()
- ->join( 'users AS USR', 'USR.id', '=', 'projectemployees.user_id' )
- ->get();
+ $tarif = $user ? $user->hourlyrate : 0;
- return $projectemployees;
- }
+ $projectemployee = Projectemployee::create( [
+ 'project_id' => $projectID,
+ 'user_id' => $userID,
+ 'tarif' => $tarif
+ ] );
- public static function getProjectemployeeDetailsPerProject( $projectID )
- {
- $details = Projectemployee::selectRaw( 'USR.id, budget, project_id, ROUND(SUM(hours), 0) AS hours, ROUND(SUM(hours * tarif), 0) AS revenues, projectemployees.id AS projectemployeeID' )
- ->join( 'users AS USR', 'USR.id', '=', 'projectemployees.user_id' )
- ->join( 'projecthours AS PRH', 'PRH.projectemployee_id', '=', 'projectemployees.id' )
- ->where( 'projectemployees.project_id', '=', $projectID )
- ->where( 'PRH.hourtype_id', '=', 1 )
- ->groupBy( 'projectemployees.id' )
- ->get();
+ return $projectemployee;
+ }
- return $details;
- }
+ public static function createProjectEmployee( $projectID )
+ {
+ $projectemployee = Projectemployee::create( [
+ 'project_id' => $projectID
+ ] );
- public static function firstOrCreateProjectemployee( $userID, $projectID )
- {
- $projectemployee = self::whereUserId($userID)->whereProjectId($projectID);
+ return $projectemployee->id;
+ }
- if( $projectemployee->count() > 0 ) return $projectemployee->first();
+ public static function saveProjectemployee( $projectemployeeID, $projectemployee )
+ {
+ Projectemployee::whereId( $projectemployeeID )
+ ->update( $projectemployee );
+ }
- $user = User::find( $userID );
+ public static function removeProjectemployee( $projectemployeeID )
+ {
+ Projectemployee::whereId( $projectemployeeID )->delete();
+ }
- $tarif = $user ? $user->hourlyrate : 0;
-
- $projectemployee = Projectemployee::create( [
- 'project_id' => $projectID,
- 'user_id' => $userID,
- 'tarif' => $tarif
- ] );
-
- return $projectemployee;
- }
-
- public static function createProjectEmployee( $projectID )
- {
- $projectemployee = Projectemployee::create( [
- 'project_id' => $projectID
- ] );
-
- return $projectemployee->id;
- }
-
- public static function saveProjectemployee( $projectemployeeID, $projectemployee )
- {
- Projectemployee::whereId( $projectemployeeID )
- ->update( $projectemployee );
- }
-
- public static function removeProjectemployee( $projectemployeeID )
- {
- Projectemployee::whereId( $projectemployeeID )->delete();
- }
-
-}
\ No newline at end of file
+}
diff --git a/application/views/emails/requestpassword_email.php b/application/views/emails/requestpassword_email.php
index f1d9ddb..a141a26 100644
--- a/application/views/emails/requestpassword_email.php
+++ b/application/views/emails/requestpassword_email.php
@@ -311,7 +311,7 @@
- Nieuw wachtwoord DBOIS De Beleidsonderzoeker
+ Nieuw wachtwoord DBOIS De Beleidsonderzoekers
diff --git a/application/views/emails/welcome_email.php b/application/views/emails/welcome_email.php
index 06471aa..4dd69e4 100644
--- a/application/views/emails/welcome_email.php
+++ b/application/views/emails/welcome_email.php
@@ -311,7 +311,7 @@
- Wachtwoord De Beleidsonderzoeker
+ Wachtwoord De Beleidsonderzoekers
diff --git a/application/views/main_view.php b/application/views/main_view.php
index 7effca0..ae9d928 100644
--- a/application/views/main_view.php
+++ b/application/views/main_view.php
@@ -7,7 +7,7 @@
- ** De Beleidsonderzoeker **
+ ** De Beleidsonderzoekers **
load->view( 'partials/_css' ); ?>
diff --git a/application/views/modals/partials/_invoices.php b/application/views/modals/partials/_invoices.php
index 5ca8891..54b4516 100644
--- a/application/views/modals/partials/_invoices.php
+++ b/application/views/modals/partials/_invoices.php
@@ -169,11 +169,21 @@
-
-
-
+
+
+
+
+
+
+
@@ -184,4 +194,4 @@
-
\ No newline at end of file
+
diff --git a/application/views/modals/partials/_projectcosts.php b/application/views/modals/partials/_projectcosts.php
index 0a1d63a..7473af1 100644
--- a/application/views/modals/partials/_projectcosts.php
+++ b/application/views/modals/partials/_projectcosts.php
@@ -110,6 +110,20 @@
+
+
+
+
+
+
+
+
@@ -120,4 +134,4 @@
-
\ No newline at end of file
+
diff --git a/application/views/modals/partials/_reservations.php b/application/views/modals/partials/_reservations.php
index a1a923c..502dbfa 100644
--- a/application/views/modals/partials/_reservations.php
+++ b/application/views/modals/partials/_reservations.php
@@ -1,7 +1,7 @@
- budget onderaannemers (incl. btw)
+ gereserveerd op spaarrekening (incl. btw)
@@ -49,6 +49,12 @@
+
+
+
+
diff --git a/application/views/pages/login/login_view.php b/application/views/pages/login/login_view.php
index c1032ca..918b6d1 100644
--- a/application/views/pages/login/login_view.php
+++ b/application/views/pages/login/login_view.php
@@ -93,7 +93,7 @@
- © 2018. De Beleidsonderzoeker.
+ © 2018. De Beleidsonderzoekers
diff --git a/application/views/pages/reservations_view.php b/application/views/pages/reservations_view.php
index 17dcac5..4ff4e39 100644
--- a/application/views/pages/reservations_view.php
+++ b/application/views/pages/reservations_view.php
@@ -11,7 +11,7 @@
project
Kosten derden
factuur INK
- budget onderaannemers
+ gereserveerd op spaarrekening
betaald
saldo te betalen
betaald via reserveringen
diff --git a/application/views/reports/monthlyemployeehours/euro_view.php b/application/views/reports/monthlyemployeehours/euro_view.php
index 5e4663d..edf2c64 100644
--- a/application/views/reports/monthlyemployeehours/euro_view.php
+++ b/application/views/reports/monthlyemployeehours/euro_view.php
@@ -1,17 +1,23 @@
-
- projectnummer
+
+
+ projectnummer
+
instroom
-
- naam
+
+
+ naam
+
-
- opdrachtgever
+
+
+ opdrachtgever
+
@@ -43,6 +49,32 @@
Volgende boekjaren
+
+ totaal
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -79,32 +111,6 @@
-
- totaal
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/application/views/reports/monthlyemployeehours/hours_view.php b/application/views/reports/monthlyemployeehours/hours_view.php
index cf1d7ce..f889572 100644
--- a/application/views/reports/monthlyemployeehours/hours_view.php
+++ b/application/views/reports/monthlyemployeehours/hours_view.php
@@ -2,7 +2,9 @@
- projectnummer
+
+ projectnummer
+
instroom
@@ -11,10 +13,14 @@
uitstroom
- naam
+
+ naam
+
- opdrachtgever
+
+ opdrachtgever
+
@@ -33,6 +39,25 @@
totaal beschikbare uren
+
+ totaal
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -60,24 +85,5 @@
-
- totaal
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+
diff --git a/public/css/main.css b/public/css/main.css
index 7a07770..c080794 100644
--- a/public/css/main.css
+++ b/public/css/main.css
@@ -103,6 +103,10 @@ th.rotate > div > span {
border-right: 1px solid #ccc;
border-bottom: 1px solid #ccc;
}
+th.sorting-field:hover{
+ cursor: pointer;
+ color:#222;
+}
.pie-test{
width:20px;
height:20px;
diff --git a/public/js/lib/dataservices/reportsDataService.js b/public/js/lib/dataservices/reportsDataService.js
index 54db274..60b01ee 100644
--- a/public/js/lib/dataservices/reportsDataService.js
+++ b/public/js/lib/dataservices/reportsDataService.js
@@ -8,32 +8,36 @@
dbo.reportsDataService = {
- getUsedYears: function ( callback ) {
- $.getJSON( 'index.php/reports/reportsdefaultController/getUsedYears' )
- .done( function ( data ) {
- callback( data );
- } );
- },
+ getUsedYears: function ( callback ) {
+ $.getJSON( 'index.php/reports/reportsdefaultController/getUsedYears' )
+ .done( function ( data ) {
+ callback( data );
+ } );
+ },
- getRecapProjects: function(archive, callback){
- $.getJSON( 'index.php/reports/reportsController/recapProjects/' + archive )
- .done( function ( data ) {
- callback( data );
- } );
- },
+ getRecapProjects: function ( field, direction, archive, callback ) {
+ var submitDATA = {
+ field : field,
+ direction: direction
+ };
+ $.post( 'index.php/reports/reportsController/recapProjects/' + archive, submitDATA )
+ .done( function ( data ) {
+ callback( data );
+ }, 'JSON' );
+ },
- getEmployeeHours: function ( employeeID, year, callback ) {
- $.getJSON( 'index.php/reports/reportsController/getMonthlyEmployeeHoursPerProject/' + employeeID + '/' + year )
- .done( function ( data ) {
- callback( data );
- } );
- },
+ getEmployeeHours: function ( employeeID, year, callback ) {
+ $.getJSON( 'index.php/reports/reportsController/getMonthlyEmployeeHoursPerProject/' + employeeID + '/' + year )
+ .done( function ( data ) {
+ callback( data );
+ } );
+ },
- saveCurrentFinnacialYear: function(projectID, amount, callback){
- $.post( 'index.php/reports/reportsController/saveCurrentFinnacialYear/' + projectID, {amount:amount} )
- .done( function ( data ) {
- callback( data );
- }, 'json' );
- }
+ saveCurrentFinnacialYear: function ( projectID, amount, callback ) {
+ $.post( 'index.php/reports/reportsController/saveCurrentFinnacialYear/' + projectID, {amount: amount} )
+ .done( function ( data ) {
+ callback( data );
+ }, 'json' );
+ }
-}
\ No newline at end of file
+}
diff --git a/public/js/lib/dataservices/userDataservice.js b/public/js/lib/dataservices/userDataservice.js
index e30be5c..9978990 100644
--- a/public/js/lib/dataservices/userDataservice.js
+++ b/public/js/lib/dataservices/userDataservice.js
@@ -42,12 +42,19 @@ dbo.userDataService = {
} );
},
- getUniqueProjectEmployees: function ( callback ) {
- $.post( 'index.php/beheer/usersController/getUniqueprojectEmployees', 'json' )
- .done( function ( data ) {
- callback( data );
- } );
- },
+ getUniqueProjectEmployees: function ( callback ) {
+ $.post( 'index.php/beheer/usersController/getUniqueprojectEmployees', 'json' )
+ .done( function ( data ) {
+ callback( data );
+ } );
+ },
+
+ getUniqueEmployeesWithActivity: function ( archive, callback ) {
+ $.post( 'index.php/beheer/usersController/getUniqueEmployeesWithActivity/' + archive, 'json' )
+ .done( function ( data ) {
+ callback( data );
+ } );
+ },
checkUsername: function ( username, callback ) {
$.post( 'index.php/beheer/userController/checkUsername', 'json' )
diff --git a/public/js/lib/modals/projectModal.js b/public/js/lib/modals/projectModal.js
index a1525d0..4851160 100644
--- a/public/js/lib/modals/projectModal.js
+++ b/public/js/lib/modals/projectModal.js
@@ -6,1142 +6,1171 @@
*/
$( function () {
- var timeout;
- dbo.editProjectModal = {
-
- offers : ko.observableArray( [] ),
- projectEmployees : ko.observableArray( [] ),
- customers : ko.observableArray( [] ),
- users : ko.observableArray( [] ),
- invoices : ko.observableArray( [] ),
- projecthours : ko.observableArray( [] ),
- offerFiles : ko.observableArray( [] ),
- offerComments : ko.observableArray( [] ),
- projectFiles : ko.observableArray( [] ),
- projectComments : ko.observableArray( [] ),
- externals : ko.observableArray( [] ),
- projectcosts : ko.observableArray( [] ),
- vats : ko.observableArray( [] ),
- availableEmployees : ko.observableArray( [] ),
- forecasts : ko.observableArray( [] ),
- reservations : ko.observableArray( [] ),
- showProject : ko.observable( false ),
- projectID : null,
- callback : null,
- customerID : ko.observable( null ),
- projectnumber : ko.observable(),
- projectleaderID : ko.observable(),
- archive : ko.observable( false ),
- startdate : ko.observable( null ),
- enddate : ko.observable( null ),
- vat_id : ko.observable(),
- projectname : ko.observable(),
- busy : false,
- ownRevenue : ko.observable(),
- otherRevenue : ko.observable(),
- costs : ko.observable(),
- projectname : ko.observable(),
- years : ko.observableArray( dbo.years ),
- months : ko.observableArray( dbo.monthArray ),
- outstanding : ko.observable(),
- documents : ko.observableArray( [] ),
- comments : ko.observableArray( [] ),
- activeTab : ko.observable(),
- totalRevenues : ko.observable(),
- totalInvoiced : ko.observable(),
- totalRevenuesIncl : ko.observable(),
- outstanding : ko.observable(),
- outstandingInvoices: ko.observable(),
- payed : ko.observable(),
- totalForecast : ko.observable(),
- toForecast : ko.observable(),
- toInvoice : 0,
- hourTotals : ko.observableArray( [] ),
- totalNonDeclarable : ko.observable( 0 ),
- totalDeclarable : ko.observable( 0 ),
- totalRevenueHours : ko.observable( 0 ),
-
- init: function () {
- var vm = dbo.editProjectModal;
-
- vm.busy = true;
-
- $( "#project-scroller" ).height( $( window ).height() - 100 );
-
- dbo.customerDataService.getAllCustomers( 'F', function ( data ) {
- vm.customers( data );
- dbo.userDataService.getAllUsers( 'F', function ( data ) {
- vm.users( data );
- dbo.externalDataService.getAllExternals( 'F', function ( data ) {
- vm.externals( data );
- dbo.vatDataService.getVats( 'F', function ( data ) {
- vm.vats( data );
-
- vm.refreshAvailableEmployees( function () {
- vm.refreshProject();
-
- vm.activeTab( 'DASHBOARD' );
-
- vm.busy = false;
- } );
- } );
- } );
- } );
- } );
- },
-
- setActiveTab: function ( tab ) {
- var vm = dbo.editProjectModal;
-
- vm.activeTab( tab );
- },
-
- togglePayments: function () {
- this.showPayments( !this.showPayments() );
-
- var showPayments = sessionStorage.showPayments || [];
-
- if ( this.showPayments() ) {
- showPayments.push( this.id );
- } else {
- var index = showPayments.indexOf( this.id );
- showPayments.splice( index, 1 );
- }
-
- sessionStorage.setItem( "showPayment", showPayments );
- },
-
- toggleFromReservation: function () {
- var vm = dbo.editProjectModal;
- var self = this;
-
- self.fromReservation( !self.fromReservation() );
-
- vm.saveProjectCost( self );
- },
-
- editProjectemployee: function () {
- var self = this;
- var vm = dbo.editProjectModal;
- $.each( vm.projectEmployees(), function ( i, p ) {
- if ( p.id == self.id ) {
- p.inEdit( !p.inEdit() );
- } else {
- p.inEdit( false );
- }
- } );
- },
-
- editInvoice: function () {
- var self = this;
- var vm = dbo.editProjectModal;
- $.each( vm.invoices(), function ( i, p ) {
- if ( p.id == self.id ) {
- p.inEdit( !p.inEdit() );
- } else {
- p.inEdit( false );
- }
- } );
- },
-
- editPayment: function ( parent ) {
- var self = this;
- $.each( parent.payments(), function ( i, p ) {
- console.log( p.invoice_id(), ' ', parent.id );
- if ( p.id == self.id ) {
- p.inEdit( !p.inEdit() );
- } else {
- p.inEdit( false );
- }
- } );
- },
-
- setHourtype: function ( status ) {
- if ( !this.inEdit() ) return;
-
- var vm = dbo.editProjectModal;
- this.hourtype_id( status );
-
- vm.saveProjecthour( this );
- },
-
- setPayment: function ( status ) {
- var vm = dbo.editProjectModal;
-
- this.payed( status );
-
- vm.saveReservation( this );
- },
-
- editProjecthour: function () {
- var self = this;
- var vm = dbo.editProjectModal;
- $.each( vm.projecthours(), function ( i, p ) {
- if ( p.id == self.id ) {
- p.inEdit( !p.inEdit() );
- } else {
- p.inEdit( false );
- }
- } );
- },
-
- editProjectcosts: function () {
- var self = this;
- var vm = dbo.editProjectModal;
- $.each( vm.projectcosts(), function ( i, p ) {
- if ( p.id == self.id ) {
- p.inEdit( !p.inEdit() );
- } else {
- p.inEdit( false );
- }
- } );
- },
-
- editForecast: function () {
- var self = this;
- var vm = dbo.editProjectModal;
- $.each( vm.forecasts(), function ( i, p ) {
- if ( p.id == self.id ) {
- p.inEdit( !p.inEdit() );
- } else {
- p.inEdit( false );
- }
- } );
- vm.toForecasting();
- },
-
- editReservation: function () {
- var self = this;
- var vm = dbo.editProjectModal;
- $.each( vm.reservations(), function ( i, p ) {
- if ( p.id == self.id ) {
- p.inEdit( !p.inEdit() );
- } else {
- p.inEdit( false );
- }
- } );
- },
-
- newOffer: function () {
- var vm = dbo.editProjectModal;
- var service = dbo.offersService;
- service.vm = dbo.editProjectModal;
-
- service.newOffer( vm.projectID, vm.customerID() );
- },
-
- newInvoice: function () {
- var vm = dbo.editProjectModal;
-
- var invoice = {
- id : 0,
- project_id : vm.projectID,
- invoicenumber : '',
- invoicedate : null,
- invoiceamount : 0,
- forecastamount: 0,
- forecastdate : null,
- inEdit : true,
- showPayments : false,
- payments : []
- }
-
- vm.invoices.push( new vm.Invoice( invoice ) );
- },
-
- newPayment: function () {
- var vm = dbo.editProjectModal;
- var self = this;
- console.log( self );
- var payment = {
- id : 0,
- invoice_id : self.id,
- paymentdate : null,
- paymentamount: 0,
- inEdit : true
- };
-
- self.payments.push( new vm.Payment( payment ) );
- },
-
- newProjecthour: function () {
- var vm = dbo.editProjectModal;
-
- var projecthour = {
- id : 0,
- projectemployee_id: null,
- hourdate : null,
- hours : 0,
- hourtype_id : 1,
- inEdit : true
- };
-
- vm.projecthours.push( new vm.Projecthour( projecthour ) );
- },
-
- newProjectcost: function () {
- var vm = dbo.editProjectModal;
-
- var projectcost = {
- id : 0,
- external_id: null,
- description: '',
- date : null,
- costs : 0,
- payed : 0,
- inEdit : true
- };
-
- vm.projectcosts.push( new vm.Projectcost( projectcost ) );
- },
-
- editOffer: function () {
- var service = dbo.offersService;
- service.vm = dbo.editProjectModal;
-
- service.editOffer( this, false, false, true );
- },
-
- addProject: function ( callback ) {
- var vm = dbo.editProjectModal;
-
- vm.callback = callback;
-
- dbo.projectDataService.addProject( function ( data ) {
- console.log( data );
- vm.projectID = data;
-
- vm.showProject( true );
-
- vm.init();
- } );
- },
-
- addProjectemployee: function () {
- var vm = dbo.editProjectModal;
- dbo.projectDataService.addProjectemployee( vm.projectID, function () {
- vm.refreshProject();
- } );
- },
-
- addForecast: function () {
- var vm = dbo.editProjectModal;
-
- var forecast = {
- id : 0,
- project_id : vm.projectID,
- year : dbo.currentYear,
- month_id : dbo.currentMonth,
- forecastamount: 0,
- inEdit : true
- };
-
- vm.forecasts.push( new vm.Forecast( forecast ) );
- },
-
- addReservation: function () {
- var vm = dbo.editProjectModal;
-
- var reservation = {
- id : 0,
- project_id : vm.projectID,
- reservationamount : 0,
- external_id : null,
- inEdit : true,
- invalidReservation: true
- };
-
- vm.reservations.push( new vm.Reservation( reservation ) );
- },
-
- editProject: function ( projectID, callback ) {
- var vm = dbo.editProjectModal;
-
- vm.callback = callback;
- vm.projectID = projectID;
-
- vm.showProject( true );
-
- vm.init();
- },
-
- saveProjectname: function () {
- var vm = dbo.editProjectModal;
- if ( timeout ) {
- clearTimeout( timeout );
- timeout = null;
- }
- timeout = setTimeout( function () {
- vm.saveProject();
- }, 700 );
- },
-
- saveProject: function () {
- var vm = dbo.editProjectModal;
-
- if ( vm.busy ) return;
-
- var submitDATA = {
- id : vm.projectID,
- customer_id : vm.customerID(),
- projectleader_id: vm.projectleaderID(),
- projectname : vm.projectname(),
- startdate : vm.startdate(),
- enddate : vm.enddate(),
- vat_id : vm.vat_id()
- }
-
- dbo.projectDataService.saveProject( vm.projectID, submitDATA, function ( data ) {
- vm.refreshProject();
+ var timeout;
+ dbo.editProjectModal = {
+
+ offers : ko.observableArray( [] ),
+ projectEmployees : ko.observableArray( [] ),
+ customers : ko.observableArray( [] ),
+ users : ko.observableArray( [] ),
+ invoices : ko.observableArray( [] ),
+ projecthours : ko.observableArray( [] ),
+ offerFiles : ko.observableArray( [] ),
+ offerComments : ko.observableArray( [] ),
+ projectFiles : ko.observableArray( [] ),
+ projectComments : ko.observableArray( [] ),
+ externals : ko.observableArray( [] ),
+ projectcosts : ko.observableArray( [] ),
+ vats : ko.observableArray( [] ),
+ availableEmployees : ko.observableArray( [] ),
+ forecasts : ko.observableArray( [] ),
+ reservations : ko.observableArray( [] ),
+ showProject : ko.observable( false ),
+ projectID : null,
+ callback : null,
+ customerID : ko.observable( null ),
+ projectnumber : ko.observable(),
+ projectleaderID : ko.observable(),
+ archive : ko.observable( false ),
+ startdate : ko.observable( null ),
+ enddate : ko.observable( null ),
+ vat_id : ko.observable(),
+ projectname : ko.observable(),
+ busy : false,
+ ownRevenue : ko.observable(),
+ otherRevenue : ko.observable(),
+ costs : ko.observable(),
+ projectname : ko.observable(),
+ years : ko.observableArray( dbo.years ),
+ months : ko.observableArray( dbo.monthArray ),
+ outstanding : ko.observable(),
+ documents : ko.observableArray( [] ),
+ comments : ko.observableArray( [] ),
+ activeTab : ko.observable(),
+ totalRevenues : ko.observable(),
+ totalInvoiced : ko.observable(),
+ totalRevenuesIncl : ko.observable(),
+ outstanding : ko.observable(),
+ outstandingInvoices : ko.observable(),
+ payed : ko.observable(),
+ totalForecast : ko.observable(),
+ toForecast : ko.observable(),
+ toInvoice : 0,
+ hourTotals : ko.observableArray( [] ),
+ totalNonDeclarable : ko.observable( 0 ),
+ totalDeclarable : ko.observable( 0 ),
+ totalRevenueHours : ko.observable( 0 ),
+ totalCosts : ko.observable(),
+ totalPayed : ko.observable(),
+ totalToPay : ko.observable(),
+ totalReservationamount: ko.observable(),
+ totalInvoiceamount : ko.observable(0),
+ totalInclBtw : ko.observable(0),
+ totalOutstanding : ko.observable(0),
+
+
+ init: function () {
+ var vm = dbo.editProjectModal;
+
+ vm.busy = true;
+
+ $( "#project-scroller" ).height( $( window ).height() - 100 );
+
+ dbo.customerDataService.getAllCustomers( 'F', function ( data ) {
+ vm.customers( data );
+ dbo.userDataService.getAllUsers( 'F', function ( data ) {
+ vm.users( data );
+ dbo.externalDataService.getAllExternals( 'F', function ( data ) {
+ vm.externals( data );
+ dbo.vatDataService.getVats( 'F', function ( data ) {
+ vm.vats( data );
+
+ vm.refreshAvailableEmployees( function () {
+ vm.refreshProject();
+
+ vm.activeTab( 'DASHBOARD' );
+
+ vm.busy = false;
+ } );
+ } );
+ } );
+ } );
+ } );
+ },
+
+ setActiveTab: function ( tab ) {
+ var vm = dbo.editProjectModal;
+
+ vm.activeTab( tab );
+ },
+
+ togglePayments: function () {
+ this.showPayments( !this.showPayments() );
+
+ var showPayments = sessionStorage.showPayments || [];
+
+ if ( this.showPayments() ) {
+ showPayments.push( this.id );
+ } else {
+ var index = showPayments.indexOf( this.id );
+ showPayments.splice( index, 1 );
+ }
+
+ sessionStorage.setItem( "showPayment", showPayments );
+ },
+
+ toggleFromReservation: function () {
+ var vm = dbo.editProjectModal;
+ var self = this;
+
+ self.fromReservation( !self.fromReservation() );
+
+ vm.saveProjectCost( self );
+ },
+
+ editProjectemployee: function () {
+ var self = this;
+ var vm = dbo.editProjectModal;
+ $.each( vm.projectEmployees(), function ( i, p ) {
+ if ( p.id == self.id ) {
+ p.inEdit( !p.inEdit() );
+ } else {
+ p.inEdit( false );
+ }
+ } );
+ },
+
+ editInvoice: function () {
+ var self = this;
+ var vm = dbo.editProjectModal;
+ $.each( vm.invoices(), function ( i, p ) {
+ if ( p.id == self.id ) {
+ p.inEdit( !p.inEdit() );
+ } else {
+ p.inEdit( false );
+ }
+ } );
+ },
+
+ editPayment: function ( parent ) {
+ var self = this;
+ $.each( parent.payments(), function ( i, p ) {
+ console.log( p.invoice_id(), ' ', parent.id );
+ if ( p.id == self.id ) {
+ p.inEdit( !p.inEdit() );
+ } else {
+ p.inEdit( false );
+ }
+ } );
+ },
+
+ setHourtype: function ( status ) {
+ if ( !this.inEdit() ) return;
+
+ var vm = dbo.editProjectModal;
+ this.hourtype_id( status );
+
+ vm.saveProjecthour( this );
+ },
+
+ setPayment: function ( status ) {
+ var vm = dbo.editProjectModal;
+
+ this.payed( status );
+
+ vm.saveReservation( this );
+ },
+
+ editProjecthour: function () {
+ var self = this;
+ var vm = dbo.editProjectModal;
+ $.each( vm.projecthours(), function ( i, p ) {
+ if ( p.id == self.id ) {
+ p.inEdit( !p.inEdit() );
+ } else {
+ p.inEdit( false );
+ }
+ } );
+ },
+
+ editProjectcosts: function () {
+ var self = this;
+ var vm = dbo.editProjectModal;
+ $.each( vm.projectcosts(), function ( i, p ) {
+ if ( p.id == self.id ) {
+ p.inEdit( !p.inEdit() );
+ } else {
+ p.inEdit( false );
+ }
+ } );
+ },
+
+ editForecast: function () {
+ var self = this;
+ var vm = dbo.editProjectModal;
+ $.each( vm.forecasts(), function ( i, p ) {
+ if ( p.id == self.id ) {
+ p.inEdit( !p.inEdit() );
+ } else {
+ p.inEdit( false );
+ }
+ } );
+ vm.toForecasting();
+ },
+
+ editReservation: function () {
+ var self = this;
+ var vm = dbo.editProjectModal;
+ $.each( vm.reservations(), function ( i, p ) {
+ if ( p.id == self.id ) {
+ p.inEdit( !p.inEdit() );
+ } else {
+ p.inEdit( false );
+ }
+ } );
+ },
+
+ newOffer: function () {
+ var vm = dbo.editProjectModal;
+ var service = dbo.offersService;
+ service.vm = dbo.editProjectModal;
+
+ service.newOffer( vm.projectID, vm.customerID() );
+ },
+
+ newInvoice: function () {
+ var vm = dbo.editProjectModal;
+
+ var invoice = {
+ id : 0,
+ project_id : vm.projectID,
+ invoicenumber : '',
+ invoicedate : null,
+ invoiceamount : 0,
+ forecastamount: 0,
+ forecastdate : null,
+ inEdit : true,
+ showPayments : false,
+ payments : []
+ }
+
+ vm.invoices.push( new vm.Invoice( invoice ) );
+ },
+
+ newPayment: function () {
+ var vm = dbo.editProjectModal;
+ var self = this;
+ console.log( self );
+ var payment = {
+ id : 0,
+ invoice_id : self.id,
+ paymentdate : null,
+ paymentamount: 0,
+ inEdit : true
+ };
+
+ self.payments.push( new vm.Payment( payment ) );
+ },
+
+ newProjecthour: function () {
+ var vm = dbo.editProjectModal;
+
+ var projecthour = {
+ id : 0,
+ projectemployee_id: null,
+ hourdate : null,
+ hours : 0,
+ hourtype_id : 1,
+ inEdit : true
+ };
+
+ vm.projecthours.push( new vm.Projecthour( projecthour ) );
+ },
+
+ newProjectcost: function () {
+ var vm = dbo.editProjectModal;
+
+ var projectcost = {
+ id : 0,
+ external_id: null,
+ description: '',
+ date : null,
+ costs : 0,
+ payed : 0,
+ inEdit : true
+ };
+
+ vm.projectcosts.push( new vm.Projectcost( projectcost ) );
+ },
+
+ editOffer: function () {
+ var service = dbo.offersService;
+ service.vm = dbo.editProjectModal;
+
+ service.editOffer( this, false, false, true );
+ },
+
+ addProject: function ( callback ) {
+ var vm = dbo.editProjectModal;
+
+ vm.callback = callback;
+
+ dbo.projectDataService.addProject( function ( data ) {
+ console.log( data );
+ vm.projectID = data;
+
+ vm.showProject( true );
+
+ vm.init();
+ } );
+ },
+
+ addProjectemployee: function () {
+ var vm = dbo.editProjectModal;
+ dbo.projectDataService.addProjectemployee( vm.projectID, function () {
+ vm.refreshProject();
+ } );
+ },
+
+ addForecast: function () {
+ var vm = dbo.editProjectModal;
+
+ var forecast = {
+ id : 0,
+ project_id : vm.projectID,
+ year : dbo.currentYear,
+ month_id : dbo.currentMonth,
+ forecastamount: 0,
+ inEdit : true
+ };
+
+ vm.forecasts.push( new vm.Forecast( forecast ) );
+ },
+
+ addReservation: function () {
+ var vm = dbo.editProjectModal;
+
+ var reservation = {
+ id : 0,
+ project_id : vm.projectID,
+ reservationamount : 0,
+ external_id : null,
+ inEdit : true,
+ invalidReservation: true
+ };
+
+ vm.reservations.push( new vm.Reservation( reservation ) );
+ },
+
+ editProject: function ( projectID, callback ) {
+ var vm = dbo.editProjectModal;
+
+ vm.callback = callback;
+ vm.projectID = projectID;
+
+ vm.showProject( true );
+
+ vm.init();
+ },
+
+ saveProjectname: function () {
+ var vm = dbo.editProjectModal;
+ if ( timeout ) {
+ clearTimeout( timeout );
+ timeout = null;
+ }
+ timeout = setTimeout( function () {
+ vm.saveProject();
+ }, 700 );
+ },
+
+ saveProject: function () {
+ var vm = dbo.editProjectModal;
+
+ if ( vm.busy ) return;
+
+ var submitDATA = {
+ id : vm.projectID,
+ customer_id : vm.customerID(),
+ projectleader_id: vm.projectleaderID(),
+ projectname : vm.projectname(),
+ startdate : vm.startdate(),
+ enddate : vm.enddate(),
+ vat_id : vm.vat_id()
+ }
+
+ dbo.projectDataService.saveProject( vm.projectID, submitDATA, function ( data ) {
+ vm.refreshProject();
// vm.projectID = data.projectID;
- } );
- },
-
- changeProjectemployee: function () {
- var vm = dbo.editProjectModal;
- var self = this;
- dbo.userDataService.getUser( this.employeeID(), function ( data ) {
- self.tarif( data.hourlyrate );
-
- vm.saveProjectemployee( self );
- } );
- },
-
- saveProjectemployee: function ( self = false ) {
- var vm = dbo.editProjectModal;
- if ( !self ) self = this;
-
- $.each( vm.users(), function ( i, p ) {
- if ( self.employeeID == p.id ) self.fullname( p.fullname );
- } );
-
- if ( timeout ) {
- clearTimeout( timeout );
- timeout = null;
- }
- timeout = setTimeout( function () {
- var submitDATA = {
- id : self.id,
- user_id: self.employeeID(),
- tarif : self.tarif() ? self.tarif().toString().replace( ',', '.' ) : 0,
- budget : self.budget() ? self.budget().toString().replace( ',', '.' ) : 0
- }
-
- dbo.projectDataService.saveProjectemployee( submitDATA, function () {
- vm.refreshAvailableEmployees();
- } );
- }, 400 );
- },
-
- saveInvoice: function () {
- var self = this;
-
- var submitDATA = {
- id : self.id,
- project_id : self.project_id(),
- invoicenumber : self.invoicenumber(),
- invoicedate : self.invoicedate(),
- invoiceamount : self.invoiceamount(),
- forecastamount: self.forecastamount(),
- forecastdate : self.forecastdate(),
- vat_id : self.vat_id()
- };
-
- dbo.projectDataService.saveInvoice( submitDATA, function ( data ) {
- if ( data.success ) self.id = data.invoiceID;
- } );
-
- },
-
- savePayment: function () {
- var self = this;
-
- var submitDATA = {
- id : self.id,
- invoice_id : self.invoice_id(),
- paymentdate : self.paymentdate(),
- paymentamount: self.paymentamount()
- };
-
- dbo.projectDataService.savePayment( submitDATA, function ( data ) {
- if ( data.success ) self.id = data.paymentID;
- } );
- },
-
- saveProjecthour: function ( self = false ) {
- if ( !self ) self = this;
-
- if ( !self.projectemployee_id() ) return;
-
- var submitDATA = {
- id : self.id,
- projectemployee_id: self.projectemployee_id(),
- hourdate : self.hourdate(),
- hourtype_id : self.hourtype_id(),
- hours : self.hours()
- };
-
- dbo.projectDataService.saveProjecthour( submitDATA, function ( data ) {
- console.log( data );
- if ( data.success ) self.id = data.projecthourID;
- } );
- },
-
- saveProjectcosts: function () {
- var vm = dbo.editProjectModal;
-
- vm.saveProjectCost( this );
- },
-
- saveProjectCost: function ( self ) {
- var vm = dbo.editProjectModal;
-
- var submitDATA = {
- id : self.id,
- project_id : vm.projectID,
- external_id : self.external_id(),
- description : self.description(),
- date : self.date(),
- costs : self.costs(),
- payed : self.payed(),
- from_reservation: self.fromReservation() ? 'T' : 'F'
- };
-
- dbo.projectDataService.saveProjectcost( submitDATA, function ( data ) {
- if ( data.success ) self.id = data.projectcostID;
- } );
- },
-
- saveForecast: function () {
- var vm = dbo.editProjectModal;
- var self = this;
-
- var submitDATA = {
- id : self.id,
- project_id : self.project_id,
- year : self.year(),
- month_id : self.month_id(),
- forecastamount: self.forecastamount()
- }
-
- dbo.projectDataService.saveForecast( submitDATA, function ( data ) {
- if ( data.success ) self.id = data.forecastID;
- vm.toForecasting();
- } );
- },
-
- saveReservation: function ( self = false ) {
- var vm = dbo.editProjectModal;
- if ( !self ) self = this;
-
- if ( !self.external_id ) {
- self.invalidReservation( true );
- return;
- }
-
- var submitDATA = {
- id : self.id,
- project_id : self.project_id,
- external_id : self.external_id(),
- reservationamount: self.reservationamount()
- }
-
- dbo.projectDataService.saveReservation( submitDATA, function ( data ) {
- if ( data.success ) {
- self.invalidReservation( false );
- self.id = data.reservationID;
- }
- } );
- },
-
- removeProjectemployee: function () {
- var vm = dbo.editProjectModal;
- var self = this;
-
- tellMe( {
- title : 'verwijderen projectmedewerker',
- message : 'weet u zeker dat u de projectmedewerker wilt verwijderen, dit kan niet ongedaan worden gemaakt',
- notify : true,
- noText : 'nee verwijder de projectmedewerker niet',
- yesText : 'ja verwijder de projectmedewerker',
- modalClass: 'modal-warning'
- }, function ( response ) {
- console.log( response );
- if ( response ) {
- dbo.projectDataService.removeProjectemployee( self.id, function ( data ) {
- if ( data.result ) {
- vm.refreshProject();
- } else {
- tellMe( {
- title : 'fout bij verwijderen projectmedewerker',
- message : 'de projectmedewerker kan niet worden verwijderd, verwijder eerst alle uren behorende bij deze medewerker bij dit project',
- modalClass: 'modal-danger'
- } );
- }
- } );
- }
- } );
- },
-
- removeInvoice: function () {
- var vm = dbo.editProjectModal;
- var self = this;
-
- tellMe( {
- title : 'verwijderen factuur',
- message : 'weet u zeker dat u deze factuur wilt verwijderen, dit kan niet ongedaan worden gemaakt',
- notify : true,
- noText : 'nee verwijder de factuur niet',
- yesText : 'ja verwijder de factuur',
- modalClass: 'modal-warning'
- }, function ( response ) {
- console.log( response );
- if ( response ) {
- dbo.projectDataService.removeInvoice( self.id, function ( data ) {
- if ( data.result ) {
- vm.refreshProject();
- } else {
- tellMe( {
- title : 'fout bij verwijderen factuur',
- message : 'de factuur kan niet worden verwijderd, verwijder eerst alle betalingen op deze factuur',
- modalClass: 'modal-danger'
- } );
- }
- } );
- }
- } );
- },
-
- removeProjectcosts: function () {
- var vm = dbo.editProjectModal;
- var self = this;
-
- tellMe( {
- title : 'verwijderen inkomende factuur',
- message : 'weet u zeker dat u deze inkomende factuur wilt verwijderen, dit kan niet ongedaan worden gemaakt',
- notify : true,
- noText : 'nee verwijder de inkomende factuur niet',
- yesText : 'ja verwijder de inkomende factuur',
- modalClass: 'modal-warning'
- }, function ( response ) {
- console.log( response );
- if ( response ) {
- dbo.projectDataService.removeIncomingInvoice( self.id, function ( data ) {
- if ( data.result ) {
- vm.refreshProject();
- } else {
- tellMe( {
- title : 'fout bij verwijderen inkomende factuur',
- message : 'de inkomende factuur kan niet worden verwijderd',
- modalClass: 'modal-danger'
- } );
- }
- } );
- }
- } );
- },
-
- removeOffer: function () {
- var vm = dbo.editProjectModal;
- var self = this;
-
- tellMe( {
- title : 'verwijderen offerte',
- message : 'weet u zeker dat u de offerte wilt verwijderen, dit kan niet ongedaan worden gemaakt',
- notify : true,
- noText : 'nee verwijder de offerte niet',
- yesText : 'ja verwijder de offerte',
- modalClass: 'modal-warning'
- }, function ( response ) {
- console.log( response );
- if ( response ) {
- dbo.offerDataService.removeOffer( self.id, function ( data ) {
- if ( data.result ) {
- vm.refreshProject();
- } else {
- tellMe( {
- title : 'fout bij verwijderen offerte',
- message : 'de offerte kan niet worden verwijderd',
- modalClass: 'modal-danger'
- } );
- }
- } );
- }
- } );
- },
-
- removePayment: function () {
- var vm = dbo.editProjectModal;
- var self = this;
-
- tellMe( {
- title : 'verwijderen betaling',
- message : 'weet u zeker dat u de betaling wilt verwijderen, dit kan niet ongedaan worden gemaakt',
- notify : true,
- noText : 'nee verwijder de betaling niet',
- yesText : 'ja verwijder de betaling',
- modalClass: 'modal-warning'
- }, function ( response ) {
- console.log( response );
- if ( response ) {
- dbo.projectDataService.removePayment( self.id, function ( data ) {
- if ( data.result ) {
- vm.refreshProject();
- } else {
- tellMe( {
- title : 'fout bij verwijderen betaling',
- message : 'de betaling kan niet worden verwijderd',
- modalClass: 'modal-danger'
- } );
- }
- } );
- }
- } );
- },
-
- removeProjecthour: function () {
- var vm = dbo.editProjectModal;
- var self = this;
-
- tellMe( {
- title : 'verwijderen projectuur',
- message : 'weet u zeker dat u de projectuur wilt verwijderen, dit kan niet ongedaan worden gemaakt',
- notify : true,
- noText : 'nee verwijder de projectuur niet',
- yesText : 'ja verwijder de projectuur',
- modalClass: 'modal-warning'
- }, function ( response ) {
- console.log( response );
- if ( response ) {
- dbo.projectDataService.removeProjecthour( self.id, function ( data ) {
- if ( data.result ) {
- vm.refreshProject();
- } else {
- tellMe( {
- title : 'fout bij verwijderen projectuur',
- message : 'de projectuur kan niet worden verwijderd',
- modalClass: 'modal-danger'
- } );
- }
- } );
- }
- } );
- },
-
- removeForecast: function () {
- var vm = dbo.editProjectModal;
- var self = this;
-
- tellMe( {
- title : 'verwijderen prognose',
- message : 'weet u zeker dat u deze prognose wilt verwijderen, dit kan niet ongedaan worden gemaakt',
- notify : true,
- noText : 'nee verwijder prognose niet',
- yesText : 'ja verwijder de prognose',
- modalClass: 'modal-warning'
- }, function ( response ) {
- console.log( response );
- if ( response ) {
- dbo.projectDataService.removeForecast( self.id, function ( data ) {
- if ( data.result ) {
- vm.refreshProject();
- } else {
- tellMe( {
- title : 'fout bij verwijderen prognose',
- message : 'de prognose kan niet worden verwijderd',
- modalClass: 'modal-danger'
- } );
- }
- } );
- }
- } );
- },
-
- removeReservation: function () {
- var vm = dbo.editProjectModal;
- var self = this;
-
- tellMe( {
- title : 'verwijderen reservering',
- message : 'weet u zeker dat u deze reservering wilt verwijderen, dit kan niet ongedaan worden gemaakt',
- notify : true,
- noText : 'nee verwijder reservering niet',
- yesText : 'ja verwijder de reservering',
- modalClass: 'modal-warning'
- }, function ( response ) {
- console.log( response );
- if ( response ) {
- dbo.projectDataService.removeReservation( self.id, function ( data ) {
- if ( data.result ) {
- vm.refreshProject();
- } else {
- tellMe( {
- title : 'fout bij verwijderen reserevring',
- message : 'de reservering kan niet worden verwijderd',
- modalClass: 'modal-danger'
- } );
- }
- } );
- }
- } );
- },
-
- closeProject: function () {
- var vm = dbo.editProjectModal;
-
- vm.showProject( false );
-
- vm.callback();
- },
-
- validateNumber: function ( field ) {
- this[field]( dbo.helpers.validateNumber( this[field](), true ) );
- },
-
- refreshAvailableEmployees: function ( callback ) {
- var vm = dbo.editProjectModal;
-
- dbo.projectDataService.getAvailableEmployees( vm.projectID, function ( data ) {
- vm.availableEmployees( data );
-
- if ( typeof (callback) == 'function' ) callback();
- } );
- },
-
- refreshProject: function () {
- var vm = dbo.editProjectModal;
- vm.busy = true;
-
- dbo.projectDataService.getProject( vm.projectID, function ( data ) {
- var revenues = Number( data.offer.own_revenue ) + Number( data.offer.other_revenue ) + Number( data.offer.costs );
- var totalRevenuesIncl = Math.round( (revenues * (Number( data.vat.vatrate ) + 100)) / 100 );
-
- vm.id = data.id
- vm.projectleaderID( data.projectleader_id );
- vm.customerID( data.customer_id );
- vm.startdate( dbo.helpers.mysql2date( data.startdate ) );
- vm.enddate( dbo.helpers.mysql2date( data.enddate ) );
- vm.projectnumber( data.projectnumber );
- vm.projectname( data.projectname );
- vm.vat_id( data.vat_id );
- vm.totalRevenuesIncl( dbo.helpers.numberWithPoints( totalRevenuesIncl ) );
- vm.totalInvoiced( dbo.helpers.numberWithPoints( Math.round( Number( data.invoiceDetails.totalinvoiced ) ) ) );
- vm.outstanding( dbo.helpers.numberWithPoints( Math.round( Number( totalRevenuesIncl ) ) - Math.round( Number( data.invoiceDetails.totalinvoiced ) ) ) );
- vm.outstandingInvoices( dbo.helpers.numberWithPoints( Math.round( Number( data.invoiceDetails.totalinvoiced ) ) - Math.round( Number( data.invoiceDetails.payed ) ) ) );
- vm.payed( dbo.helpers.numberWithPoints( Math.round( Number( data.invoiceDetails.payed ) ) ) );
- vm.toInvoice = Math.round( totalRevenuesIncl - Number( data.invoiceDetails.totalinvoiced ) );
-
- vm.projectEmployees.removeAll();
- vm.projecthours.removeAll();
-
- vm.ownRevenue( dbo.helpers.numberWithPoints( Math.round( Number( data.offer.own_revenue ) ) ) );
- vm.otherRevenue( dbo.helpers.numberWithPoints( Math.round( Number( data.offer.other_revenue ) ) ) );
- vm.costs( dbo.helpers.numberWithPoints( Math.round( Number( data.offer.costs ) ) ) );
- vm.totalRevenues( dbo.helpers.numberWithPoints( Math.round( revenues ) ) );
-
- vm.hourTotals.removeAll();
- vm.totalNonDeclarable( 0 );
- vm.totalDeclarable( 0 );
- vm.totalRevenueHours( 0 );
- _.each( data.hourTotals, function ( p ) {
- vm.hourTotals.push( {
- fullname : p.fullname,
- nondeclarable: p.nondeclarable,
- declarable : p.declarable,
- revenues : dbo.helpers.numberWithPoints( Math.round( Number( p.revenues ) ) )
- } );
- vm.totalNonDeclarable( Number( vm.totalNonDeclarable() ) + Number( p.nondeclarable ) );
- vm.totalDeclarable( Number( vm.totalDeclarable() ) + Number( p.declarable ) );
- vm.totalRevenueHours( Number( vm.totalRevenueHours() ) + Number( p.revenues ) );
- } );
- vm.totalRevenueHours( dbo.helpers.numberWithPoints( Math.round( vm.totalRevenueHours() ) ) );
-
- _.each( data.projectemployees, function ( p ) {
- vm.projectEmployees.push( new vm.Projectemployee( 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 ) );
- } );
- } );
-
- vm.projectcosts.removeAll();
- _.each( data.projectcosts, function ( p ) {
- vm.projectcosts.push( new vm.Projectcost( p ) );
- } );
-
- vm.invoices.removeAll();
- _.each( data.invoices, function ( p ) {
- vm.invoices.push( new vm.Invoice( p ) );
- } );
-
- vm.forecasts.removeAll();
- _.each( data.forecasts, function ( p ) {
- vm.forecasts.push( new vm.Forecast( p ) );
- } );
-
- vm.toForecasting();
-
- vm.reservations.removeAll();
- _.each( data.reservations, function ( p ) {
- vm.reservations.push( new vm.Reservation( p ) );
- } );
-
- vm.refreshDocuments();
-
- vm.busy = false;
+ } );
+ },
+
+ changeProjectemployee: function () {
+ var vm = dbo.editProjectModal;
+ var self = this;
+ dbo.userDataService.getUser( this.employeeID(), function ( data ) {
+ self.tarif( data.hourlyrate );
+
+ vm.saveProjectemployee( self );
+ } );
+ },
+
+ saveProjectemployee: function ( self = false ) {
+ var vm = dbo.editProjectModal;
+ if ( !self ) self = this;
+
+ $.each( vm.users(), function ( i, p ) {
+ if ( self.employeeID == p.id ) self.fullname( p.fullname );
+ } );
+
+ if ( timeout ) {
+ clearTimeout( timeout );
+ timeout = null;
+ }
+ timeout = setTimeout( function () {
+ var submitDATA = {
+ id : self.id,
+ user_id: self.employeeID(),
+ tarif : self.tarif() ? self.tarif().toString().replace( ',', '.' ) : 0,
+ budget : self.budget() ? self.budget().toString().replace( ',', '.' ) : 0
+ }
+
+ dbo.projectDataService.saveProjectemployee( submitDATA, function () {
+ vm.refreshAvailableEmployees();
+ } );
+ }, 400 );
+ },
+
+ saveInvoice: function () {
+ var self = this;
+
+ var submitDATA = {
+ id : self.id,
+ project_id : self.project_id(),
+ invoicenumber : self.invoicenumber(),
+ invoicedate : self.invoicedate(),
+ invoiceamount : self.invoiceamount(),
+ forecastamount: self.forecastamount(),
+ forecastdate : self.forecastdate(),
+ vat_id : self.vat_id()
+ };
+
+ dbo.projectDataService.saveInvoice( submitDATA, function ( data ) {
+ if ( data.success ) self.id = data.invoiceID;
+ } );
+
+ },
+
+ savePayment: function () {
+ var self = this;
+
+ var submitDATA = {
+ id : self.id,
+ invoice_id : self.invoice_id(),
+ paymentdate : self.paymentdate(),
+ paymentamount: self.paymentamount()
+ };
+
+ dbo.projectDataService.savePayment( submitDATA, function ( data ) {
+ if ( data.success ) self.id = data.paymentID;
+ } );
+ },
+
+ saveProjecthour: function ( self = false ) {
+ if ( !self ) self = this;
+
+ if ( !self.projectemployee_id() ) return;
+
+ var submitDATA = {
+ id : self.id,
+ projectemployee_id: self.projectemployee_id(),
+ hourdate : self.hourdate(),
+ hourtype_id : self.hourtype_id(),
+ hours : self.hours()
+ };
+
+ dbo.projectDataService.saveProjecthour( submitDATA, function ( data ) {
+ console.log( data );
+ if ( data.success ) self.id = data.projecthourID;
+ } );
+ },
+
+ saveProjectcosts: function () {
+ var vm = dbo.editProjectModal;
+
+ vm.saveProjectCost( this );
+ },
+
+ saveProjectCost: function ( self ) {
+ var vm = dbo.editProjectModal;
+
+ var submitDATA = {
+ id : self.id,
+ project_id : vm.projectID,
+ external_id : self.external_id(),
+ description : self.description(),
+ date : self.date(),
+ costs : self.costs(),
+ payed : self.payed(),
+ from_reservation: self.fromReservation() ? 'T' : 'F'
+ };
+
+ dbo.projectDataService.saveProjectcost( submitDATA, function ( data ) {
+ if ( data.success ) self.id = data.projectcostID;
+ } );
+ },
+
+ saveForecast: function () {
+ var vm = dbo.editProjectModal;
+ var self = this;
+
+ var submitDATA = {
+ id : self.id,
+ project_id : self.project_id,
+ year : self.year(),
+ month_id : self.month_id(),
+ forecastamount: self.forecastamount()
+ }
+
+ dbo.projectDataService.saveForecast( submitDATA, function ( data ) {
+ if ( data.success ) self.id = data.forecastID;
+ vm.toForecasting();
+ } );
+ },
+
+ saveReservation: function ( self = false ) {
+ var vm = dbo.editProjectModal;
+ if ( !self ) self = this;
+
+ if ( !self.external_id ) {
+ self.invalidReservation( true );
+ return;
+ }
+
+ var submitDATA = {
+ id : self.id,
+ project_id : self.project_id,
+ external_id : self.external_id(),
+ reservationamount: self.reservationamount()
+ }
+
+ dbo.projectDataService.saveReservation( submitDATA, function ( data ) {
+ if ( data.success ) {
+ self.invalidReservation( false );
+ self.id = data.reservationID;
+ }
+ } );
+ },
+
+ removeProjectemployee: function () {
+ var vm = dbo.editProjectModal;
+ var self = this;
+
+ tellMe( {
+ title : 'verwijderen projectmedewerker',
+ message : 'weet u zeker dat u de projectmedewerker wilt verwijderen, dit kan niet ongedaan worden gemaakt',
+ notify : true,
+ noText : 'nee verwijder de projectmedewerker niet',
+ yesText : 'ja verwijder de projectmedewerker',
+ modalClass: 'modal-warning'
+ }, function ( response ) {
+ console.log( response );
+ if ( response ) {
+ dbo.projectDataService.removeProjectemployee( self.id, function ( data ) {
+ if ( data.result ) {
+ vm.refreshProject();
+ } else {
+ tellMe( {
+ title : 'fout bij verwijderen projectmedewerker',
+ message : 'de projectmedewerker kan niet worden verwijderd, verwijder eerst alle uren behorende bij deze medewerker bij dit project',
+ modalClass: 'modal-danger'
+ } );
+ }
+ } );
+ }
+ } );
+ },
+
+ removeInvoice: function () {
+ var vm = dbo.editProjectModal;
+ var self = this;
+
+ tellMe( {
+ title : 'verwijderen factuur',
+ message : 'weet u zeker dat u deze factuur wilt verwijderen, dit kan niet ongedaan worden gemaakt',
+ notify : true,
+ noText : 'nee verwijder de factuur niet',
+ yesText : 'ja verwijder de factuur',
+ modalClass: 'modal-warning'
+ }, function ( response ) {
+ console.log( response );
+ if ( response ) {
+ dbo.projectDataService.removeInvoice( self.id, function ( data ) {
+ if ( data.result ) {
+ vm.refreshProject();
+ } else {
+ tellMe( {
+ title : 'fout bij verwijderen factuur',
+ message : 'de factuur kan niet worden verwijderd, verwijder eerst alle betalingen op deze factuur',
+ modalClass: 'modal-danger'
+ } );
+ }
+ } );
+ }
+ } );
+ },
+
+ removeProjectcosts: function () {
+ var vm = dbo.editProjectModal;
+ var self = this;
+
+ tellMe( {
+ title : 'verwijderen inkomende factuur',
+ message : 'weet u zeker dat u deze inkomende factuur wilt verwijderen, dit kan niet ongedaan worden gemaakt',
+ notify : true,
+ noText : 'nee verwijder de inkomende factuur niet',
+ yesText : 'ja verwijder de inkomende factuur',
+ modalClass: 'modal-warning'
+ }, function ( response ) {
+ console.log( response );
+ if ( response ) {
+ dbo.projectDataService.removeIncomingInvoice( self.id, function ( data ) {
+ if ( data.result ) {
+ vm.refreshProject();
+ } else {
+ tellMe( {
+ title : 'fout bij verwijderen inkomende factuur',
+ message : 'de inkomende factuur kan niet worden verwijderd',
+ modalClass: 'modal-danger'
+ } );
+ }
+ } );
+ }
+ } );
+ },
+
+ removeOffer: function () {
+ var vm = dbo.editProjectModal;
+ var self = this;
+
+ tellMe( {
+ title : 'verwijderen offerte',
+ message : 'weet u zeker dat u de offerte wilt verwijderen, dit kan niet ongedaan worden gemaakt',
+ notify : true,
+ noText : 'nee verwijder de offerte niet',
+ yesText : 'ja verwijder de offerte',
+ modalClass: 'modal-warning'
+ }, function ( response ) {
+ console.log( response );
+ if ( response ) {
+ dbo.offerDataService.removeOffer( self.id, function ( data ) {
+ if ( data.result ) {
+ vm.refreshProject();
+ } else {
+ tellMe( {
+ title : 'fout bij verwijderen offerte',
+ message : 'de offerte kan niet worden verwijderd',
+ modalClass: 'modal-danger'
+ } );
+ }
+ } );
+ }
+ } );
+ },
+
+ removePayment: function () {
+ var vm = dbo.editProjectModal;
+ var self = this;
+
+ tellMe( {
+ title : 'verwijderen betaling',
+ message : 'weet u zeker dat u de betaling wilt verwijderen, dit kan niet ongedaan worden gemaakt',
+ notify : true,
+ noText : 'nee verwijder de betaling niet',
+ yesText : 'ja verwijder de betaling',
+ modalClass: 'modal-warning'
+ }, function ( response ) {
+ console.log( response );
+ if ( response ) {
+ dbo.projectDataService.removePayment( self.id, function ( data ) {
+ if ( data.result ) {
+ vm.refreshProject();
+ } else {
+ tellMe( {
+ title : 'fout bij verwijderen betaling',
+ message : 'de betaling kan niet worden verwijderd',
+ modalClass: 'modal-danger'
+ } );
+ }
+ } );
+ }
+ } );
+ },
+
+ removeProjecthour: function () {
+ var vm = dbo.editProjectModal;
+ var self = this;
+
+ tellMe( {
+ title : 'verwijderen projectuur',
+ message : 'weet u zeker dat u de projectuur wilt verwijderen, dit kan niet ongedaan worden gemaakt',
+ notify : true,
+ noText : 'nee verwijder de projectuur niet',
+ yesText : 'ja verwijder de projectuur',
+ modalClass: 'modal-warning'
+ }, function ( response ) {
+ console.log( response );
+ if ( response ) {
+ dbo.projectDataService.removeProjecthour( self.id, function ( data ) {
+ if ( data.result ) {
+ vm.refreshProject();
+ } else {
+ tellMe( {
+ title : 'fout bij verwijderen projectuur',
+ message : 'de projectuur kan niet worden verwijderd',
+ modalClass: 'modal-danger'
+ } );
+ }
+ } );
+ }
+ } );
+ },
+
+ removeForecast: function () {
+ var vm = dbo.editProjectModal;
+ var self = this;
+
+ tellMe( {
+ title : 'verwijderen prognose',
+ message : 'weet u zeker dat u deze prognose wilt verwijderen, dit kan niet ongedaan worden gemaakt',
+ notify : true,
+ noText : 'nee verwijder prognose niet',
+ yesText : 'ja verwijder de prognose',
+ modalClass: 'modal-warning'
+ }, function ( response ) {
+ console.log( response );
+ if ( response ) {
+ dbo.projectDataService.removeForecast( self.id, function ( data ) {
+ if ( data.result ) {
+ vm.refreshProject();
+ } else {
+ tellMe( {
+ title : 'fout bij verwijderen prognose',
+ message : 'de prognose kan niet worden verwijderd',
+ modalClass: 'modal-danger'
+ } );
+ }
+ } );
+ }
+ } );
+ },
+
+ removeReservation: function () {
+ var vm = dbo.editProjectModal;
+ var self = this;
+
+ tellMe( {
+ title : 'verwijderen reservering',
+ message : 'weet u zeker dat u deze reservering wilt verwijderen, dit kan niet ongedaan worden gemaakt',
+ notify : true,
+ noText : 'nee verwijder reservering niet',
+ yesText : 'ja verwijder de reservering',
+ modalClass: 'modal-warning'
+ }, function ( response ) {
+ console.log( response );
+ if ( response ) {
+ dbo.projectDataService.removeReservation( self.id, function ( data ) {
+ if ( data.result ) {
+ vm.refreshProject();
+ } else {
+ tellMe( {
+ title : 'fout bij verwijderen reserevring',
+ message : 'de reservering kan niet worden verwijderd',
+ modalClass: 'modal-danger'
+ } );
+ }
+ } );
+ }
+ } );
+ },
+
+ closeProject: function () {
+ var vm = dbo.editProjectModal;
+
+ vm.showProject( false );
+
+ vm.callback();
+ },
+
+ validateNumber: function ( field ) {
+ this[field]( dbo.helpers.validateNumber( this[field](), true ) );
+ },
+
+ refreshAvailableEmployees: function ( callback ) {
+ var vm = dbo.editProjectModal;
+
+ dbo.projectDataService.getAvailableEmployees( vm.projectID, function ( data ) {
+ vm.availableEmployees( data );
+
+ if ( typeof (callback) == 'function' ) callback();
+ } );
+ },
+
+ refreshProject: function () {
+ var vm = dbo.editProjectModal;
+ vm.busy = true;
+
+ dbo.projectDataService.getProject( vm.projectID, function ( data ) {
+ var revenues = Number( data.offer.own_revenue ) + Number( data.offer.other_revenue ) + Number( data.offer.costs );
+ var totalRevenuesIncl = Math.round( (revenues * (Number( data.vat.vatrate ) + 100)) / 100 );
+
+ vm.id = data.id
+ vm.projectleaderID( data.projectleader_id );
+ vm.customerID( data.customer_id );
+ vm.startdate( dbo.helpers.mysql2date( data.startdate ) );
+ vm.enddate( dbo.helpers.mysql2date( data.enddate ) );
+ vm.projectnumber( data.projectnumber );
+ vm.projectname( data.projectname );
+ vm.vat_id( data.vat_id );
+ vm.totalRevenuesIncl( dbo.helpers.numberWithPoints( totalRevenuesIncl ) );
+ vm.totalInvoiced( dbo.helpers.numberWithPoints( Math.round( Number( data.invoiceDetails.totalinvoiced ) ) ) );
+ vm.outstanding( dbo.helpers.numberWithPoints( Math.round( Number( totalRevenuesIncl ) ) - Math.round( Number( data.invoiceDetails.totalinvoiced ) ) ) );
+ vm.outstandingInvoices( dbo.helpers.numberWithPoints( Math.round( Number( data.invoiceDetails.totalinvoiced ) ) - Math.round( Number( data.invoiceDetails.payed ) ) ) );
+ vm.payed( dbo.helpers.numberWithPoints( Math.round( Number( data.invoiceDetails.payed ) ) ) );
+ vm.toInvoice = Math.round( totalRevenuesIncl - Number( data.invoiceDetails.totalinvoiced ) );
+
+ vm.totalCosts( 0 );
+ vm.totalPayed( 0 );
+ vm.totalToPay( 0 );
+ vm.totalReservationamount( 0 );
+ vm.totalInvoiceamount( 0 );
+ vm.totalInclBtw( 0 );
+ vm.totalOutstanding( 0 );
+
+ vm.projectEmployees.removeAll();
+ vm.projecthours.removeAll();
+
+ vm.ownRevenue( dbo.helpers.numberWithPoints( Math.round( Number( data.offer.own_revenue ) ) ) );
+ vm.otherRevenue( dbo.helpers.numberWithPoints( Math.round( Number( data.offer.other_revenue ) ) ) );
+ vm.costs( dbo.helpers.numberWithPoints( Math.round( Number( data.offer.costs ) ) ) );
+ vm.totalRevenues( dbo.helpers.numberWithPoints( Math.round( revenues ) ) );
+
+ vm.hourTotals.removeAll();
+ vm.totalNonDeclarable( 0 );
+ vm.totalDeclarable( 0 );
+ vm.totalRevenueHours( 0 );
+ _.each( data.hourTotals, function ( p ) {
+ vm.hourTotals.push( {
+ fullname : p.fullname,
+ nondeclarable: p.nondeclarable,
+ declarable : p.declarable,
+ revenues : dbo.helpers.numberWithPoints( Math.round( Number( p.revenues ) ) )
+ } );
+ vm.totalNonDeclarable( Number( vm.totalNonDeclarable() ) + Number( p.nondeclarable ) );
+ vm.totalDeclarable( Number( vm.totalDeclarable() ) + Number( p.declarable ) );
+ vm.totalRevenueHours( Number( vm.totalRevenueHours() ) + Number( p.revenues ) );
+ } );
+ vm.totalRevenueHours( dbo.helpers.numberWithPoints( Math.round( vm.totalRevenueHours() ) ) );
+
+ _.each( data.projectemployees, function ( p ) {
+ vm.projectEmployees.push( new vm.Projectemployee( 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 ) );
+ } );
+ } );
+
+ vm.projectcosts.removeAll();
+ _.each( data.projectcosts, function ( p ) {
+ vm.projectcosts.push( new vm.Projectcost( p ) );
+ } );
+
+ vm.invoices.removeAll();
+ _.each( data.invoices, function ( p ) {
+ vm.invoices.push( new vm.Invoice( p ) );
+ } );
+
+ vm.forecasts.removeAll();
+ _.each( data.forecasts, function ( p ) {
+ vm.forecasts.push( new vm.Forecast( p ) );
+ } );
+
+ vm.toForecasting();
+
+ vm.reservations.removeAll();
+ _.each( data.reservations, function ( p ) {
+ vm.reservations.push( new vm.Reservation( p ) );
+ } );
+
+ vm.refreshDocuments();
+
+ vm.busy = false;
// dbo.charts.drawHoursVsBudget( 340, 230, 'hours-vs-budget' );
// dbo.charts.drawInvoicesVsPayed( 36000, 24000, 11000, 'invoice-vs-payed' );
- } );
- },
+ } );
+ },
- toForecasting: function () {
- var vm = dbo.editProjectModal;
+ toForecasting: function () {
+ var vm = dbo.editProjectModal;
- vm.totalForecast( 0 );
- vm.toForecast( vm.toInvoice );
- _.each( vm.forecasts(), function ( p ) {
- vm.totalForecast( vm.totalForecast() + Number( p.forecastamount() ) );
- vm.toForecast( vm.toForecast() - Number( p.forecastamount() ) );
- } );
- vm.toForecast( dbo.helpers.numberWithPoints( Number( vm.toForecast() ) ) );
- vm.totalForecast( dbo.helpers.numberWithPoints( Number( vm.totalForecast() ) ) );
- },
+ vm.totalForecast( 0 );
+ vm.toForecast( vm.toInvoice );
+ _.each( vm.forecasts(), function ( p ) {
+ vm.totalForecast( vm.totalForecast() + Number( p.forecastamount() ) );
+ vm.toForecast( vm.toForecast() - Number( p.forecastamount() ) );
+ } );
+ vm.toForecast( dbo.helpers.numberWithPoints( Math.round( Number( vm.toForecast() ) ) ) );
+ vm.totalForecast( dbo.helpers.numberWithPoints( Math.round( Number( vm.totalForecast() ) ) ) );
+ },
- Projectemployee: function ( data ) {
- var self = this;
+ Projectemployee: function ( data ) {
+ var self = this;
- self.id = data.id;
- self.employeeID = ko.observable( data.user_id );
- self.fullname = ko.observable( data.user ? data.user.fullname : '#NB' );
- self.tarif = ko.observable( data.tarif ? data.tarif : 0 );
- self.budget = ko.observable( data.budget ? data.budget : 0 );
- self.inEdit = ko.observable( sessionStorage.editEmployee == data.id );
- },
+ self.id = data.id;
+ self.employeeID = ko.observable( data.user_id );
+ self.fullname = ko.observable( data.user ? data.user.fullname : '#NB' );
+ self.tarif = ko.observable( data.tarif ? data.tarif : 0 );
+ self.budget = ko.observable( data.budget ? data.budget : 0 );
+ self.inEdit = ko.observable( sessionStorage.editEmployee == data.id );
+ },
- Projecthour: function ( data, fullname ) {
- var self = this;
- var vm = dbo.editProjectModal;
+ Projecthour: function ( data, fullname ) {
+ var self = this;
+ var vm = dbo.editProjectModal;
- var inEdit = sessionStorage.Projecthour == data.id;
- if ( !inEdit ) inEdit = data.inEdit || false;
+ var inEdit = sessionStorage.Projecthour == data.id;
+ if ( !inEdit ) inEdit = data.inEdit || false;
- self.id = data.id;
- self.fullname = ko.observable( fullname );
- self.projectemployee_id = ko.observable( data.projectemployee_id );
- self.hourdate = ko.observable( dbo.helpers.mysql2date( data.hourdate ) );
- self.hours = ko.observable( data.hours );
- self.hourtype_id = ko.observable( data.hourtype_id );
- self.inEdit = ko.observable( inEdit );
+ self.id = data.id;
+ self.fullname = ko.observable( fullname );
+ self.projectemployee_id = ko.observable( data.projectemployee_id );
+ self.hourdate = ko.observable( dbo.helpers.mysql2date( data.hourdate ) );
+ self.hours = ko.observable( data.hours );
+ self.hourtype_id = ko.observable( data.hourtype_id );
+ self.inEdit = ko.observable( inEdit );
- self.revenue = ko.pureComputed( function () {
- if ( !self.projectemployee_id() ) return 0;
- var tarif = dbo.helpers.findArrayElement( 'id', 'tarif', self.projectemployee_id(), vm.projectEmployees() )();
+ self.revenue = ko.pureComputed( function () {
+ if ( !self.projectemployee_id() ) return 0;
+ var tarif = dbo.helpers.findArrayElement( 'id', 'tarif', self.projectemployee_id(), vm.projectEmployees() )();
- if ( isNaN( tarif ) ) return 0;
- if ( isNaN( self.hours() ) ) return 0;
- if ( self.hourtype_id() != 1 ) return 0;
+ if ( isNaN( tarif ) ) return 0;
+ if ( isNaN( self.hours() ) ) return 0;
+ if ( self.hourtype_id() != 1 ) return 0;
- return (tarif * self.hours()).toFixed( 0 );
- } );
- },
+ return (tarif * self.hours()).toFixed( 0 );
+ } );
+ },
- Projectcost: function ( data ) {
- var self = this;
+ Projectcost: function ( data ) {
+ var self = this;
+ var vm = dbo.editProjectModal;
- self.id = data.id;
- self.external_id = ko.observable( data.external_id );
- self.contactperson = ko.observable( data.external ? data.external.contactperson : '' );
- self.description = ko.observable( data.description );
- self.date = ko.observable( dbo.helpers.mysql2date( data.date ) );
- self.costs = ko.observable( data.costs );
- self.payed = ko.observable( data.payed );
- self.inEdit = ko.observable( data.inEdit || false );
- self.fromReservation = ko.observable( data.from_reservation == 'T' ? true : false );
+ self.id = data.id;
+ self.external_id = ko.observable( data.external_id );
+ self.contactperson = ko.observable( data.external ? data.external.contactperson : '' );
+ self.description = ko.observable( data.description );
+ self.date = ko.observable( dbo.helpers.mysql2date( data.date ) );
+ self.costs = ko.observable( data.costs );
+ self.payed = ko.observable( data.payed );
+ self.inEdit = ko.observable( data.inEdit || false );
+ self.fromReservation = ko.observable( data.from_reservation == 'T' ? true : false );
- this.toPay = ko.pureComputed( function () {
- if ( isNaN( self.costs() ) ) return 0;
- if ( isNaN( self.payed() ) ) return 0;
- return self.costs() - self.payed();
- } )
- },
+ self.toPay = ko.pureComputed( function () {
+ if ( isNaN( self.costs() ) ) return 0;
+ if ( isNaN( self.payed() ) ) return 0;
- Invoice: function ( data ) {
- var vm = dbo.editProjectModal;
- var self = this;
- var inEdit = sessionStorage.editInvoice == data.id;
- if ( !inEdit ) inEdit = data.inEdit || false;
+ return self.costs() - self.payed();
+ } )
- self.id = data.id;
- self.project_id = ko.observable( data.project_id );
- self.invoicenumber = ko.observable( data.invoicenumber );
- self.invoicedate = ko.observable( dbo.helpers.mysql2date( data.invoicedate ) );
- self.invoiceamount = ko.observable( data.invoiceamount.toFixed( 0 ) );
- self.forecastamount = ko.observable( data.forecastamount.toFixed( 0 ) );
- self.forecastdate = ko.observable( dbo.helpers.mysql2date( data.forecastdate ) );
- self.vat_id = ko.observable( data.vat_id );
+ vm.totalCosts( Number( vm.totalCosts() ) + Number( self.costs() ) );
+ vm.totalPayed( Number( vm.totalPayed() ) + Number( self.payed() ) );
+ vm.totalToPay( Number( vm.totalToPay() ) + Number( self.toPay() ) );
+ },
- self.inEdit = ko.observable( inEdit );
+ Invoice: function ( data ) {
+ var vm = dbo.editProjectModal;
+ var self = this;
+ var inEdit = sessionStorage.editInvoice == data.id;
+ if ( !inEdit ) inEdit = data.inEdit || false;
- self.inclBtw = ko.pureComputed( function () {
- if ( !self.vat_id() ) return self.invoiceamount();
+ self.id = data.id;
+ self.project_id = ko.observable( data.project_id );
+ self.invoicenumber = ko.observable( data.invoicenumber );
+ self.invoicedate = ko.observable( dbo.helpers.mysql2date( data.invoicedate ) );
+ self.invoiceamount = ko.observable( data.invoiceamount.toFixed( 0 ) );
+ self.forecastamount = ko.observable( data.forecastamount.toFixed( 0 ) );
+ self.forecastdate = ko.observable( dbo.helpers.mysql2date( data.forecastdate ) );
+ self.vat_id = ko.observable( data.vat_id );
- return (Number( self.invoiceamount() ) + (self.invoiceamount() *
- (dbo.helpers.findArrayElement( 'id', 'vatrate', self.vat_id(), this.vats() ) / 100))).toFixed( 0 );
- }, dbo.editProjectModal );
+ self.inEdit = ko.observable( inEdit );
- self.showPayments = ko.observable( data.showPayments || false );
- if ( sessionStorage.showPayment == data.id ) self.showPayments( true );
+ self.inclBtw = ko.pureComputed( function () {
+ if ( !self.vat_id() ) return self.invoiceamount();
- self.payments = ko.observableArray( [] );
- $.each( data.payments, function ( i, p ) {
- self.payments.push( new vm.Payment( p, self.invoicenumber ) );
- } );
+ return (Number( self.invoiceamount() ) + (self.invoiceamount() *
+ (dbo.helpers.findArrayElement( 'id', 'vatrate', self.vat_id(), this.vats() ) / 100))).toFixed( 0 );
+ }, dbo.editProjectModal );
- self.outstanding = ko.pureComputed( function () {
- var payed = 0
- $.each( self.payments(), function ( i, p ) {
- payed += Number( p.paymentamount() );
- } );
- return (self.inclBtw() - payed).toFixed( 0 );
- } );
- },
+ self.showPayments = ko.observable( data.showPayments || false );
+ if ( sessionStorage.showPayment == data.id ) self.showPayments( true );
- Payment: function ( data ) {
- var inEdit = sessionStorage.editPayment == data.id;
- if ( !inEdit ) inEdit = data.inEdit || false;
+ self.payments = ko.observableArray( [] );
+ $.each( data.payments, function ( i, p ) {
+ self.payments.push( new vm.Payment( p, self.invoicenumber ) );
+ } );
- this.id = data.id;
- this.invoice_id = ko.observable( data.invoice_id );
- this.paymentdate = ko.observable( dbo.helpers.mysql2date( data.paymentdate ) );
- this.paymentamount = ko.observable( data.paymentamount );
- this.inEdit = ko.observable( inEdit );
- },
+ self.outstanding = ko.pureComputed( function () {
+ var payed = 0
+ $.each( self.payments(), function ( i, p ) {
+ payed += Number( p.paymentamount() );
+ } );
+ return (self.inclBtw() - payed).toFixed( 0 );
+ } );
- Forecast: function ( data ) {
- this.id = data.id;
- this.project_id = data.project_id;
- this.year = ko.observable( data.year );
- this.month_id = ko.observable( data.month_id );
- this.forecastamount = ko.observable( data.forecastamount );
- this.inEdit = ko.observable( data.inEdit || false );
- },
+ vm.totalInvoiceamount( Number( vm.totalInvoiceamount() + Number( self.invoiceamount() ) ) );
+ vm.totalInclBtw( Number( vm.totalInclBtw() + Number( self.inclBtw() ) ) );
+ vm.totalOutstanding( Number( vm.totalOutstanding() + Number( self.outstanding() ) ) );
+ },
- Reservation: function ( data ) {
- this.id = data.id;
- this.project_id = data.project_id;
- this.reservationamount = ko.observable( data.reservationamount );
- this.external_id = ko.observable( data.external_id );
- this.inEdit = ko.observable( data.inEdit || false );
- this.invalidReservation = ko.observable( data.invalidReservation || false );
- },
+ Payment: function ( data ) {
+ var inEdit = sessionStorage.editPayment == data.id;
+ if ( !inEdit ) inEdit = data.inEdit || false;
- addDocument: function ( data, evt ) {
- var vm = dbo.editProjectModal;
- uploadFile( evt.target.files[0], vm.projectID, function () {
- vm.refreshDocuments();
- } );
- },
+ this.id = data.id;
+ this.invoice_id = ko.observable( data.invoice_id );
+ this.paymentdate = ko.observable( dbo.helpers.mysql2date( data.paymentdate ) );
+ this.paymentamount = ko.observable( data.paymentamount );
+ this.inEdit = ko.observable( inEdit );
+ },
- addComment: function () {
- var vm = dbo.editProjectModal;
- dbo.commentsDataService.addComment( vm.selectedRowID(), vm.tableName, function ( commentID ) {
- dbo.commentModel.showComment( commentID, function () {
- vm.refreshComments();
- } )
- } );
- },
+ Forecast: function ( data ) {
+ this.id = data.id;
+ this.project_id = data.project_id;
+ this.year = ko.observable( data.year );
+ this.month_id = ko.observable( data.month_id );
+ this.forecastamount = ko.observable( data.forecastamount );
+ this.inEdit = ko.observable( data.inEdit || false );
+ },
- editComment: function () {
- var vm = dbo.editProjectModal;
- dbo.commentModel.showComment( this.id, function () {
- vm.refreshComments();
- } );
- },
+ Reservation: function ( data ) {
+ var vm = dbo.editProjectModal;
+ this.project_id = data.project_id;
+ this.reservationamount = ko.observable( data.reservationamount );
+ this.external_id = ko.observable( data.external_id );
+ this.inEdit = ko.observable( data.inEdit || false );
+ this.invalidReservation = ko.observable( data.invalidReservation || false );
- downloadDocument: function () {
- window.open( 'index.php/projects/documentsController/downloadDocument/' + this.id );
- },
+ vm.totalReservationamount(
+ Number( vm.totalReservationamount() ) + Number( this.reservationamount() ) )
+ },
- refreshComments: function () {
- var vm = dbo.editProjectModal;
+ addDocument: function ( data, evt ) {
+ var vm = dbo.editProjectModal;
+ uploadFile( evt.target.files[0], vm.projectID, function () {
+ vm.refreshDocuments();
+ } );
+ },
- dbo.commentsDataService.getComments( vm.selectedRowID(), vm.tableName, function ( data ) {
- vm.comments.removeAll();
- console.log( data );
- $.each( data, function ( i, p ) {
- vm.comments.push( new vm.Comment( p ) );
- } );
- } );
- },
+ addComment: function () {
+ var vm = dbo.editProjectModal;
+ dbo.commentsDataService.addComment( vm.selectedRowID(), vm.tableName, function ( commentID ) {
+ dbo.commentModel.showComment( commentID, function () {
+ vm.refreshComments();
+ } )
+ } );
+ },
- refreshDocuments: function () {
- var vm = dbo.editProjectModal;
- console.log( vm.projectID );
- dbo.documentsDataService.getdocuments( vm.projectID, function ( data ) {
- vm.documents.removeAll();
+ editComment: function () {
+ var vm = dbo.editProjectModal;
+ dbo.commentModel.showComment( this.id, function () {
+ vm.refreshComments();
+ } );
+ },
- $.each( data, function ( i, p ) {
- vm.documents.push( new vm.Document( p ) );
- } )
- } );
- },
+ downloadDocument: function () {
+ window.open( 'index.php/projects/documentsController/downloadDocument/' + this.id );
+ },
- Comment: function ( data ) {
- this.id = data.id;
- this.comment_date = data.comment_date;
- this.fullname = data.user.fullname;
- this.comment = ko.observable( data.comment );
- },
+ refreshComments: function () {
+ var vm = dbo.editProjectModal;
- Document: function ( data ) {
- this.id = data.id;
- this.originalname = data.originalname;
- this.uploaddate = data.uploaddate;
- this.fullname = data.user.fullname;
- }
+ dbo.commentsDataService.getComments( vm.selectedRowID(), vm.tableName, function ( data ) {
+ vm.comments.removeAll();
+ console.log( data );
+ $.each( data, function ( i, p ) {
+ vm.comments.push( new vm.Comment( p ) );
+ } );
+ } );
+ },
- };
+ refreshDocuments: function () {
+ var vm = dbo.editProjectModal;
+ console.log( vm.projectID );
+ dbo.documentsDataService.getdocuments( vm.projectID, function ( data ) {
+ vm.documents.removeAll();
- dbo.editProjectModal.totalHours = ko.pureComputed( function () {
- var vm = dbo.editProjectModal;
- var totalHours = 0
+ $.each( data, function ( i, p ) {
+ vm.documents.push( new vm.Document( p ) );
+ } )
+ } );
+ },
- $.each( vm.projecthours(), function ( i, p ) {
- if ( p.hourtype_id() == 1 ) {
- totalHours += Number( p.hours() );
- }
- } );
- return totalHours.toFixed( 2 );
- } );
+ Comment: function ( data ) {
+ this.id = data.id;
+ this.comment_date = data.comment_date;
+ this.fullname = data.user.fullname;
+ this.comment = ko.observable( data.comment );
+ },
- dbo.editProjectModal.totalRevenue = ko.pureComputed( function () {
- var vm = dbo.editProjectModal;
- var totalRevenue = 0
+ Document: function ( data ) {
+ this.id = data.id;
+ this.originalname = data.originalname;
+ this.uploaddate = data.uploaddate;
+ this.fullname = data.user.fullname;
+ }
- $.each( vm.projecthours(), function ( i, p ) {
- if ( p.hourtype_id() == 1 ) {
- totalRevenue += Number( p.revenue() );
- }
- } );
- return totalRevenue.toFixed( 0 );
- } );
+ };
- dbo.editProjectModal.totalBudget = ko.pureComputed( function () {
- var vm = dbo.editProjectModal;
- var totalBudget = 0;
+ dbo.editProjectModal.totalHours = ko.pureComputed( function () {
+ var vm = dbo.editProjectModal;
+ var totalHours = 0
- $.each( vm.projectEmployees(), function ( i, p ) {
- totalBudget += Number( p.budget() );
- } );
- return totalBudget;
- } );
+ $.each( vm.projecthours(), function ( i, p ) {
+ if ( p.hourtype_id() == 1 ) {
+ totalHours += Number( p.hours() );
+ }
+ } );
+ return totalHours.toFixed( 2 );
+ } );
- ko.applyBindings( dbo.editProjectModal, document.getElementById( 'project-modal' ) );
+ dbo.editProjectModal.totalRevenue = ko.pureComputed( function () {
+ var vm = dbo.editProjectModal;
+ var totalRevenue = 0
+
+ $.each( vm.projecthours(), function ( i, p ) {
+ if ( p.hourtype_id() == 1 ) {
+ totalRevenue += Number( p.revenue() );
+ }
+ } );
+ return totalRevenue.toFixed( 0 );
+ } );
+
+ dbo.editProjectModal.totalBudget = ko.pureComputed( function () {
+ var vm = dbo.editProjectModal;
+ var totalBudget = 0;
+
+ $.each( vm.projectEmployees(), function ( i, p ) {
+ totalBudget += Number( p.budget() );
+ } );
+ return totalBudget;
+ } );
+
+ ko.applyBindings( dbo.editProjectModal, document.getElementById( 'project-modal' ) );
} );
diff --git a/public/js/lib/modules/reports/invoicereport.js b/public/js/lib/modules/reports/invoicereport.js
index 8146d98..832dae9 100644
--- a/public/js/lib/modules/reports/invoicereport.js
+++ b/public/js/lib/modules/reports/invoicereport.js
@@ -8,251 +8,252 @@
dbo.invoicereportInit = function () {
- if ( dbo.invoicereport !== undefined ) {
+ if ( dbo.invoicereport !== undefined ) {
- dbo.invoicereport.initModule();
+ dbo.invoicereport.initModule();
- } else {
- dbo.invoicereport = {
+ } else {
+ dbo.invoicereport = {
- selectedYear : ko.observable(),
- invoiceOverview : ko.observableArray( [] ),
- forecasts : ko.observableArray( [] ),
- monthForecasts : ko.observableArray( [] ),
- monthPayments : ko.observableArray( [] ),
- months : ko.observableArray( [] ),
- monthTotals : ko.observableArray( [] ),
- monthPaymentTotals : ko.observableArray( [] ),
- validYear : ko.observable(),
- invoiceTab : ko.observable(),
- totalToInvoicingExcl : ko.observable(),
- totalToInvoicingIncl : ko.observable(),
- totalInvoicedOtherYears: ko.observable(),
- totalInvoicedThisYear : ko.observable(),
- totalPayment : ko.observable(),
- totalToPay : ko.observable(),
- invoicesTotal : ko.observable(),
- needInvoice : ko.observable(),
- forecastThisYear : ko.observable(),
- forecastOtherYears : ko.observable(),
- forecastRemaining : ko.observable(),
- totalProjectPayments : ko.observable(),
- orderType : 'projectnumber',
- orderDirection : false,
- archive : ko.observable( false ),
+ selectedYear : ko.observable(),
+ invoiceOverview : ko.observableArray( [] ),
+ forecasts : ko.observableArray( [] ),
+ monthForecasts : ko.observableArray( [] ),
+ monthPayments : ko.observableArray( [] ),
+ months : ko.observableArray( [] ),
+ monthTotals : ko.observableArray( [] ),
+ monthPaymentTotals : ko.observableArray( [] ),
+ validYear : ko.observable(),
+ invoiceTab : ko.observable(),
+ totalToInvoicingExcl : ko.observable(),
+ totalToInvoicingIncl : ko.observable(),
+ totalInvoicedOtherYears: ko.observable(),
+ totalInvoicedThisYear : ko.observable(),
+ totalPayment : ko.observable(),
+ totalToPay : ko.observable(),
+ invoicesTotal : ko.observable(),
+ needInvoice : ko.observable(),
+ forecastThisYear : ko.observable(),
+ forecastOtherYears : ko.observable(),
+ forecastRemaining : ko.observable(),
+ totalProjectPayments : ko.observable(),
+ orderType : 'projectnumber',
+ orderDirection : false,
+ archive : ko.observable( false ),
- init: function () {
- var vm = dbo.invoicereport;
+ init: function () {
+ var vm = dbo.invoicereport;
- vm.selectedYear( (new Date()).getFullYear() );
- vm.invoiceTab( 'invoice' );
- vm.validYear( true );
- vm.months( dbo.monthArray );
+ vm.selectedYear( (new Date()).getFullYear() );
+ vm.invoiceTab( 'invoice' );
+ vm.validYear( true );
+ vm.months( dbo.monthArray );
- vm.initModule();
- },
+ vm.initModule();
+ },
- initModule: function () {
- var vm = dbo.invoicereport;
+ initModule: function () {
+ var vm = dbo.invoicereport;
- vm.resetTotals();
+ vm.resetTotals();
- var orderDirection = vm.orderDirection ? 'ASC' : 'DESC';
- var archive = vm.archive() ? 'T' : 'F';
+ var orderDirection = vm.orderDirection ? 'ASC' : 'DESC';
+ var archive = vm.archive() ? 'T' : 'F';
- dbo.invoiceDataService.getInvoiceOverview( vm.selectedYear(), vm.orderType, orderDirection, archive, function ( data ) {
- vm.invoiceOverview( data.invoiceOverview );
- vm.setInvoiceOverviewTotals( data.invoiceOverview );
+ dbo.invoiceDataService.getInvoiceOverview( vm.selectedYear(), vm.orderType, orderDirection, archive, function ( data ) {
+ vm.invoiceOverview( data.invoiceOverview );
+ vm.setInvoiceOverviewTotals( data.invoiceOverview );
- vm.forecasts( data.forecasts );
- vm.setForecastsTotals( data.forecasts );
+ vm.forecasts( data.forecasts );
+ vm.setForecastsTotals( data.forecasts );
- vm.monthForecasts.removeAll();
- _.each( data.monthForecasts, function ( p ) {
- vm.monthForecasts.push( new vm.Monthforecast( p ) );
- } );
- _.each( vm.monthTotals(), function ( p ) {
- p.forecastamount( dbo.helpers.thousandSeparator( p.forecastamount() ) );
- } );
+ vm.monthForecasts.removeAll();
+ _.each( data.monthForecasts, function ( p ) {
+ vm.monthForecasts.push( new vm.Monthforecast( p ) );
+ } );
+ _.each( vm.monthTotals(), function ( p ) {
+ p.forecastamount( dbo.helpers.thousandSeparator( p.forecastamount() ) );
+ } );
- vm.monthPayments.removeAll();
- _.each( data.monthPayments, function ( p ) {
- vm.monthPayments.push( new vm.Monthpayment( p ) );
- vm.totalProjectPayments( Number( vm.totalProjectPayments() ) + Number( p.totalProjectPayments.replace( '.', '' ) ) );
- console.log( vm.totalProjectPayments() );
- } );
- vm.totalProjectPayments( dbo.helpers.thousandSeparator( vm.totalProjectPayments() ) );
- _.each( vm.monthPaymentTotals(), function ( p ) {
- p.paymentamount( dbo.helpers.thousandSeparator( p.paymentamount() ) );
- } );
+ vm.monthPayments.removeAll();
+ _.each( data.monthPayments, function ( p ) {
+ vm.monthPayments.push( new vm.Monthpayment( p ) );
+ vm.totalProjectPayments( Number( vm.totalProjectPayments() ) + Number( p.totalProjectPayments.replace( '.', '' ) ) );
+ } );
+ vm.totalProjectPayments( dbo.helpers.thousandSeparator( vm.totalProjectPayments() ) );
+ _.each( vm.monthPaymentTotals(), function ( p ) {
+ p.paymentamount( dbo.helpers.thousandSeparator( p.paymentamount() ) );
+ } );
- } );
- },
+ } );
+ },
- toggleArchive: function () {
- var vm = dbo.invoicereport;
- vm.archive( !vm.archive() );
+ toggleArchive: function () {
+ var vm = dbo.invoicereport;
+ vm.archive( !vm.archive() );
- vm.initModule();
- },
+ vm.initModule();
+ },
- sortList: function ( orderType ) {
- var vm = dbo.invoicereport;
+ sortList: function ( orderType ) {
+ var vm = dbo.invoicereport;
- vm.orderType = orderType;
- vm.orderDirection = !vm.orderDirection;
+ vm.orderType = orderType;
+ vm.orderDirection = !vm.orderDirection;
- vm.initModule();
- },
+ vm.initModule();
+ },
- resetTotals: function () {
- var vm = dbo.invoicereport;
+ resetTotals: function () {
+ var vm = dbo.invoicereport;
- vm.totalToInvoicingExcl( 0 );
- vm.totalToInvoicingIncl( 0 );
- vm.totalInvoicedOtherYears( 0 );
- vm.totalInvoicedThisYear( 0 );
- vm.invoicesTotal( 0 );
- vm.totalPayment( 0 );
- vm.totalToPay( 0 );
- vm.needInvoice( 0 );
- vm.forecastThisYear( 0 );
- vm.forecastOtherYears( 0 );
- vm.forecastRemaining( 0 );
- vm.totalProjectPayments( 0 );
+ vm.totalToInvoicingExcl( 0 );
+ vm.totalToInvoicingIncl( 0 );
+ vm.totalInvoicedOtherYears( 0 );
+ vm.totalInvoicedThisYear( 0 );
+ vm.invoicesTotal( 0 );
+ vm.totalPayment( 0 );
+ vm.totalToPay( 0 );
+ vm.needInvoice( Number( 0 ) );
+ vm.forecastThisYear( 0 );
+ vm.forecastOtherYears( 0 );
+ vm.forecastRemaining( 0 );
+ vm.totalProjectPayments( 0 );
- vm.monthTotals.removeAll();
- vm.monthPaymentTotals.removeAll();
- for ( var i = 1; i <= 12; i++ ) {
- vm.monthTotals.push( {monthID: i, forecastamount: ko.observable( 0 )} );
- vm.monthPaymentTotals.push( {monthID: i, paymentamount: ko.observable( 0 )} );
- }
- },
+ vm.monthTotals.removeAll();
+ vm.monthPaymentTotals.removeAll();
+ for ( var i = 1; i <= 12; i++ ) {
+ vm.monthTotals.push( {monthID: i, forecastamount: ko.observable( 0 )} );
+ vm.monthPaymentTotals.push( {monthID: i, paymentamount: ko.observable( 0 )} );
+ }
+ },
- setInvoiceOverviewTotals: function ( data ) {
- var vm = dbo.invoicereport;
+ setInvoiceOverviewTotals: function ( data ) {
+ var vm = dbo.invoicereport;
- _.each( data, function ( p ) {
- vm.totalToInvoicingExcl( vm.totalToInvoicingExcl() + Number( p.totalToInvoicingExcl.replace( '.', '' ) ) );
- vm.totalToInvoicingIncl( vm.totalToInvoicingIncl() + Number( p.totalToInvoicingIncl.replace( '.', '' ) ) );
- vm.totalInvoicedOtherYears( vm.totalInvoicedOtherYears() + Number( p.totalInvoicedOtherYears.replace( '.', '' ) ) );
- vm.totalInvoicedThisYear( vm.totalInvoicedThisYear() + Number( p.totalInvoicedThisYear.replace( '.', '' ) ) );
- vm.invoicesTotal( vm.invoicesTotal() + Number( p.invoicesTotal.replace( '.', '' ) ) );
- vm.totalPayment( vm.totalPayment() + Number( p.projectPayment.replace( '.', '' ) ) );
- vm.totalToPay( vm.totalToPay() + Number( p.invoiceToPay.replace( '.', '' ) ) );
- vm.needInvoice( vm.needInvoice() + Number( p.needInvoice.replace( '.', '' ) ) );
- } );
+ _.each( data, function ( p ) {
+ vm.totalToInvoicingExcl( vm.totalToInvoicingExcl() + Number( p.totalToInvoicingExcl.replace( '.', '' ) ) );
+ vm.totalToInvoicingIncl( vm.totalToInvoicingIncl() + Number( p.totalToInvoicingIncl.replace( '.', '' ) ) );
+ vm.totalInvoicedOtherYears( vm.totalInvoicedOtherYears() + Number( p.totalInvoicedOtherYears.replace( '.', '' ) ) );
+ vm.totalInvoicedThisYear( vm.totalInvoicedThisYear() + Number( p.totalInvoicedThisYear.replace( '.', '' ) ) );
+ vm.invoicesTotal( vm.invoicesTotal() + Number( p.invoicesTotal.replace( '.', '' ) ) );
+ vm.totalPayment( vm.totalPayment() + Number( p.projectPayment.replace( '.', '' ) ) );
+ vm.totalToPay( vm.totalToPay() + Number( p.invoiceToPay.replace( '.', '' ) ) );
+ vm.needInvoice( Number( vm.needInvoice() ) + Number( p.needInvoice.replace( '.', '' ) ) );
+ } );
- vm.totalToInvoicingExcl( dbo.helpers.thousandSeparator( vm.totalToInvoicingExcl() ) );
- vm.totalToInvoicingIncl( dbo.helpers.thousandSeparator( vm.totalToInvoicingIncl() ) );
- vm.totalInvoicedOtherYears( dbo.helpers.thousandSeparator( vm.totalInvoicedOtherYears() ) );
- vm.totalInvoicedThisYear( dbo.helpers.thousandSeparator( vm.totalInvoicedThisYear() ) );
- vm.invoicesTotal( dbo.helpers.thousandSeparator( vm.invoicesTotal() ) );
- vm.totalPayment( dbo.helpers.thousandSeparator( vm.totalPayment() ) );
- vm.totalToPay( dbo.helpers.thousandSeparator( vm.totalToPay() ) );
- vm.needInvoice( dbo.helpers.thousandSeparator( vm.needInvoice() ) );
- },
+ vm.totalToInvoicingExcl( dbo.helpers.thousandSeparator( vm.totalToInvoicingExcl() ) );
+ vm.totalToInvoicingIncl( dbo.helpers.thousandSeparator( vm.totalToInvoicingIncl() ) );
+ vm.totalInvoicedOtherYears( dbo.helpers.thousandSeparator( vm.totalInvoicedOtherYears() ) );
+ vm.totalInvoicedThisYear( dbo.helpers.thousandSeparator( vm.totalInvoicedThisYear() ) );
+ vm.invoicesTotal( dbo.helpers.thousandSeparator( vm.invoicesTotal() ) );
+ vm.totalPayment( dbo.helpers.thousandSeparator( vm.totalPayment() ) );
+ vm.totalToPay( dbo.helpers.thousandSeparator( vm.totalToPay() ) );
+ vm.needInvoice( dbo.helpers.thousandSeparator( vm.needInvoice() ) );
+ },
- setForecastsTotals: function ( data ) {
- var vm = dbo.invoicereport;
+ setForecastsTotals: function ( data ) {
+ var vm = dbo.invoicereport;
- _.each( data, function ( p ) {
- vm.forecastThisYear( vm.forecastThisYear() + Number( p.forecastThisYear.replace( '.', '' ) ) );
- vm.forecastOtherYears( vm.forecastOtherYears() + Number( p.forecastOtherYears.replace( '.', '' ) ) );
- vm.forecastRemaining( vm.forecastRemaining() + Number( p.forecastRemaining.replace( '.', '' ) ) );
- } );
- vm.forecastThisYear( dbo.helpers.thousandSeparator( vm.forecastThisYear() ) );
- vm.forecastOtherYears( dbo.helpers.thousandSeparator( vm.forecastOtherYears() ) );
- vm.forecastRemaining( dbo.helpers.thousandSeparator( vm.forecastRemaining() ) );
- },
+ _.each( data, function ( p ) {
+ vm.forecastThisYear( vm.forecastThisYear() + Number( p.forecastThisYear.replace( '.', '' ) ) );
+ vm.forecastOtherYears( vm.forecastOtherYears() + Number( p.forecastOtherYears.replace( '.', '' ) ) );
+ vm.forecastRemaining( vm.forecastRemaining() + Number( p.forecastRemaining.replace( '.', '' ) ) );
+ } );
+ vm.forecastThisYear( dbo.helpers.thousandSeparator( vm.forecastThisYear() ) );
+ vm.forecastOtherYears( dbo.helpers.thousandSeparator( vm.forecastOtherYears() ) );
+ vm.forecastRemaining( dbo.helpers.thousandSeparator( vm.forecastRemaining() ) );
+ },
- setForecastMonthsTotals: function ( data ) {
- var vm = dbo.invoicereport;
+ setForecastMonthsTotals: function ( data ) {
+ console.log( data );
+ var vm = dbo.invoicereport;
- _.each( data, function ( p ) {
- _.each( p.forecastMonths(), function ( q ) {
- vm.forecastMonths( vm.forecastMonths() + q );
- } );
- } );
- },
+ _.each( data, function ( p ) {
+ _.each( p.forecastMonths(), function ( q ) {
+ vm.forecastMonths( vm.forecastMonths() + q );
+ } );
+ } );
+ },
- checkYear: function () {
- var vm = dbo.invoicereport;
- 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 );
+ checkYear: function () {
+ var vm = dbo.invoicereport;
+ 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();
- },
+ vm.initModule();
+ },
- setActivetab: function ( page ) {
- var vm = dbo.invoicereport;
+ setActivetab: function ( page ) {
+ var vm = dbo.invoicereport;
- vm.invoiceTab( page );
- },
+ vm.invoiceTab( page );
+ },
- Monthforecast: function ( data ) {
- var vm = dbo.invoicereport;
- var self = this;
- self.projectnumber = data.projectnumber;
- self.projectname = data.projectname;
- self.customer = data.customer;
- self.needInvoice = data.needInvoice;
- self.forecastOtherYears = data.forecastOtherYears;
- self.forecastRemaining = data.forecastRemaining;
+ Monthforecast: function ( data ) {
+ console.log( data );
+ var vm = dbo.invoicereport;
+ var self = this;
+ self.projectnumber = data.projectnumber;
+ self.projectname = data.projectname;
+ self.customer = data.customer;
+ self.needInvoice = data.needInvoice;
+ self.forecastOtherYears = data.forecastOtherYears;
+ self.forecastRemaining = data.forecastRemaining;
- self.forecastMonths = ko.observableArray( [] );
- _.each( data.forecastMonths, function ( p, i ) {
- self.forecastMonths.push( new vm.ForecastMonth( p ) );
- _.each( vm.monthTotals(), function ( q ) {
- if ( q.monthID == i ) q.forecastamount( Number( q.forecastamount() ) + Number( p.forecastamount ) );
- } );
- } );
- },
+ self.forecastMonths = ko.observableArray( [] );
+ _.each( data.forecastMonths, function ( p, i ) {
+ self.forecastMonths.push( new vm.ForecastMonth( p ) );
+ _.each( vm.monthTotals(), function ( q ) {
+ if ( q.monthID == (i + 1) ) q.forecastamount( Math.round( Number( q.forecastamount() ) ) + Math.round( Number( p.forecastamount ) ) );
+ } );
+ } );
+ },
- ForecastMonth: function ( data ) {
- this.forecastamount = dbo.helpers.thousandSeparator( data.forecastamount );
- },
+ ForecastMonth: function ( data ) {
+ this.forecastamount = dbo.helpers.thousandSeparator( Math.round( data.forecastamount ) );
+ },
- Monthpayment: function ( data ) {
- var vm = dbo.invoicereport;
- var self = this;
- self.projectname = data.projectname;
- self.customer = data.customer;
- self.totalProjectPayments = data.totalProjectPayments;
+ Monthpayment: function ( data ) {
+ var vm = dbo.invoicereport;
+ var self = this;
+ self.projectname = data.projectname;
+ self.customer = data.customer;
+ self.totalProjectPayments = data.totalProjectPayments;
- self.paymentMonths = ko.observableArray( [] );
- _.each( data.monthPayments, function ( p, i ) {
- self.paymentMonths.push( new vm.PaymentMonth( p ) );
- _.each( vm.monthPaymentTotals(), function ( q ) {
- if ( q.monthID == i ) q.paymentamount( Number( q.paymentamount() ) + Number( p.paymentamount ) );
- } );
- } );
- },
+ self.paymentMonths = ko.observableArray( [] );
+ _.each( data.monthPayments, function ( p, i ) {
+ self.paymentMonths.push( new vm.PaymentMonth( p ) );
+ _.each( vm.monthPaymentTotals(), function ( q ) {
+ if ( q.monthID == i ) q.paymentamount( Math.round(Number( q.paymentamount()) ) + Math.round(Number( p.paymentamount ) ));
+ } );
+ } );
+ },
- PaymentMonth: function ( data ) {
- this.paymentamount = dbo.helpers.thousandSeparator( data.paymentamount );
- },
+ PaymentMonth: function ( data ) {
+ this.paymentamount = dbo.helpers.thousandSeparator( Math.round(data.paymentamount) );
+ },
- createSpreadsheet: function () {
- var vm = dbo.invoicereport;
+ createSpreadsheet: function () {
+ var vm = dbo.invoicereport;
- var orderDirection = vm.orderDirection ? 'ASC' : 'DESC';
- var archive = vm.archive() ? 'T' : 'F';
+ var orderDirection = vm.orderDirection ? 'ASC' : 'DESC';
+ var archive = vm.archive() ? 'T' : 'F';
- var url = 'index.php/reports/reportsController/createInvoicesSpreadsheet/' + vm.selectedYear() + '/' + vm.orderType + '/' + orderDirection + '/' + archive;
- window.open( url, '_blank' );
- }
- }
+ var url = 'index.php/reports/reportsController/createInvoicesSpreadsheet/' + vm.selectedYear() + '/' + vm.orderType + '/' + orderDirection + '/' + archive;
+ window.open( url, '_blank' );
+ }
+ }
- dbo.invoicereport.init();
+ dbo.invoicereport.init();
- ko.applyBindings(
- dbo.invoicereport, document.getElementById( "INVOICEREPORT" ) );
+ ko.applyBindings(
+ dbo.invoicereport, document.getElementById( "INVOICEREPORT" ) );
- }
+ }
-}
\ No newline at end of file
+}
diff --git a/public/js/lib/modules/reports/monthlyEmployeeHoursModule.js b/public/js/lib/modules/reports/monthlyEmployeeHoursModule.js
index 9aad7d0..9217a7f 100644
--- a/public/js/lib/modules/reports/monthlyEmployeeHoursModule.js
+++ b/public/js/lib/modules/reports/monthlyEmployeeHoursModule.js
@@ -6,462 +6,478 @@
*/
dbo.monthlyemployeehoursInit = function () {
- var timeout;
+ var timeout;
- if ( dbo.monthlyEmployeeHoursModel !== undefined ) {
+ if ( dbo.monthlyEmployeeHoursModel !== undefined ) {
- dbo.monthlyEmployeeHoursModel.initModule();
+ dbo.monthlyEmployeeHoursModel.initModule();
- } else {
+ } else {
- dbo.monthlyEmployeeHoursModel = {
+ dbo.monthlyEmployeeHoursModel = {
- uniqueEmployees : ko.observableArray( [] ),
- uniqueYears : ko.observableArray( [] ),
- sluggy : ko.observable( 'euro' ),
- years : ko.observableArray( [] ),
- selectedYear : ko.observable(),
- currentTab : false,
- 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(),
- totalOwp : ko.observable(),
- totalWorkInProgress : ko.observable(),
- totalCurrentFinancialYear : ko.observable(),
- totalNextFinancialYear : ko.observable(),
- totalInvoicedYear : ko.observableArray( [] ),
- validYear : ko.observable( true ),
- archive : ko.observable(),
+ uniqueEmployees : ko.observableArray( [] ),
+ uniqueYears : ko.observableArray( [] ),
+ sluggy : ko.observable( 'euro' ),
+ years : ko.observableArray( [] ),
+ selectedYear : ko.observable(),
+ currentTab : false,
+ 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(),
+ totalOwp : ko.observable(),
+ totalWorkInProgress : ko.observable(),
+ totalCurrentFinancialYear : ko.observable(),
+ totalNextFinancialYear : ko.observable(),
+ totalInvoicedYear : ko.observableArray( [] ),
+ validYear : ko.observable( true ),
+ archive : ko.observable(),
+ field : 'projectnumber',
+ direction : 'asc',
- init: function () {
- var vm = dbo.monthlyEmployeeHoursModel;
+ init: function () {
+ var vm = dbo.monthlyEmployeeHoursModel;
- dbo.reportsDataService.getUsedYears( function ( data ) {
- vm.years( dbo.years )
- vm.selectedYear( dbo.currentYear );
- } );
+ dbo.reportsDataService.getUsedYears( function ( data ) {
+ vm.years( dbo.years )
+ vm.selectedYear( dbo.currentYear );
+ } );
- vm.initModule();
- },
+ vm.initModule();
+ },
- 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.totalOwp( 0 );
- vm.totalPerEmployee.removeAll();
- vm.totalInvoicedYear.removeAll();
- dbo.userDataService.getUniqueProjectEmployees( function ( data ) {
- vm.uniqueEmployees.removeAll();
- $.each( data, function ( i, p ) {
- vm.uniqueEmployees.push( new vm.UniqueEmployee( p ) )
- } );
- } );
+ initModule: function () {
+ var vm = dbo.monthlyEmployeeHoursModel;
+ var archive = vm.archive() ? 'T' : 'F';
- var archive = vm.archive() ? 'T' : 'F';
- dbo.reportsDataService.getRecapProjects( archive, function ( data ) {
- vm.recap.removeAll();
- vm.uniqueYears.removeAll();
- $.each( data, function ( i, p ) {
- if ( i == 0 ) {
- $.each( p.invoiced, function ( y, q ) {
- vm.uniqueYears.push( {year: q.year} );
- } );
- }
- 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.totalOwp( dbo.helpers.thousandSeparator( vm.totalOwp() ) );
- vm.totalEmployeeHours( dbo.helpers.thousandSeparator( vm.totalEmployeeHours() ) );
- _.each( vm.totalPerEmployee(), function ( p ) {
- p.totalRevenue( dbo.helpers.thousandSeparator( p.totalRevenue() ) );
- } );
- _.each( vm.totalInvoicedYear(), function ( p ) {
- p.totalInvoiced( dbo.helpers.thousandSeparator( p.totalInvoiced() ) );
- } );
- var chartData = [];
- var chartLabels = [];
- _.each( vm.totalPerEmployee(), function ( p ) {
- chartData.push( Number( p.totalRevenue().replace( '.', '' ) ) );
- chartLabels.push( p.fullname );
- } );
- var chartDataProjects = [];
- var chartLabelsProjects = [];
- var chartDataOwh = [];
- var chartColorOwh = [];
- _.each( vm.recap(), function ( p ) {
- chartDataProjects.push( Number( p.totalEmployeeRevenues.replace( '.', '' ) ) );
- chartLabelsProjects.push( p.projectname );
- chartDataOwh.push( Number( p.workInProgress.replace( '.', '' ) ) );
- chartColorOwh.push( Number( p.workInProgress.replace( '.', '' ) ) < 0 ? '#d53d24' : '#78be4b' );
- } );
+ 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.totalOwp( 0 );
+ vm.totalPerEmployee.removeAll();
+ vm.totalInvoicedYear.removeAll();
+ dbo.userDataService.getUniqueEmployeesWithActivity( archive, function ( data ) {
+ vm.uniqueEmployees.removeAll();
+ $.each( data, function ( i, p ) {
+ vm.uniqueEmployees.push( new vm.UniqueEmployee( p ) )
+ } );
+ } );
+
+ dbo.reportsDataService.getRecapProjects( vm.field, vm.direction, archive, function ( data ) {
+ vm.recap.removeAll();
+ vm.uniqueYears.removeAll();
+ $.each( data, function ( i, p ) {
+ if ( i == 0 ) {
+ $.each( p.invoiced, function ( y, q ) {
+ vm.uniqueYears.push( {year: q.year} );
+ } );
+ }
+ 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.totalOwp( dbo.helpers.thousandSeparator( vm.totalOwp() ) );
+ vm.totalEmployeeHours( dbo.helpers.thousandSeparator( vm.totalEmployeeHours() ) );
+ _.each( vm.totalPerEmployee(), function ( p ) {
+ p.totalRevenue( dbo.helpers.thousandSeparator( p.totalRevenue() ) );
+ } );
+ _.each( vm.totalInvoicedYear(), function ( p ) {
+ p.totalInvoiced( dbo.helpers.thousandSeparator( p.totalInvoiced() ) );
+ } );
+ var chartData = [];
+ var chartLabels = [];
+ _.each( vm.totalPerEmployee(), function ( p ) {
+ chartData.push( Number( p.totalRevenue().replace( '.', '' ) ) );
+ chartLabels.push( p.fullname );
+ } );
+ var chartDataProjects = [];
+ var chartLabelsProjects = [];
+ var chartDataOwh = [];
+ var chartColorOwh = [];
+ _.each( vm.recap(), function ( p ) {
+ chartDataProjects.push( Number( p.totalEmployeeRevenues.replace( '.', '' ) ) );
+ chartLabelsProjects.push( p.projectname );
+ chartDataOwh.push( Number( p.workInProgress.replace( '.', '' ) ) );
+ chartColorOwh.push( Number( p.workInProgress.replace( '.', '' ) ) < 0 ? '#d53d24' : '#78be4b' );
+ } );
// dbo.charts.drawPie( 'recap-revenues', chartData, chartLabels, 'omzet per medewerker' );
// dbo.charts.drawPie( 'recap-revenues-project', chartDataProjects, chartLabelsProjects, 'omzet per project' );
// dbo.charts.drawHoursChart( 'recap-owh', chartDataOwh, chartLabelsProjects, 'onderhandenwerk per project', chartColorOwh );
- } );
- },
+ } );
+ },
- toggleArchive: function () {
- var vm = dbo.monthlyEmployeeHoursModel;
+ setSorting: function ( field ) {
+ var vm = dbo.monthlyEmployeeHoursModel;
+ if ( vm.field == field ) {
+ vm.direction = vm.direction == 'desc' ? 'asc' : 'desc';
+ } else {
+ vm.direction = 'asc';
+ }
- vm.archive( !vm.archive() );
- vm.initModule();
- },
+ vm.field = field;
- 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 );
- },
+ vm.initModule();
+ },
- refreshTab: function () {
- var vm = dbo.monthlyEmployeeHoursModel;
+ toggleArchive: function () {
+ var vm = dbo.monthlyEmployeeHoursModel;
- if ( vm.currentTab == false ) return;
+ vm.archive( !vm.archive() );
+ vm.initModule();
+ },
- dbo.reportsDataService.getEmployeeHours( vm.currentTab.id, vm.selectedYear(), function ( data ) {
- vm.currentTab.myData( data );
- vm.currentTab.totalJanuari( 0 );
- vm.currentTab.totalFebruari( 0 );
- vm.currentTab.totalMaart( 0 );
- vm.currentTab.totalApril( 0 );
- vm.currentTab.totalMei( 0 );
- vm.currentTab.totalJuni( 0 );
- vm.currentTab.totalJuli( 0 );
- vm.currentTab.totalAugustus( 0 );
- vm.currentTab.totalSeptember( 0 );
- vm.currentTab.totalOktober( 0 );
- vm.currentTab.totalNovember( 0 );
- vm.currentTab.totalDecember( 0 );
- vm.currentTab.totalTotal( 0 );
- vm.currentTab.totalTotalOtheryears( 0 );
- vm.currentTab.totalJanuariRevenue( 0 );
- vm.currentTab.totalFebruariRevenue( 0 );
- vm.currentTab.totalMaartRevenue( 0 );
- vm.currentTab.totalAprilRevenue( 0 );
- vm.currentTab.totalMeiRevenue( 0 );
- vm.currentTab.totalJuniRevenue( 0 );
- vm.currentTab.totalJuliRevenue( 0 );
- vm.currentTab.totalAugustusRevenue( 0 );
- vm.currentTab.totalSeptemberRevenue( 0 );
- vm.currentTab.totalOktoberRevenue( 0 );
- vm.currentTab.totalNovemberRevenue( 0 );
- vm.currentTab.totalDecemberRevenue( 0 );
- vm.currentTab.totalTotalRevenue( 0 );
- vm.currentTab.totalTotalOtheryearsRevenue( 0 );
- vm.currentTab.totalHoursChart = [];
- vm.currentTab.totalHoursRevenueChart = [];
- vm.currentTab.projectChart = [];
- $.each( vm.currentTab.myData(), function ( i, q ) {
- vm.currentTab.tarif( q.tarif );
- vm.currentTab.totalJanuari( vm.currentTab.totalJanuari() + q.januari );
- vm.currentTab.totalFebruari( vm.currentTab.totalFebruari() + q.februari );
- vm.currentTab.totalMaart( vm.currentTab.totalMaart() + q.maart );
- vm.currentTab.totalApril( vm.currentTab.totalApril() + q.april );
- vm.currentTab.totalMei( vm.currentTab.totalMei() + q.mei );
- vm.currentTab.totalJuni( vm.currentTab.totalJuni() + q.juni );
- vm.currentTab.totalJuli( vm.currentTab.totalJuli() + q.juli );
- vm.currentTab.totalAugustus( vm.currentTab.totalAugustus() + q.augustus );
- vm.currentTab.totalSeptember( vm.currentTab.totalSeptember() + q.september );
- vm.currentTab.totalOktober( vm.currentTab.totalOktober() + q.oktober );
- vm.currentTab.totalNovember( vm.currentTab.totalNovember() + q.november );
- vm.currentTab.totalDecember( vm.currentTab.totalDecember() + q.december );
- vm.currentTab.totalTotal( vm.currentTab.totalTotal() + q.totalyear );
- vm.currentTab.totalTotalOtheryears( vm.currentTab.totalTotalOtheryears() + q.totalotheryears );
+ 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 );
+ },
- vm.currentTab.totalJanuariRevenue( vm.currentTab.totalJanuariRevenue() + q.januariRevenue );
- vm.currentTab.totalFebruariRevenue( vm.currentTab.totalFebruariRevenue() + q.februariRevenue );
- vm.currentTab.totalMaartRevenue( vm.currentTab.totalMaartRevenue() + q.maartRevenue );
- vm.currentTab.totalAprilRevenue( vm.currentTab.totalAprilRevenue() + q.aprilRevenue );
- vm.currentTab.totalMeiRevenue( vm.currentTab.totalMeiRevenue() + q.meiRevenue );
- vm.currentTab.totalJuniRevenue( vm.currentTab.totalJuniRevenue() + q.juniRevenue );
- vm.currentTab.totalJuliRevenue( vm.currentTab.totalJuliRevenue() + q.juliRevenue );
- vm.currentTab.totalAugustusRevenue( vm.currentTab.totalAugustusRevenue() + q.augustusRevenue );
- vm.currentTab.totalSeptemberRevenue( vm.currentTab.totalSeptemberRevenue() + q.septemberRevenue );
- vm.currentTab.totalOktoberRevenue( vm.currentTab.totalOktoberRevenue() + q.oktoberRevenue );
- vm.currentTab.totalNovemberRevenue( vm.currentTab.totalNovemberRevenue() + q.novemberRevenue );
- vm.currentTab.totalDecemberRevenue( vm.currentTab.totalDecemberRevenue() + q.decemberRevenue );
- vm.currentTab.totalTotalRevenue( vm.currentTab.totalTotalRevenue() + q.totalyearRevenue );
- vm.currentTab.totalTotalOtheryearsRevenue( vm.currentTab.totalTotalOtheryearsRevenue() + q.totalotheryearsRevenue );
+ refreshTab: function () {
+ var vm = dbo.monthlyEmployeeHoursModel;
- vm.currentTab.projectChart.push( q.projectname );
- vm.currentTab.totalHoursChart.push( q.totalhours );
- vm.currentTab.totalHoursRevenueChart.push( q.totalhoursRevenue );
- } );
- vm.currentTab.chartData = [vm.currentTab.totalJanuari(), vm.currentTab.totalFebruari(), vm.currentTab.totalMaart(), vm.currentTab.totalApril(), vm.currentTab.totalMei(), vm.currentTab.totalJuni(), vm.currentTab.totalJuli(), vm.currentTab.totalAugustus(), vm.currentTab.totalSeptember(), vm.currentTab.totalOktober(), vm.currentTab.totalNovember(), vm.currentTab.totalDecember()];
- vm.currentTab.chartRevenueData = [vm.currentTab.totalJanuariRevenue(), vm.currentTab.totalFebruariRevenue(), vm.currentTab.totalMaartRevenue(), vm.currentTab.totalAprilRevenue(), vm.currentTab.totalMeiRevenue(), vm.currentTab.totalJuniRevenue(), vm.currentTab.totalJuliRevenue(), vm.currentTab.totalAugustusRevenue(), vm.currentTab.totalSeptemberRevenue(), vm.currentTab.totalOktoberRevenue(), vm.currentTab.totalNovemberRevenue(), vm.currentTab.totalDecemberRevenue()];
+ if ( vm.currentTab == false ) return;
+
+ dbo.reportsDataService.getEmployeeHours( vm.currentTab.id, vm.selectedYear(), function ( data ) {
+ vm.currentTab.myData( data );
+ vm.currentTab.totalJanuari( 0 );
+ vm.currentTab.totalFebruari( 0 );
+ vm.currentTab.totalMaart( 0 );
+ vm.currentTab.totalApril( 0 );
+ vm.currentTab.totalMei( 0 );
+ vm.currentTab.totalJuni( 0 );
+ vm.currentTab.totalJuli( 0 );
+ vm.currentTab.totalAugustus( 0 );
+ vm.currentTab.totalSeptember( 0 );
+ vm.currentTab.totalOktober( 0 );
+ vm.currentTab.totalNovember( 0 );
+ vm.currentTab.totalDecember( 0 );
+ vm.currentTab.totalTotal( 0 );
+ vm.currentTab.totalTotalOtheryears( 0 );
+ vm.currentTab.totalJanuariRevenue( 0 );
+ vm.currentTab.totalFebruariRevenue( 0 );
+ vm.currentTab.totalMaartRevenue( 0 );
+ vm.currentTab.totalAprilRevenue( 0 );
+ vm.currentTab.totalMeiRevenue( 0 );
+ vm.currentTab.totalJuniRevenue( 0 );
+ vm.currentTab.totalJuliRevenue( 0 );
+ vm.currentTab.totalAugustusRevenue( 0 );
+ vm.currentTab.totalSeptemberRevenue( 0 );
+ vm.currentTab.totalOktoberRevenue( 0 );
+ vm.currentTab.totalNovemberRevenue( 0 );
+ vm.currentTab.totalDecemberRevenue( 0 );
+ vm.currentTab.totalTotalRevenue( 0 );
+ vm.currentTab.totalTotalOtheryearsRevenue( 0 );
+ vm.currentTab.totalHoursChart = [];
+ vm.currentTab.totalHoursRevenueChart = [];
+ vm.currentTab.projectChart = [];
+ $.each( vm.currentTab.myData(), function ( i, q ) {
+ vm.currentTab.tarif( q.tarif );
+ vm.currentTab.totalJanuari( vm.currentTab.totalJanuari() + q.januari );
+ vm.currentTab.totalFebruari( vm.currentTab.totalFebruari() + q.februari );
+ vm.currentTab.totalMaart( vm.currentTab.totalMaart() + q.maart );
+ vm.currentTab.totalApril( vm.currentTab.totalApril() + q.april );
+ vm.currentTab.totalMei( vm.currentTab.totalMei() + q.mei );
+ vm.currentTab.totalJuni( vm.currentTab.totalJuni() + q.juni );
+ vm.currentTab.totalJuli( vm.currentTab.totalJuli() + q.juli );
+ vm.currentTab.totalAugustus( vm.currentTab.totalAugustus() + q.augustus );
+ vm.currentTab.totalSeptember( vm.currentTab.totalSeptember() + q.september );
+ vm.currentTab.totalOktober( vm.currentTab.totalOktober() + q.oktober );
+ vm.currentTab.totalNovember( vm.currentTab.totalNovember() + q.november );
+ vm.currentTab.totalDecember( vm.currentTab.totalDecember() + q.december );
+ vm.currentTab.totalTotal( vm.currentTab.totalTotal() + q.totalyear );
+ vm.currentTab.totalTotalOtheryears( vm.currentTab.totalTotalOtheryears() + q.totalotheryears );
+
+ vm.currentTab.totalJanuariRevenue( vm.currentTab.totalJanuariRevenue() + q.januariRevenue );
+ vm.currentTab.totalFebruariRevenue( vm.currentTab.totalFebruariRevenue() + q.februariRevenue );
+ vm.currentTab.totalMaartRevenue( vm.currentTab.totalMaartRevenue() + q.maartRevenue );
+ vm.currentTab.totalAprilRevenue( vm.currentTab.totalAprilRevenue() + q.aprilRevenue );
+ vm.currentTab.totalMeiRevenue( vm.currentTab.totalMeiRevenue() + q.meiRevenue );
+ vm.currentTab.totalJuniRevenue( vm.currentTab.totalJuniRevenue() + q.juniRevenue );
+ vm.currentTab.totalJuliRevenue( vm.currentTab.totalJuliRevenue() + q.juliRevenue );
+ vm.currentTab.totalAugustusRevenue( vm.currentTab.totalAugustusRevenue() + q.augustusRevenue );
+ vm.currentTab.totalSeptemberRevenue( vm.currentTab.totalSeptemberRevenue() + q.septemberRevenue );
+ vm.currentTab.totalOktoberRevenue( vm.currentTab.totalOktoberRevenue() + q.oktoberRevenue );
+ vm.currentTab.totalNovemberRevenue( vm.currentTab.totalNovemberRevenue() + q.novemberRevenue );
+ vm.currentTab.totalDecemberRevenue( vm.currentTab.totalDecemberRevenue() + q.decemberRevenue );
+ vm.currentTab.totalTotalRevenue( vm.currentTab.totalTotalRevenue() + q.totalyearRevenue );
+ vm.currentTab.totalTotalOtheryearsRevenue( vm.currentTab.totalTotalOtheryearsRevenue() + q.totalotheryearsRevenue );
+
+ vm.currentTab.projectChart.push( q.projectname );
+ vm.currentTab.totalHoursChart.push( q.totalhours );
+ vm.currentTab.totalHoursRevenueChart.push( q.totalhoursRevenue );
+ } );
+ vm.currentTab.chartData = [vm.currentTab.totalJanuari(), vm.currentTab.totalFebruari(), vm.currentTab.totalMaart(), vm.currentTab.totalApril(), vm.currentTab.totalMei(), vm.currentTab.totalJuni(), vm.currentTab.totalJuli(), vm.currentTab.totalAugustus(), vm.currentTab.totalSeptember(), vm.currentTab.totalOktober(), vm.currentTab.totalNovember(), vm.currentTab.totalDecember()];
+ vm.currentTab.chartRevenueData = [vm.currentTab.totalJanuariRevenue(), vm.currentTab.totalFebruariRevenue(), vm.currentTab.totalMaartRevenue(), vm.currentTab.totalAprilRevenue(), vm.currentTab.totalMeiRevenue(), vm.currentTab.totalJuniRevenue(), vm.currentTab.totalJuliRevenue(), vm.currentTab.totalAugustusRevenue(), vm.currentTab.totalSeptemberRevenue(), vm.currentTab.totalOktoberRevenue(), vm.currentTab.totalNovemberRevenue(), vm.currentTab.totalDecemberRevenue()];
// vm.drawCharts( vm.currentTab );
- } );
- },
+ } );
+ },
- drawCharts: function ( self ) {
- if ( self.hourView() ) {
- dbo.charts.drawHoursChart( 'hours-per-month-' + self.slug, self.chartData, dbo.monthLabels, 'uren per maand', '#f28f25' );
- dbo.charts.drawHoursChart( 'hours-per-project-' + self.slug, self.totalHoursChart, self.projectChart, 'uren per project', '#0daef0' );
- } else {
- dbo.charts.drawHoursChart( 'revenue-per-month-' + self.slug, self.chartRevenueData, dbo.monthLabels, 'omzet per maand', '#f28f25' );
- dbo.charts.drawHoursChart( 'revenue-per-project-' + self.slug, self.totalHoursRevenueChart, self.projectChart, 'omzet per project', '#0daef0' );
- }
- },
+ drawCharts: function ( self ) {
+ if ( self.hourView() ) {
+ dbo.charts.drawHoursChart( 'hours-per-month-' + self.slug, self.chartData, dbo.monthLabels, 'uren per maand', '#f28f25' );
+ dbo.charts.drawHoursChart( 'hours-per-project-' + self.slug, self.totalHoursChart, self.projectChart, 'uren per project', '#0daef0' );
+ } else {
+ dbo.charts.drawHoursChart( 'revenue-per-month-' + self.slug, self.chartRevenueData, dbo.monthLabels, 'omzet per maand', '#f28f25' );
+ dbo.charts.drawHoursChart( 'revenue-per-project-' + self.slug, self.totalHoursRevenueChart, self.projectChart, 'omzet per project', '#0daef0' );
+ }
+ },
- toggleHourView: function () {
- this.hourView( !this.hourView() );
+ toggleHourView: function () {
+ this.hourView( !this.hourView() );
- dbo.monthlyEmployeeHoursModel.drawCharts( this );
- },
+ dbo.monthlyEmployeeHoursModel.drawCharts( this );
+ },
- setActivetab: function ( tab ) {
- var vm = dbo.monthlyEmployeeHoursModel;
+ setActivetab: function ( tab ) {
+ var vm = dbo.monthlyEmployeeHoursModel;
- $.each( vm.uniqueEmployees(), function ( i, p ) {
- if ( tab == p.slug ) {
- vm.currentTab = p;
- vm.refreshTab();
- }
- } )
+ $.each( vm.uniqueEmployees(), function ( i, p ) {
+ if ( tab == p.slug ) {
+ vm.currentTab = p;
+ vm.refreshTab();
+ }
+ } )
- vm.sluggy( tab );
- },
+ vm.sluggy( tab );
+ },
- UniqueEmployee: function ( data ) {
- var vm = dbo.monthlyEmployeeHoursModel;
- var self = this;
+ UniqueEmployee: function ( data ) {
+ var vm = dbo.monthlyEmployeeHoursModel;
+ var self = this;
- self.id = data.id;
- self.fullname = data.fullname;
- self.slug = data.slug;
+ self.id = data.id;
+ self.fullname = data.fullname;
+ self.slug = data.slug;
- self.tarif = ko.observable( 0 );
+ self.tarif = ko.observable( 0 );
- self.totalJanuari = ko.observable( 0 );
- self.totalFebruari = ko.observable( 0 );
- self.totalMaart = ko.observable( 0 );
- self.totalApril = ko.observable( 0 );
- self.totalMei = ko.observable( 0 );
- self.totalJuni = ko.observable( 0 );
- self.totalJuli = ko.observable( 0 );
- self.totalAugustus = ko.observable( 0 );
- self.totalSeptember = ko.observable( 0 );
- self.totalOktober = ko.observable( 0 );
- self.totalNovember = ko.observable( 0 );
- self.totalDecember = ko.observable( 0 );
- self.totalTotal = ko.observable( 0 );
- self.totalOtheryears = ko.observable( 0 );
- self.totalTotalOtheryears = ko.observable( 0 );
+ self.totalJanuari = ko.observable( 0 );
+ self.totalFebruari = ko.observable( 0 );
+ self.totalMaart = ko.observable( 0 );
+ self.totalApril = ko.observable( 0 );
+ self.totalMei = ko.observable( 0 );
+ self.totalJuni = ko.observable( 0 );
+ self.totalJuli = ko.observable( 0 );
+ self.totalAugustus = ko.observable( 0 );
+ self.totalSeptember = ko.observable( 0 );
+ self.totalOktober = ko.observable( 0 );
+ self.totalNovember = ko.observable( 0 );
+ self.totalDecember = ko.observable( 0 );
+ self.totalTotal = ko.observable( 0 );
+ self.totalOtheryears = ko.observable( 0 );
+ self.totalTotalOtheryears = ko.observable( 0 );
- self.totalJanuariRevenue = ko.observable( 0 );
- self.totalFebruariRevenue = ko.observable( 0 );
- self.totalMaartRevenue = ko.observable( 0 );
- self.totalAprilRevenue = ko.observable( 0 );
- self.totalMeiRevenue = ko.observable( 0 );
- self.totalJuniRevenue = ko.observable( 0 );
- self.totalJuliRevenue = ko.observable( 0 );
- self.totalAugustusRevenue = ko.observable( 0 );
- self.totalSeptemberRevenue = ko.observable( 0 );
- self.totalOktoberRevenue = ko.observable( 0 );
- self.totalNovemberRevenue = ko.observable( 0 );
- self.totalDecemberRevenue = ko.observable( 0 );
- self.totalTotalRevenue = ko.observable( 0 );
- self.totalOtheryearsRevenue = ko.observable( 0 );
- self.totalTotalOtheryearsRevenue = ko.observable( 0 );
+ self.totalJanuariRevenue = ko.observable( 0 );
+ self.totalFebruariRevenue = ko.observable( 0 );
+ self.totalMaartRevenue = ko.observable( 0 );
+ self.totalAprilRevenue = ko.observable( 0 );
+ self.totalMeiRevenue = ko.observable( 0 );
+ self.totalJuniRevenue = ko.observable( 0 );
+ self.totalJuliRevenue = ko.observable( 0 );
+ self.totalAugustusRevenue = ko.observable( 0 );
+ self.totalSeptemberRevenue = ko.observable( 0 );
+ self.totalOktoberRevenue = ko.observable( 0 );
+ self.totalNovemberRevenue = ko.observable( 0 );
+ self.totalDecemberRevenue = ko.observable( 0 );
+ self.totalTotalRevenue = ko.observable( 0 );
+ self.totalOtheryearsRevenue = ko.observable( 0 );
+ self.totalTotalOtheryearsRevenue = ko.observable( 0 );
- self.hourView = ko.observable( true );
+ self.hourView = ko.observable( true );
- self.myData = ko.observableArray( [] );
- },
+ self.myData = ko.observableArray( [] );
+ },
- Detail: function ( data ) {
- this.test = data;
- },
+ Detail: function ( data ) {
+ this.test = data;
+ },
- Project: function ( data ) {
- var vm = dbo.monthlyEmployeeHoursModel;
- var self = this;
+ Project: function ( data ) {
+ var vm = dbo.monthlyEmployeeHoursModel;
+ var self = this;
- self.projectID = data.id
- self.projectnumber = data.projectnumber;
- self.instroom = data.instroom;
- self.uitstroom = data.uitstroom;
- self.projectname = data.projectname;
- self.name = data.name;
- self.revenues = dbo.helpers.thousandSeparator( data.budget );
- self.hours = data.hours;
- self.totalEmpoloyeeRevenues = 0;
- self.availableRevenue = data.own_revenue - data.projectEuros;
- self.owpNumber = self.availableRevenue < 0 ? 0 : self.availableRevenue;
- self.owp = self.owpNumber;
- self.currentFinancialYear = ko.observable( data.current_financial_year );
- self.pristine = ko.observable( true );
+ self.projectID = data.id
+ self.projectnumber = data.projectnumber;
+ self.instroom = data.instroom;
+ self.uitstroom = data.uitstroom;
+ self.projectname = data.projectname;
+ self.name = data.name;
+ self.revenues = dbo.helpers.thousandSeparator( data.budget );
+ self.hours = data.hours;
+ self.totalEmpoloyeeRevenues = 0;
+ self.availableRevenue = data.own_revenue - data.projectEuros;
+ self.owpNumber = self.availableRevenue < 0 ? 0 : self.availableRevenue;
+ self.owp = self.owpNumber;
+ self.currentFinancialYear = ko.observable( data.current_financial_year );
+ self.pristine = ko.observable( true );
- self.nextFinancialYears = ko.pureComputed( function () {
- return dbo.helpers.thousandSeparator( Number( self.owpNumber ) - Number( self.currentFinancialYear() ) );
- } );
- 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 );
+ self.nextFinancialYears = ko.pureComputed( function () {
+ return dbo.helpers.thousandSeparator( Number( self.owpNumber ) - Number( self.currentFinancialYear() ) );
+ } );
+ 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 );
- self.employees = ko.observableArray( [] );
- $.each( data.employees, function ( i, p ) {
- self.employees.push( new vm.Employee( p ) );
- if ( !self.totalEmployeeRevenues ) self.totalEmployeeRevenues = 0;
- if ( !self.totalEmployeeHours ) self.totalEmployeeHours = 0;
- } );
- self.totalEmployeeRevenues = data.projectEuros;
- self.totalEmployeeHours = data.projectHours;
- self.hoursAvailable = data.hoursAvailable;
- vm.totalEmployeeRevenues( vm.totalEmployeeRevenues() + Number( self.totalEmployeeRevenues ) );
- vm.totalEmployeeHours( vm.totalEmployeeHours() + Number( self.totalEmployeeHours ) );
- vm.totalEmployeeAvailableHours( vm.totalEmployeeAvailableHours() + Number( self.hoursAvailable ) );
- vm.totalAvailableRevenues( Number( vm.totalAvailableRevenues() ) + Number( self.availableRevenue ) );
- vm.totalOwp( Number( vm.totalOwp() ) + Number( self.owp ) );
- self.totalEmployeeRevenues = dbo.helpers.thousandSeparator( self.totalEmployeeRevenues );
- self.availableRevenue = dbo.helpers.thousandSeparator( self.availableRevenue );
- self.workInProgress = dbo.helpers.thousandSeparator( data.workInProgress );
- self.owp = dbo.helpers.thousandSeparator( self.owp );
- self.hoursAvailable = data.hoursAvailable;
+ self.employees = ko.observableArray( [] );
+ $.each( data.employees, function ( i, p ) {
+ self.employees.push( new vm.Employee( p ) );
+ if ( !self.totalEmployeeRevenues ) self.totalEmployeeRevenues = 0;
+ if ( !self.totalEmployeeHours ) self.totalEmployeeHours = 0;
+ } );
+ self.totalEmployeeRevenues = data.projectEuros;
+ self.totalEmployeeHours = data.projectHours;
+ self.hoursAvailable = data.hoursAvailable;
+ vm.totalEmployeeRevenues( vm.totalEmployeeRevenues() + Number( self.totalEmployeeRevenues ) );
+ vm.totalEmployeeHours( vm.totalEmployeeHours() + Number( self.totalEmployeeHours ) );
+ vm.totalEmployeeAvailableHours( vm.totalEmployeeAvailableHours() + Number( self.hoursAvailable ) );
+ vm.totalAvailableRevenues( Number( vm.totalAvailableRevenues() ) + Number( self.availableRevenue ) );
+ vm.totalOwp( Number( vm.totalOwp() ) + Number( self.owp ) );
+ self.totalEmployeeRevenues = dbo.helpers.thousandSeparator( self.totalEmployeeRevenues );
+ self.availableRevenue = dbo.helpers.thousandSeparator( self.availableRevenue );
+ self.workInProgress = dbo.helpers.thousandSeparator( data.workInProgress );
+ self.owp = dbo.helpers.thousandSeparator( self.owp );
+ self.hoursAvailable = data.hoursAvailable;
- self.invoiced = ko.observableArray( [] );
- $.each( data.invoiced, function ( i, p ) {
- self.invoiced.push( {invoiced: dbo.helpers.thousandSeparator( p.invoiced )} );
- } );
+ self.invoiced = ko.observableArray( [] );
+ $.each( data.invoiced, function ( i, p ) {
+ self.invoiced.push( {invoiced: dbo.helpers.thousandSeparator( p.invoiced )} );
+ } );
- vm.setTotals( data );
- },
+ vm.setTotals( data );
+ },
- setTotals: function ( data ) {
- var vm = dbo.monthlyEmployeeHoursModel;
+ setTotals: function ( data ) {
+ 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.ownRevenueAvailable ) );
- vm.totalSaldo( vm.totalSaldo() + Number( data.saldo ) );
- vm.totalWorkInProgress( vm.totalWorkInProgress() + Number( data.workInProgress ) );
+ 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.ownRevenueAvailable ) );
+ vm.totalSaldo( vm.totalSaldo() + Number( data.saldo ) );
+ vm.totalWorkInProgress( vm.totalWorkInProgress() + Number( data.workInProgress ) );
- var hasTotalEmployees = true;
- if ( vm.totalPerEmployee().length == 0 ) hasTotalEmployees = false;
- _.each( data.employees, function ( p ) {
- if ( !hasTotalEmployees ) {
- vm.totalPerEmployee.push( {
- id : p.id,
- fullname : p.fullname,
- totalRevenue : ko.observable( 0 ),
- totalHours : ko.observable( 0 ),
- totalAvailableHours: ko.observable( 0 )
- } );
- }
- var a = _.find( vm.totalPerEmployee(), function ( o ) {
- return o.id == p.id
- } );
- a.totalRevenue( a.totalRevenue() + Number( p.revenues ) );
- a.totalHours( a.totalHours() + Number( p.hours ) );
- a.totalAvailableHours( a.totalAvailableHours() + Number( p.availableHours ) );
- } );
+ var hasTotalEmployees = true;
+ if ( vm.totalPerEmployee().length == 0 ) hasTotalEmployees = false;
+ _.each( data.employees, function ( p ) {
+ if ( !hasTotalEmployees ) {
+ vm.totalPerEmployee.push( {
+ id : p.id,
+ fullname : p.fullname,
+ totalRevenue : ko.observable( 0 ),
+ totalHours : ko.observable( 0 ),
+ totalAvailableHours: ko.observable( 0 )
+ } );
+ }
+ var a = _.find( vm.totalPerEmployee(), function ( o ) {
+ return o.id == p.id
+ } );
+ a.totalRevenue( a.totalRevenue() + Number( p.revenues ) );
+ a.totalHours( a.totalHours() + Number( p.hours ) );
+ a.totalAvailableHours( a.totalAvailableHours() + Number( p.availableHours ) );
+ } );
- var hasTotalsOwpYear = true;
- if ( vm.totalInvoicedYear().length == 0 ) hasTotalsOwpYear = false;
- _.each( data.invoiced, function ( p ) {
- if ( !hasTotalsOwpYear ) {
- vm.totalInvoicedYear.push( {year: p.year, totalInvoiced: ko.observable( 0 )} );
- }
- var a = _.find( vm.totalInvoicedYear(), function ( o ) {
- return o.year == p.year
- } );
- a.totalInvoiced( a.totalInvoiced() + Number( p.invoiced ) );
- } );
- },
+ var hasTotalsOwpYear = true;
+ if ( vm.totalInvoicedYear().length == 0 ) hasTotalsOwpYear = false;
+ _.each( data.invoiced, function ( p ) {
+ if ( !hasTotalsOwpYear ) {
+ vm.totalInvoicedYear.push( {year: p.year, totalInvoiced: ko.observable( 0 )} );
+ }
+ var a = _.find( vm.totalInvoicedYear(), function ( o ) {
+ return o.year == p.year
+ } );
+ a.totalInvoiced( a.totalInvoiced() + Number( p.invoiced ) );
+ } );
+ },
- Employee: function ( data ) {
- this.fullname = data.fullname;
- this.revenues = dbo.helpers.thousandSeparator( data.revenues );
- this.hours = data.hours;
- this.budget = data.budget;
- this.availableHours = data.availableHours;
- },
+ Employee: function ( data ) {
+ this.fullname = data.fullname;
+ this.revenues = dbo.helpers.thousandSeparator( data.revenues );
+ this.hours = data.hours;
+ this.budget = data.budget;
+ this.availableHours = data.availableHours;
+ },
- saveCurrentFinancialYear: function () {
- var self = this;
- self.pristine( false );
+ saveCurrentFinancialYear: function () {
+ var self = this;
+ self.pristine( false );
- self.currentFinancialYear( dbo.helpers.validateNumber( self.currentFinancialYear() ) );
+ self.currentFinancialYear( dbo.helpers.validateNumber( self.currentFinancialYear() ) );
- if ( timeout ) {
- clearTimeout( timeout );
- timeout = null;
- }
- timeout = setTimeout( function () {
- if ( self.currentFinancialYear().length == 0 ) self.currentFinancialYear( 0 );
+ if ( timeout ) {
+ clearTimeout( timeout );
+ timeout = null;
+ }
+ timeout = setTimeout( function () {
+ if ( self.currentFinancialYear().length == 0 ) self.currentFinancialYear( 0 );
- dbo.reportsDataService.saveCurrentFinnacialYear(
- self.projectID, self.currentFinancialYear(), function () {
- self.pristine( true );
- } );
- }, 400 );
+ dbo.reportsDataService.saveCurrentFinnacialYear(
+ self.projectID, self.currentFinancialYear(), function () {
+ self.pristine( true );
+ } );
+ }, 400 );
- }
- };
+ }
+ };
- dbo.monthlyEmployeeHoursModel.init();
+ dbo.monthlyEmployeeHoursModel.init();
- dbo.monthlyEmployeeHoursModel.totalCurrentFinancialYear = ko.pureComputed( function () {
- var totalCurrentFinancialYear = 0
- var vm = dbo.monthlyEmployeeHoursModel;
- _.each( vm.recap(), function ( p ) {
- totalCurrentFinancialYear += Number( p.currentFinancialYear() );
- } );
+ dbo.monthlyEmployeeHoursModel.totalCurrentFinancialYear = ko.pureComputed( function () {
+ var totalCurrentFinancialYear = 0
+ var vm = dbo.monthlyEmployeeHoursModel;
+ _.each( vm.recap(), function ( p ) {
+ totalCurrentFinancialYear += Number( p.currentFinancialYear() );
+ } );
- return dbo.helpers.thousandSeparator( totalCurrentFinancialYear );
- } );
+ return dbo.helpers.thousandSeparator( totalCurrentFinancialYear );
+ } );
- dbo.monthlyEmployeeHoursModel.totalNextFinancialYear = ko.pureComputed( function () {
- var totalNextFinancialYear = 0
- var vm = dbo.monthlyEmployeeHoursModel;
- _.each( vm.recap(), function ( p ) {
- totalNextFinancialYear += Number( p.owpNumber ) - Number( p.currentFinancialYear() );
- } );
+ dbo.monthlyEmployeeHoursModel.totalNextFinancialYear = ko.pureComputed( function () {
+ var totalNextFinancialYear = 0
+ var vm = dbo.monthlyEmployeeHoursModel;
+ _.each( vm.recap(), function ( p ) {
+ totalNextFinancialYear += Number( p.owpNumber ) - Number( p.currentFinancialYear() );
+ } );
- return dbo.helpers.thousandSeparator( totalNextFinancialYear );
- } );
+ return dbo.helpers.thousandSeparator( totalNextFinancialYear );
+ } );
- ko.applyBindings( dbo.monthlyEmployeeHoursModel, document.getElementById( "MONTHLYEMPLOYEEHOURS" ) );
- }
+ ko.applyBindings( dbo.monthlyEmployeeHoursModel, document.getElementById( "MONTHLYEMPLOYEEHOURS" ) );
+ }
-}
\ No newline at end of file
+}