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

# Conflicts:
#	application/views/modals/partials/_reservations.php
#	application/views/pages/reservations_view.php
This commit is contained in:
2019-10-31 14:04:47 +01:00
25 changed files with 6792 additions and 2028 deletions
@@ -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()
{
@@ -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] );
}
}
}
@@ -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 ++;
}
}
}
}
@@ -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
];
}
}
private function setInvoiceReport()
{
$this->invoiceReport = [
'invoiceOverview' => $this->invoiceOverviews,
'forecasts' => $this->invoiceForecasts,
'monthForecasts' => $this->monthForecasts,
'monthPayments' => $this->monthPayments
];
}
}
@@ -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, ',', '.' )
];
}
}
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, ',', '.' )
];
}
}
+12 -1
View File
@@ -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();
}
}
}
+6 -2
View File
@@ -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;
+95 -77
View File
@@ -8,94 +8,112 @@
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' );
$details = $details->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();
}
}
}
@@ -311,7 +311,7 @@
<table class="main" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="alert alert-warning">
Nieuw wachtwoord DBOIS De Beleidsonderzoeker
Nieuw wachtwoord DBOIS De Beleidsonderzoekers
</td>
</tr>
<tr>
+1 -1
View File
@@ -311,7 +311,7 @@
<table class="main" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="alert alert-warning">
Wachtwoord De Beleidsonderzoeker
Wachtwoord De Beleidsonderzoekers
</td>
</tr>
<tr>
+1 -1
View File
@@ -7,7 +7,7 @@
<link rel="icon" href="css/images/dbo-01-80x80.png" type="image/png">
<title>** De Beleidsonderzoeker **</title>
<title>** De Beleidsonderzoekers **</title>
<?php $this->load->view( 'partials/_css' ); ?>
@@ -169,11 +169,21 @@
</table>
</td>
</tr>
<tr>
<th colspan="10" class="table-cyanish-header"></th>
</tr>
</tbody>
<tfoot>
<tr>
<th colspan="3" class="table-cyanish-header"></th>
<th class="align-right table-cyanish-header">
<span data-bind="text:dbo.helpers.numberWithPoints(totalInvoiceamount())"></span>
</th>
<th class="align-right table-cyanish-header">
<span data-bind="text:dbo.helpers.numberWithPoints(totalInclBtw())"></span>
</th>
<th class="align-right table-cyanish-header">
<span data-bind="text:dbo.helpers.numberWithPoints(totalOutstanding())"></span>
</th>
<th colspan="2" class="table-cyanish-header"></th>
</tr>
<tr>
<td colspan="5">
<button class="btn btn-primary btn-round btn-sm" data-bind="click:newInvoice">
@@ -184,4 +194,4 @@
</tfoot>
</table>
</div>
</div>
</div>
@@ -110,6 +110,20 @@
</tr>
</tbody>
<tfoot>
<tr>
<th colspan="3" class="table-cyanish-header"></th>
<th class="align-right table-cyanish-header">
<span data-bind="text:dbo.helpers.numberWithPoints(totalCosts())"></span>
</th>
<th class="align-right table-cyanish-header">
<span data-bind="text:dbo.helpers.numberWithPoints(totalPayed())"></span>
</th>
<th class="table-cyanish-header"></th>
<th class="align-right table-cyanish-header">
<span data-bind="text:dbo.helpers.numberWithPoints(totalToPay())"></span>
</th>
<th class="table-cyanish-header"></th>
</tr>
<tr>
<td colspan="8">
<button class="btn btn-primary btn-round btn-sm" data-bind="click:newProjectcost">
@@ -120,4 +134,4 @@
</tfoot>
</table>
</div>
</div>
</div>
@@ -1,7 +1,7 @@
<div class="panel panel-bordered panel-primary panel-line">
<div class="panel-heading panel-heading-project">
<h3 class="">
budget gereserveerd (incl. btw)
gereserveerd op spaarrekening (incl. btw)
</h3>
</div>
<div class="panel-body panel-body-project">
@@ -49,6 +49,12 @@
</tr>
</tbody>
<tfoot>
<tr>
<th class="align-right table-cyanish-header">
<span data-bind="text:dbo.helpers.numberWithPoints(totalReservationamount())"></span>
</th>
<th class="table-cyanish-header" colspan="2"></th>
</tr>
<tr>
<th colspan="4">
<button class="btn btn-primary btn-round btn-sm" data-bind="click:addReservation">
+1 -1
View File
@@ -93,7 +93,7 @@
</div>
<footer class="page-copyright page-copyright-inverse">
<p>© 2018. De Beleidsonderzoeker.</p>
<p>© 2018. De Beleidsonderzoekers</p>
<!-- <p style="font-size:.8em">powered by: Pensare Software</p>-->
</footer>
</div>
@@ -11,7 +11,7 @@
<th width="17%">project</th>
<th width="10%" class="align-right">Kosten derden</th>
<th width="10%" class="align-right">factuur INK</th>
<th width="10%" class="align-right">budget gereserveerd</th>
<th width="10%" class="align-right">gereserveerd op<br/>spaarrekening</th>
<th width="10%" class="align-right">betaald</th>
<th width="10%" class="align-right">saldo te<br />betalen</th>
<th width="10%" class="align-right">betaald via<br />reserveringen</th>
@@ -1,17 +1,23 @@
<table class="table" style="font-size:.8em;">
<thead>
<tr>
<th class="rotate">
<div><span>projectnummer</span></div>
<th class="rotate sorting-field">
<div data-bind="click:setSorting.bind($data, 'projectnumber')">
<span>projectnummer</span>
</div>
</th>
<th class="rotate">
<div><span>instroom</span></div>
</th>
<th class="rotate">
<div><span>naam</span></div>
<th class="rotate sorting-field">
<div data-bind="click:setSorting.bind($data, 'projectname')">
<span>naam</span>
</div>
</th>
<th class="rotate">
<div><span>opdrachtgever</span></div>
<th class="rotate sorting-field">
<div data-bind="click:setSorting.bind($data, 'CUS.name')">
<span>opdrachtgever</span>
</div>
</th>
<!-- ko foreach: uniqueEmployees -->
<th class="rotate">
@@ -43,6 +49,32 @@
<div><span>Volgende boekjaren</span></div>
</th>
</tr>
<tr>
<th class="align-right" colspan="4">totaal</th>
<!-- ko foreach: totalPerEmployee -->
<th class="align-right">
<span data-bind="text:totalRevenue"></span>
</th>
<!-- /ko -->
<th class="align-right">
<span data-bind="text:totalOwnRevenue"></span>
</th>
<th class="align-right">
<span data-bind="text:totalEmployeeRevenues"></span>
</th>
<th class="align-right">
<span data-bind="text:totalAvailableRevenues"></span>
</th>
<th class="align-right">
<span data-bind="text:totalOwp"></span>
</th>
<th class="align-right">
<span data-bind="text:totalCurrentFinancialYear"></span>
</th>
<th class="align-right">
<span data-bind="text:totalNextFinancialYear"></span>
</th>
</tr>
</thead>
<tbody data-bind="foreach:recap">
<tr>
@@ -79,32 +111,6 @@
</tr>
</tbody>
<tfoot>
<tr>
<th class="align-right" colspan="4">totaal</th>
<!-- ko foreach: totalPerEmployee -->
<th class="align-right">
<span data-bind="text:totalRevenue"></span>
</th>
<!-- /ko -->
<th class="align-right">
<span data-bind="text:totalOwnRevenue"></span>
</th>
<th class="align-right">
<span data-bind="text:totalEmployeeRevenues"></span>
</th>
<th class="align-right">
<span data-bind="text:totalAvailableRevenues"></span>
</th>
<th class="align-right">
<span data-bind="text:totalOwp"></span>
</th>
<th class="align-right">
<span data-bind="text:totalCurrentFinancialYear"></span>
</th>
<th class="align-right">
<span data-bind="text:totalNextFinancialYear"></span>
</th>
</tr>
</tfoot>
</table>
@@ -2,7 +2,9 @@
<thead>
<tr>
<th class="rotate">
<div><span>projectnummer</span></div>
<div data-bind="click:setSorting.bind($data, 'projectnumber')">
<span>projectnummer</span>
</div>
</th>
<th class="rotate">
<div><span>instroom</span></div>
@@ -11,10 +13,14 @@
<div><span>uitstroom</span></div>
</th>
<th class="rotate">
<div><span>naam</span></div>
<div data-bind="click:setSorting.bind($data, 'projectname')">
<span>naam</span>
</div>
</th>
<th class="rotate">
<div><span>opdrachtgever</span></div>
<div data-bind="click:setSorting.bind($data, 'CUS.name')">
<span>opdrachtgever</span>
</div>
</th>
<!-- ko foreach: uniqueEmployees -->
<th class="rotate">
@@ -33,6 +39,25 @@
<div><span>totaal beschikbare uren</span></div>
</th>
</tr>
<tr>
<th class="align-right" colspan="5">totaal</th>
<!-- ko foreach: totalPerEmployee -->
<th class="align-right">
<span data-bind="text:totalHours"></span>
</th>
<!-- /ko -->
<th class="align-right">
<span data-bind="text:totalEmployeeHours"></span>
</th>
<!-- ko foreach: totalPerEmployee -->
<th class="align-right">
<span data-bind="text:totalAvailableHours"></span>
</th>
<!-- /ko -->
<th class="align-right">
<span data-bind="text:totalEmployeeAvailableHours"></span>
</th>
</tr>
</thead>
<tbody data-bind="foreach:recap">
<tr>
@@ -60,24 +85,5 @@
</tr>
</tbody>
<tfoot>
<tr>
<th class="align-right" colspan="5">totaal</th>
<!-- ko foreach: totalPerEmployee -->
<th class="align-right">
<span data-bind="text:totalHours"></span>
</th>
<!-- /ko -->
<th class="align-right">
<span data-bind="text:totalEmployeeHours"></span>
</th>
<!-- ko foreach: totalPerEmployee -->
<th class="align-right">
<span data-bind="text:totalAvailableHours"></span>
</th>
<!-- /ko -->
<th class="align-right">
<span data-bind="text:totalEmployeeAvailableHours"></span>
</th>
</tr>
</tfoot>
</table>
</table>
+4
View File
@@ -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;
@@ -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' );
}
}
}
+13 -6
View File
@@ -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' )
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+201 -200
View File
@@ -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" ) );
}
}
}
}
@@ -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" ) );
}
}
}