Merge branch 'master' into feature/dashboard

# Conflicts:
#	application/models/eloquent/Projectemployee.php
This commit is contained in:
2020-01-10 17:43:05 +01:00
35 changed files with 6932 additions and 1991 deletions
@@ -67,6 +67,13 @@ class usersController extends MY_Controller {
$this->json( $projectEmployees ); $this->json( $projectEmployees );
} }
public function getUniqueEmployeesWithActivity($archive)
{
$projectEmployees = Projectemployee::getUniqueEmployeesWithActivity($archive);
$this->json( $projectEmployees );
}
public function saveUser() public function saveUser()
{ {
$userValidation = new UserValidation(); $userValidation = new UserValidation();
@@ -29,7 +29,10 @@ class ReportsController extends MY_Controller {
public function recapProjects( $archive ) 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(); $projects = $recapprojects->getProjects();
@@ -27,6 +27,7 @@ class ReservationsController extends MY_Controller {
{ {
$projects[ $result->projectID ] = [ $projects[ $result->projectID ] = [
'projectnumber' => $result->projectnumber, 'projectnumber' => $result->projectnumber,
'projectname' => $result->projectname,
'costs' => 0, 'costs' => 0,
'reservation' => 0, 'reservation' => 0,
'payed' => 0, 'payed' => 0,
@@ -10,9 +10,11 @@ class Recapprojects {
private $ci; private $ci;
private $index; private $index;
private $field;
private $archive; private $archive;
private $project; private $project;
private $projects; private $projects;
private $direction;
private $employeeHours; private $employeeHours;
private $invoicedYears = []; private $invoicedYears = [];
private $projectTotals; private $projectTotals;
@@ -23,11 +25,13 @@ class Recapprojects {
private $projectEmployeeDetail; private $projectEmployeeDetail;
private $projectEmployeeDetails; private $projectEmployeeDetails;
public function __construct( $archive ) public function __construct( $archive, $field, $direction )
{ {
$this->ci =& get_instance(); $this->ci =& get_instance();
$this->archive = $archive; $this->archive = $archive;
$this->field = $field;
$this->direction = $direction;
$this->ci->load->Model( 'projects/Invoices_model' ); $this->ci->load->Model( 'projects/Invoices_model' );
@@ -54,12 +58,14 @@ class Recapprojects {
private function setProjects() private function setProjects()
{ {
$this->projects = Project::getActiveProjects( $this->archive )->toArray(); $this->projects = Project::getActiveProjects(
$this->archive, $this->field, $this->direction )->toArray();
} }
private function setUniqueEmployees() private function setUniqueEmployees()
{ {
$this->uniqueEmployees = Projectemployee::getUniqueProjectEmployees(); $this->uniqueEmployees =
Projectemployee::getUniqueEmployeesWithActivity();
} }
private function loopProjects() private function loopProjects()
@@ -42,6 +42,8 @@ class InvoiceSpreadsheet {
$this->setMonthPayment(); $this->setMonthPayment();
$this->setInvoiced();
$this->setFilename(); $this->setFilename();
$this->setFullPathname(); $this->setFullPathname();
@@ -96,6 +98,16 @@ class InvoiceSpreadsheet {
new MonthPaymentSheet( $this->invoiceReport['monthPayments'], $this->invoiceSheet ); new MonthPaymentSheet( $this->invoiceReport['monthPayments'], $this->invoiceSheet );
} }
private function setInvoiced()
{
$invoiceSheet = new Worksheet( $this->spreadsheet, 'ontvangen facturen' );
$this->invoiceSheet =
$this->spreadsheet->addSheet( $invoiceSheet );
new InvoicedSheet( $this->invoiceReport['invoiced'], $this->invoiceSheet );
}
private function setFilename() private function setFilename()
{ {
$this->filename = 'facturen' . date( 'YmdHis' ) . '.xlsx'; $this->filename = 'facturen' . date( 'YmdHis' ) . '.xlsx';
@@ -0,0 +1,67 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 30/07/2018
* Time: 10:48
*/
class InvoicedSheet {
const HEADERS = [
'A' => 'factuurnummer',
'B' => 'project',
'C' => 'klant',
'D' => 'factuurdatum',
'E' => 'exc btw',
'F' => 'btw',
'G' => 'incl btw'
];
private $invoiced;
private $sheet;
private $row;
public function __construct( $invoiced, $sheet )
{
$this->invoiced = $invoiced;
$this->sheet = $sheet;
$this->handle();
}
private function handle()
{
$this->setHeader();
$this->setBody();
}
private function setHeader()
{
foreach ( self::HEADERS as $cell => $header )
{
$this->sheet->setCellValue( $cell . '1', $header );
$this->sheet->getColumnDimension( $cell )->setAutoSize( TRUE );
}
}
private function setBody()
{
$this->row = 2;
foreach ( $this->invoiced AS $invoice )
{
$vat = ROUND($invoice->invoiceamount * 0.21, 2);
$this->sheet->setCellValue( 'A' . $this->row, $invoice->invoicenumber );
$this->sheet->setCellValue( 'B' . $this->row, ($invoice->projectnumber . ' ' . $invoice['projectname']));
$this->sheet->setCellValue( 'C' . $this->row, $invoice->name );
$this->sheet->setCellValue( 'D' . $this->row, $invoice->invoicenumber );
$this->sheet->setCellValue( 'E' . $this->row, $invoice->invoiceamount );
$this->sheet->setCellValue( 'F' . $this->row, $vat );
$this->sheet->setCellValue( 'G' . $this->row, $invoice->invoiceamount + $vat );
$this->row ++;
}
}
}
@@ -23,6 +23,8 @@ class Invoices {
private $orderType; private $orderType;
private $orderDirection; private $orderDirection;
private $archive; private $archive;
private $invoicedYears;
private $invoiced;
public function __construct( $year, $orderType, $orderDirection, $archive ) public function __construct( $year, $orderType, $orderDirection, $archive )
{ {
@@ -45,6 +47,13 @@ class Invoices {
$this->loopProjects(); $this->loopProjects();
//only projects with payments also archived projects
$this->setMonthPayments();
$this->setInvoicedyears();
$this->setInvoiced();
$this->setInvoiceReport(); $this->setInvoiceReport();
} }
@@ -63,8 +72,6 @@ class Invoices {
$this->setInvoiceForecasts(); $this->setInvoiceForecasts();
$this->setMonthForecasts(); $this->setMonthForecasts();
$this->setMonthPayments();
} }
} }
@@ -93,10 +100,23 @@ class Invoices {
public function setMonthPayments() public function setMonthPayments()
{ {
$this->monthPayment = $monthPayment = new MonthPayments(
new MonthPayments( $this->project, $this->year ); $this->year, $this->orderType, $this->orderDirection );
$this->monthPayments[] = $this->monthPayment->getProjectDetails(); $this->monthPayments = $monthPayment->getProjectDetails();
}
private function setInvoiced()
{
$this->invoiced = Invoice::getInvoiced( $this->year );
}
private function setInvoicedYears()
{
$this->invoicedYears = Invoice::selectRaw( 'DATE_FORMAT(invoicedate, "%Y") AS years' )
->distinct()
->orderBy( 'invoicedate' )
->lists( 'years' );
} }
private function setInvoiceReport() private function setInvoiceReport()
@@ -105,7 +125,9 @@ class Invoices {
'invoiceOverview' => $this->invoiceOverviews, 'invoiceOverview' => $this->invoiceOverviews,
'forecasts' => $this->invoiceForecasts, 'forecasts' => $this->invoiceForecasts,
'monthForecasts' => $this->monthForecasts, 'monthForecasts' => $this->monthForecasts,
'monthPayments' => $this->monthPayments 'monthPayments' => $this->monthPayments,
'invoicedYears' => $this->invoicedYears,
'invoiced' => $this->invoiced
]; ];
} }
} }
@@ -15,12 +15,16 @@ class MonthPayments {
private $projectname; private $projectname;
private $monthPayments; private $monthPayments;
private $projectDetails; private $projectDetails;
private $projectsWithPayments;
private $totalProjectPayments; private $totalProjectPayments;
private $orderType;
private $orderDirection;
public function __construct( $project, $year ) public function __construct( $year, $orderType, $orderDirection )
{ {
$this->project = $project;
$this->year = $year; $this->year = $year;
$this->orderType = $orderType;
$this->orderDirection = $orderDirection;
$this->handle(); $this->handle();
} }
@@ -31,6 +35,24 @@ class MonthPayments {
} }
private function handle() private function handle()
{
$this->setProjectsWithPayments();
$this->loopProjectsWithPayments();
}
private function setProjectsWithPayments()
{
$projectsArray = Payment::getProjectsWithPayments( $this->year );
$this->projectsWithPayments =
Project::getProjectsForReport(
$this->orderType, $this->orderDirection, FALSE, $projectsArray );
}
private function loopProjectsWithPayments()
{
foreach ( $this->projectsWithPayments as $this->project )
{ {
$this->setProjectname(); $this->setProjectname();
@@ -42,6 +64,7 @@ class MonthPayments {
$this->setProjectDetails(); $this->setProjectDetails();
} }
}
private function setProjectname() private function setProjectname()
{ {
@@ -65,7 +88,7 @@ class MonthPayments {
{ {
foreach ( $this->project->invoices as $invoice ) foreach ( $this->project->invoices as $invoice )
{ {
foreach($invoice->payments as $this->payment) foreach ( $invoice->payments as $this->payment )
{ {
$this->setMonthPayments(); $this->setMonthPayments();
@@ -93,7 +116,7 @@ class MonthPayments {
private function setProjectDetails() private function setProjectDetails()
{ {
$this->projectDetails = [ $this->projectDetails[] = [
'projectname' => $this->projectname, 'projectname' => $this->projectname,
'customer' => $this->customer, 'customer' => $this->customer,
'monthPayments' => $this->monthPayments, 'monthPayments' => $this->monthPayments,
+12
View File
@@ -62,4 +62,16 @@ class Invoice extends BaseModel {
return $invoiceID; return $invoiceID;
} }
public static function getInvoiced( $year )
{
$invoiced = Invoice::selectRaw('invoicenumber, PRJ.projectname, projectnumber, CUS.name, invoicedate, CUS.name, invoiceamount')
->join('projects AS PRJ', 'PRJ.id', '=', 'invoices.project_id')
->join('customers AS CUS', 'CUS.id', '=', 'PRJ.customer_id')
->whereRaw("DATE_FORMAT(invoicedate, '%Y') = {$year}")
->orderBy('invoicedate')
->get();
return $invoiced;
}
} }
+11
View File
@@ -28,6 +28,17 @@ class Payment extends BaseModel {
return $projectPayment->payment; 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 ) public static function savePayment( $paymentID, $payment )
{ {
$payment = (array) $payment; $payment = (array) $payment;
+6 -2
View File
@@ -96,7 +96,7 @@ class Project extends BaseModel {
Project::whereId( $projectID )->delete(); 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, $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" ) projectname, CUS.name, OFF.own_revenue, OFF.other_revenue" )
@@ -106,6 +106,8 @@ class Project extends BaseModel {
->groupBy( 'OFF.own_revenue' ) ->groupBy( 'OFF.own_revenue' )
->groupBy( 'OFF.other_revenue' ); ->groupBy( 'OFF.other_revenue' );
if ( $sortField ) $projects = $projects->orderBy( $sortField, $direction );
if ( $archive == 'F' ) $projects = $projects->where( 'projects.archive', '=', 'F' ); if ( $archive == 'F' ) $projects = $projects->where( 'projects.archive', '=', 'F' );
$projects = $projects->get(); $projects = $projects->get();
@@ -113,12 +115,14 @@ class Project extends BaseModel {
return $projects; return $projects;
} }
public static function getProjectsForReport( $orderType, $orderDirection, $archive = 'F' ) public static function getProjectsForReport( $orderType, $orderDirection, $archive = 'F', $projectsArray = FALSE )
{ {
$projects = self::getBaseProject(); $projects = self::getBaseProject();
if ( $archive == 'F' ) $projects = $projects->whereArchive( 'F' ); if ( $archive == 'F' ) $projects = $projects->whereArchive( 'F' );
if ( is_array( $projectsArray ) ) $projects = $projects->whereIn( 'id', $projectsArray );
$projects = $projects->orderBy( $orderType, $orderDirection )->get(); $projects = $projects->orderBy( $orderType, $orderDirection )->get();
return $projects; return $projects;
@@ -11,7 +11,8 @@ class ReservationTotals {
public static function fire() public static function fire()
{ {
// UNION ALL wordt gebruikt voor een full outer join // UNION ALL wordt gebruikt voor een full outer join
$sql = " SELECT PRJ.id AS projectID, external_id AS externalID, $sql = "SELECT PRJ.id AS projectID, external_id AS externalID,
PRJ.projectname,
COALESCE(fromreservation, 0) AS fromreservation, COALESCE(fromreservation, 0) AS fromreservation,
COALESCE(Q5.costs, 0) AS costs, COALESCE(reservation, 0) AS reservation, COALESCE(Q5.costs, 0) AS costs, COALESCE(reservation, 0) AS reservation,
COALESCE(payed, 0) AS payed, (COALESCE(reservation, 0) - COALESCE(fromreservation, 0)) AS saldo, COALESCE(payed, 0) AS payed, (COALESCE(reservation, 0) - COALESCE(fromreservation, 0)) AS saldo,
@@ -311,7 +311,7 @@
<table class="main" width="100%" cellpadding="0" cellspacing="0"> <table class="main" width="100%" cellpadding="0" cellspacing="0">
<tr> <tr>
<td class="alert alert-warning"> <td class="alert alert-warning">
Nieuw wachtwoord DBOIS De Beleidsonderzoeker Nieuw wachtwoord DBOIS De Beleidsonderzoekers
</td> </td>
</tr> </tr>
<tr> <tr>
+1 -1
View File
@@ -311,7 +311,7 @@
<table class="main" width="100%" cellpadding="0" cellspacing="0"> <table class="main" width="100%" cellpadding="0" cellspacing="0">
<tr> <tr>
<td class="alert alert-warning"> <td class="alert alert-warning">
Wachtwoord De Beleidsonderzoeker Wachtwoord De Beleidsonderzoekers
</td> </td>
</tr> </tr>
<tr> <tr>
+1 -1
View File
@@ -9,7 +9,7 @@
<link rel="icon" href="css/images/dbo-01-80x80.png" type="image/png"> <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' ); ?> <?php $this->load->view( 'partials/_css' ); ?>
@@ -169,11 +169,21 @@
</table> </table>
</td> </td>
</tr> </tr>
<tr>
<th colspan="10" class="table-cyanish-header"></th>
</tr>
</tbody> </tbody>
<tfoot> <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> <tr>
<td colspan="5"> <td colspan="5">
<button class="btn btn-primary btn-round btn-sm" data-bind="click:newInvoice"> <button class="btn btn-primary btn-round btn-sm" data-bind="click:newInvoice">
@@ -110,6 +110,20 @@
</tr> </tr>
</tbody> </tbody>
<tfoot> <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> <tr>
<td colspan="8"> <td colspan="8">
<button class="btn btn-primary btn-round btn-sm" data-bind="click:newProjectcost"> <button class="btn btn-primary btn-round btn-sm" data-bind="click:newProjectcost">
@@ -1,7 +1,7 @@
<div class="panel panel-bordered panel-primary panel-line"> <div class="panel panel-bordered panel-primary panel-line">
<div class="panel-heading panel-heading-project"> <div class="panel-heading panel-heading-project">
<h3 class=""> <h3 class="">
budget gereserveerd (incl. btw) gereserveerd op spaarrekening (incl. btw)
</h3> </h3>
</div> </div>
<div class="panel-body panel-body-project"> <div class="panel-body panel-body-project">
@@ -49,6 +49,12 @@
</tr> </tr>
</tbody> </tbody>
<tfoot> <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> <tr>
<th colspan="4"> <th colspan="4">
<button class="btn btn-primary btn-round btn-sm" data-bind="click:addReservation"> <button class="btn btn-primary btn-round btn-sm" data-bind="click:addReservation">
@@ -51,6 +51,9 @@
<li class="nav-item" data-bind="click:setActivetab.bind($data, 'monthpayments')" style="z-index:10"> <li class="nav-item" data-bind="click:setActivetab.bind($data, 'monthpayments')" style="z-index:10">
<a class="nav-link" data-bind="css:{'active':invoiceTab() == 'monthpayments'}">maand betalingen</a> <a class="nav-link" data-bind="css:{'active':invoiceTab() == 'monthpayments'}">maand betalingen</a>
</li> </li>
<li class="nav-item" data-bind="click:setActivetab.bind($data, 'invoices')" style="z-index:10">
<a class="nav-link" data-bind="css:{'active':invoiceTab() == 'invoices'}">ontvangen facturen</a>
</li>
<!-- <li class="nav-item" data-bind="click:setActivetab.bind($data, 'externals')" style="z-index:10">--> <!-- <li class="nav-item" data-bind="click:setActivetab.bind($data, 'externals')" style="z-index:10">-->
<!-- <a class="nav-link" data-bind="css:{'active':invoiceTab() == 'externals'}">onderaannemers</a>--> <!-- <a class="nav-link" data-bind="css:{'active':invoiceTab() == 'externals'}">onderaannemers</a>-->
<!-- </li>--> <!-- </li>-->
@@ -68,6 +71,9 @@
<div id="invoiceforecast" data-bind="visible:invoiceTab() == 'monthpayments'"> <div id="invoiceforecast" data-bind="visible:invoiceTab() == 'monthpayments'">
<?php $this->load->view('reports/invoices/monthpayment_report'); ?> <?php $this->load->view('reports/invoices/monthpayment_report'); ?>
</div> </div>
<div id="invoiceforecast" data-bind="visible:invoiceTab() == 'invoices'">
<?php $this->load->view('reports/invoices/invoices_report'); ?>
</div>
<!-- <div id="invoiceforecast" data-bind="visible:invoiceTab() == 'externals'">--> <!-- <div id="invoiceforecast" data-bind="visible:invoiceTab() == 'externals'">-->
<!-- --><?php //$this->load->view('reports/invoices/contractors_report'); ?> <!-- --><?php //$this->load->view('reports/invoices/contractors_report'); ?>
<!-- </div>--> <!-- </div>-->
+1 -1
View File
@@ -92,7 +92,7 @@
</div> </div>
<footer class="page-copyright page-copyright-inverse"> <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>--> <!-- <p style="font-size:.8em">powered by: Pensare Software</p>-->
</footer> </footer>
</div> </div>
+10 -10
View File
@@ -7,16 +7,16 @@
<table class="table table-condensed"> <table class="table table-condensed">
<thead> <thead>
<tr> <tr>
<th width="3%">&nbsp;</th> <th width="2%">&nbsp;</th>
<th width="17%">project</th> <th width="34%">project</th>
<th width="10%" class="align-right">Kosten derden</th> <th width="8%" class="align-right">Kosten derden</th>
<th width="10%" class="align-right">factuur INK</th> <th width="8%" class="align-right">factuur INK</th>
<th width="10%" class="align-right">budget gereserveerd</th> <th width="8%" class="align-right">gereserveerd op<br/>spaarrekening</th>
<th width="10%" class="align-right">betaald</th> <th width="8%" class="align-right">betaald</th>
<th width="10%" class="align-right">saldo te<br />betalen</th> <th width="8%" class="align-right">nog te betalen<br />facturen</th>
<th width="10%" class="align-right">betaald via<br />reserveringen</th> <th width="8%" class="align-right">betaald via<br />reserveringen</th>
<th width="10%" class="align-right">saldo reservering</th> <th width="8%" class="align-right">saldo reservering</th>
<th width="10%" class="align-right">saldo facturen INK</th> <th width="8%" class="align-right">saldo facturen INK</th>
</tr> </tr>
</thead> </thead>
<!-- ko foreach:projects --> <!-- ko foreach:projects -->
@@ -0,0 +1,56 @@
<div class="row">
<div class="col-xs-12">
<table class="table table-striped table-condensed">
<thead>
<tr>
<th>
factuurnummer
</th>
<th>
project
</th>
<th>
klant
</th>
<th>
factuur datum
</th>
<th>
excl btw
</th>
<th>
btw
</th>
<th>
incl btw
</th>
</tr>
</thead>
<tbody data-bind="foreach:invoiced">
<tr>
<td>
<span data-bind="text:invoicenumber"></span>
</td>
<td>
<span data-bind="text:project"></span>
</td>
<td>
<span data-bind="text:name"></span>
</td>
<td>
<span data-bind="text:invoicedate"></span>
</td>
<td class="align-right">
<span data-bind="text:invoiceamount"></span>
</td>
<td class="align-right">
<span data-bind="text:vat"></span>
</td>
<td class="align-right">
<span data-bind="text:inclVat"></span>
</td>
</tr>
</tbody>
</table>
</div>
</div>
@@ -1,17 +1,23 @@
<table class="table" style="font-size:.8em;"> <table class="table" style="font-size:.8em;">
<thead> <thead>
<tr> <tr>
<th class="rotate"> <th class="rotate sorting-field">
<div><span>projectnummer</span></div> <div data-bind="click:setSorting.bind($data, 'projectnumber')">
<span>projectnummer</span>
</div>
</th> </th>
<th class="rotate"> <th class="rotate">
<div><span>instroom</span></div> <div><span>instroom</span></div>
</th> </th>
<th class="rotate"> <th class="rotate sorting-field">
<div><span>naam</span></div> <div data-bind="click:setSorting.bind($data, 'projectname')">
<span>naam</span>
</div>
</th> </th>
<th class="rotate"> <th class="rotate sorting-field">
<div><span>opdrachtgever</span></div> <div data-bind="click:setSorting.bind($data, 'CUS.name')">
<span>opdrachtgever</span>
</div>
</th> </th>
<!-- ko foreach: uniqueEmployees --> <!-- ko foreach: uniqueEmployees -->
<th class="rotate"> <th class="rotate">
@@ -43,6 +49,32 @@
<div><span>Volgende boekjaren</span></div> <div><span>Volgende boekjaren</span></div>
</th> </th>
</tr> </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> </thead>
<tbody data-bind="foreach:recap"> <tbody data-bind="foreach:recap">
<tr> <tr>
@@ -79,32 +111,6 @@
</tr> </tr>
</tbody> </tbody>
<tfoot> <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> </tfoot>
</table> </table>
@@ -2,7 +2,9 @@
<thead> <thead>
<tr> <tr>
<th class="rotate"> <th class="rotate">
<div><span>projectnummer</span></div> <div data-bind="click:setSorting.bind($data, 'projectnumber')">
<span>projectnummer</span>
</div>
</th> </th>
<th class="rotate"> <th class="rotate">
<div><span>instroom</span></div> <div><span>instroom</span></div>
@@ -11,10 +13,14 @@
<div><span>uitstroom</span></div> <div><span>uitstroom</span></div>
</th> </th>
<th class="rotate"> <th class="rotate">
<div><span>naam</span></div> <div data-bind="click:setSorting.bind($data, 'projectname')">
<span>naam</span>
</div>
</th> </th>
<th class="rotate"> <th class="rotate">
<div><span>opdrachtgever</span></div> <div data-bind="click:setSorting.bind($data, 'CUS.name')">
<span>opdrachtgever</span>
</div>
</th> </th>
<!-- ko foreach: uniqueEmployees --> <!-- ko foreach: uniqueEmployees -->
<th class="rotate"> <th class="rotate">
@@ -33,6 +39,25 @@
<div><span>totaal beschikbare uren</span></div> <div><span>totaal beschikbare uren</span></div>
</th> </th>
</tr> </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> </thead>
<tbody data-bind="foreach:recap"> <tbody data-bind="foreach:recap">
<tr> <tr>
@@ -60,24 +85,5 @@
</tr> </tr>
</tbody> </tbody>
<tfoot> <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> </tfoot>
</table> </table>
+4
View File
@@ -103,6 +103,10 @@ th.rotate > div > span {
border-right: 1px solid #ccc; border-right: 1px solid #ccc;
border-bottom: 1px solid #ccc; border-bottom: 1px solid #ccc;
} }
th.sorting-field:hover{
cursor: pointer;
color:#222;
}
.pie-test{ .pie-test{
width:20px; width:20px;
height:20px; height:20px;
@@ -15,11 +15,15 @@ dbo.reportsDataService = {
} ); } );
}, },
getRecapProjects: function(archive, callback){ getRecapProjects: function ( field, direction, archive, callback ) {
$.getJSON( 'index.php/reports/reportsController/recapProjects/' + archive ) var submitDATA = {
field : field,
direction: direction
};
$.post( 'index.php/reports/reportsController/recapProjects/' + archive, submitDATA )
.done( function ( data ) { .done( function ( data ) {
callback( data ); callback( data );
} ); }, 'JSON' );
}, },
getEmployeeHours: function ( employeeID, year, callback ) { getEmployeeHours: function ( employeeID, year, callback ) {
@@ -29,8 +33,8 @@ dbo.reportsDataService = {
} ); } );
}, },
saveCurrentFinnacialYear: function(projectID, amount, callback){ saveCurrentFinnacialYear: function ( projectID, amount, callback ) {
$.post( 'index.php/reports/reportsController/saveCurrentFinnacialYear/' + projectID, {amount:amount} ) $.post( 'index.php/reports/reportsController/saveCurrentFinnacialYear/' + projectID, {amount: amount} )
.done( function ( data ) { .done( function ( data ) {
callback( data ); callback( data );
}, 'json' ); }, 'json' );
@@ -49,6 +49,13 @@ dbo.userDataService = {
} ); } );
}, },
getUniqueEmployeesWithActivity: function ( archive, callback ) {
$.post( 'index.php/beheer/usersController/getUniqueEmployeesWithActivity/' + archive, 'json' )
.done( function ( data ) {
callback( data );
} );
},
checkUsername: function ( username, callback ) { checkUsername: function ( username, callback ) {
$.post( 'index.php/beheer/userController/checkUsername', 'json' ) $.post( 'index.php/beheer/userController/checkUsername', 'json' )
.done( function ( data ) { .done( function ( data ) {
+34 -4
View File
@@ -51,7 +51,7 @@ $( function () {
totalInvoiced : ko.observable(), totalInvoiced : ko.observable(),
totalRevenuesIncl : ko.observable(), totalRevenuesIncl : ko.observable(),
outstanding : ko.observable(), outstanding : ko.observable(),
outstandingInvoices: ko.observable(), outstandingInvoices : ko.observable(),
payed : ko.observable(), payed : ko.observable(),
totalForecast : ko.observable(), totalForecast : ko.observable(),
toForecast : ko.observable(), toForecast : ko.observable(),
@@ -60,6 +60,14 @@ $( function () {
totalNonDeclarable : ko.observable( 0 ), totalNonDeclarable : ko.observable( 0 ),
totalDeclarable : ko.observable( 0 ), totalDeclarable : ko.observable( 0 ),
totalRevenueHours : 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 () { init: function () {
var vm = dbo.editProjectModal; var vm = dbo.editProjectModal;
@@ -831,6 +839,14 @@ $( function () {
vm.payed( dbo.helpers.numberWithPoints( 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.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.projectEmployees.removeAll();
vm.projecthours.removeAll(); vm.projecthours.removeAll();
@@ -907,8 +923,8 @@ $( function () {
vm.totalForecast( vm.totalForecast() + Number( p.forecastamount() ) ); vm.totalForecast( vm.totalForecast() + Number( p.forecastamount() ) );
vm.toForecast( vm.toForecast() - Number( p.forecastamount() ) ); vm.toForecast( vm.toForecast() - Number( p.forecastamount() ) );
} ); } );
vm.toForecast( dbo.helpers.numberWithPoints( Number( vm.toForecast() ) ) ); vm.toForecast( dbo.helpers.numberWithPoints( Math.round( Number( vm.toForecast() ) ) ) );
vm.totalForecast( dbo.helpers.numberWithPoints( Number( vm.totalForecast() ) ) ); vm.totalForecast( dbo.helpers.numberWithPoints( Math.round( Number( vm.totalForecast() ) ) ) );
}, },
Projectemployee: function ( data ) { Projectemployee: function ( data ) {
@@ -951,6 +967,7 @@ $( function () {
Projectcost: function ( data ) { Projectcost: function ( data ) {
var self = this; var self = this;
var vm = dbo.editProjectModal;
self.id = data.id; self.id = data.id;
self.external_id = ko.observable( data.external_id ); self.external_id = ko.observable( data.external_id );
@@ -962,12 +979,17 @@ $( function () {
self.inEdit = ko.observable( data.inEdit || false ); self.inEdit = ko.observable( data.inEdit || false );
self.fromReservation = ko.observable( data.from_reservation == 'T' ? true : false ); self.fromReservation = ko.observable( data.from_reservation == 'T' ? true : false );
this.toPay = ko.pureComputed( function () {
self.toPay = ko.pureComputed( function () {
if ( isNaN( self.costs() ) ) return 0; if ( isNaN( self.costs() ) ) return 0;
if ( isNaN( self.payed() ) ) return 0; if ( isNaN( self.payed() ) ) return 0;
return self.costs() - self.payed(); return self.costs() - self.payed();
} ) } )
vm.totalCosts( Number( vm.totalCosts() ) + Number( self.costs() ) );
vm.totalPayed( Number( vm.totalPayed() ) + Number( self.payed() ) );
vm.totalToPay( Number( vm.totalToPay() ) + Number( self.toPay() ) );
}, },
Invoice: function ( data ) { Invoice: function ( data ) {
@@ -1009,6 +1031,10 @@ $( function () {
} ); } );
return (self.inclBtw() - payed).toFixed( 0 ); return (self.inclBtw() - payed).toFixed( 0 );
} ); } );
vm.totalInvoiceamount( Number( vm.totalInvoiceamount() + Number( self.invoiceamount() ) ) );
vm.totalInclBtw( Number( vm.totalInclBtw() + Number( self.inclBtw() ) ) );
vm.totalOutstanding( Number( vm.totalOutstanding() + Number( self.outstanding() ) ) );
}, },
Payment: function ( data ) { Payment: function ( data ) {
@@ -1032,12 +1058,16 @@ $( function () {
}, },
Reservation: function ( data ) { Reservation: function ( data ) {
var vm = dbo.editProjectModal;
this.id = data.id; this.id = data.id;
this.project_id = data.project_id; this.project_id = data.project_id;
this.reservationamount = ko.observable( data.reservationamount ); this.reservationamount = ko.observable( data.reservationamount );
this.external_id = ko.observable( data.external_id ); this.external_id = ko.observable( data.external_id );
this.inEdit = ko.observable( data.inEdit || false ); this.inEdit = ko.observable( data.inEdit || false );
this.invalidReservation = ko.observable( data.invalidReservation || false ); this.invalidReservation = ko.observable( data.invalidReservation || false );
vm.totalReservationamount(
Number( vm.totalReservationamount() ) + Number( this.reservationamount() ) )
}, },
addDocument: function ( data, evt ) { addDocument: function ( data, evt ) {
File diff suppressed because it is too large Load Diff
@@ -181,12 +181,15 @@ dbo.employeehoursInit = function () {
var employeeID = vm.selectedEmployeeID() || 0; var employeeID = vm.selectedEmployeeID() || 0;
vm.employeehours.removeAll(); vm.employeehours.removeAll();
setTimeout(function(){
dbo.employeehoursDataService.getEmployeehours( dbo.employeehoursDataService.getEmployeehours(
vm.selectedMonth(), vm.selectedYear(), employeeID, function ( data ) { vm.selectedMonth(), vm.selectedYear(), employeeID, function ( data ) {
$.each( data, function ( i, p ) { $.each( data, function ( i, p ) {
vm.employeehours.push( new vm.Employeehour( p ) ); vm.employeehours.push( new vm.Employeehour( p ) );
} ); } );
} ); } );
}, 1000);
}, },
validateNumber: function ( field ) { validateNumber: function ( field ) {
@@ -249,8 +252,6 @@ dbo.employeehoursInit = function () {
self.hours( 0 ); self.hours( 0 );
} }
} }
return true; return true;
} ); } );
} }
+177 -158
View File
@@ -5,24 +5,24 @@
* Time: 11:43 * Time: 11:43
*/ */
dbo.invoicereportInit = function () { dbo.invoicereportInit = function () {
if ( dbo.invoicereport !== undefined ) { if (dbo.invoicereport !== undefined) {
dbo.invoicereport.initModule(); dbo.invoicereport.initModule()
} else { } else {
dbo.invoicereport = { dbo.invoicereport = {
years : ko.observableArray([]),
selectedYear : ko.observable(), selectedYear : ko.observable(),
invoiceOverview : ko.observableArray( [] ), invoiceOverview : ko.observableArray([]),
forecasts : ko.observableArray( [] ), forecasts : ko.observableArray([]),
monthForecasts : ko.observableArray( [] ), monthForecasts : ko.observableArray([]),
monthPayments : ko.observableArray( [] ), monthPayments : ko.observableArray([]),
months : ko.observableArray( [] ), months : ko.observableArray([]),
monthTotals : ko.observableArray( [] ), monthTotals : ko.observableArray([]),
monthPaymentTotals : ko.observableArray( [] ), monthPaymentTotals : ko.observableArray([]),
validYear : ko.observable(), validYear : ko.observable(),
invoiceTab : ko.observable(), invoiceTab : ko.observable(),
totalToInvoicingExcl : ko.observable(), totalToInvoicingExcl : ko.observable(),
@@ -39,220 +39,239 @@ dbo.invoicereportInit = function () {
totalProjectPayments : ko.observable(), totalProjectPayments : ko.observable(),
orderType : 'projectnumber', orderType : 'projectnumber',
orderDirection : false, orderDirection : false,
archive : ko.observable( false ), archive : ko.observable(false),
recievedInvoices : ko.observableArray([]),
invoiced : ko.observableArray([]),
init: function () { init: function () {
var vm = dbo.invoicereport; var vm = dbo.invoicereport
vm.selectedYear( (new Date()).getFullYear() ); vm.selectedYear((new Date()).getFullYear())
vm.invoiceTab( 'invoice' ); vm.invoiceTab('invoice')
vm.validYear( true ); vm.validYear(true)
vm.months( dbo.monthArray ); vm.months(dbo.monthArray)
vm.initModule(); vm.initModule()
}, },
initModule: function () { initModule: function () {
var vm = dbo.invoicereport; var vm = dbo.invoicereport
vm.resetTotals(); vm.resetTotals()
var orderDirection = vm.orderDirection ? 'ASC' : 'DESC'; var orderDirection = vm.orderDirection ? 'ASC' : 'DESC'
var archive = vm.archive() ? 'T' : 'F'; var archive = vm.archive() ? 'T' : 'F'
dbo.invoiceDataService.getInvoiceOverview( vm.selectedYear(), vm.orderType, orderDirection, archive, function ( data ) { dbo.invoiceDataService.getInvoiceOverview(vm.selectedYear(), vm.orderType, orderDirection, archive, function (data) {
vm.invoiceOverview( data.invoiceOverview ); vm.invoiceOverview(data.invoiceOverview)
vm.setInvoiceOverviewTotals( data.invoiceOverview ); vm.setInvoiceOverviewTotals(data.invoiceOverview)
vm.forecasts( data.forecasts ); vm.forecasts(data.forecasts)
vm.setForecastsTotals( data.forecasts ); vm.setForecastsTotals(data.forecasts)
vm.monthForecasts.removeAll(); vm.monthForecasts.removeAll()
_.each( data.monthForecasts, function ( p ) { _.each(data.monthForecasts, function (p) {
vm.monthForecasts.push( new vm.Monthforecast( p ) ); vm.monthForecasts.push(new vm.Monthforecast(p))
} ); })
_.each( vm.monthTotals(), function ( p ) { _.each(vm.monthTotals(), function (p) {
p.forecastamount( dbo.helpers.thousandSeparator( p.forecastamount() ) ); p.forecastamount(dbo.helpers.thousandSeparator(p.forecastamount()))
} ); })
vm.monthPayments.removeAll(); vm.monthPayments.removeAll()
_.each( data.monthPayments, function ( p ) { _.each(data.monthPayments, function (p) {
vm.monthPayments.push( new vm.Monthpayment( p ) ); vm.monthPayments.push(new vm.Monthpayment(p))
vm.totalProjectPayments( Number( vm.totalProjectPayments() ) + Number( p.totalProjectPayments.replace( '.', '' ) ) ); vm.totalProjectPayments(Number(vm.totalProjectPayments()) + Number(p.totalProjectPayments.replace('.', '')))
console.log( vm.totalProjectPayments() ); })
} ); vm.totalProjectPayments(dbo.helpers.thousandSeparator(vm.totalProjectPayments()))
vm.totalProjectPayments( dbo.helpers.thousandSeparator( vm.totalProjectPayments() ) ); _.each(vm.monthPaymentTotals(), function (p) {
_.each( vm.monthPaymentTotals(), function ( p ) { p.paymentamount(dbo.helpers.thousandSeparator(p.paymentamount()))
p.paymentamount( dbo.helpers.thousandSeparator( p.paymentamount() ) ); })
} );
} ); vm.years(data.invoicedYears);
vm.invoiced.removeAll()
_.each(data.invoiced, function(p){
vm.invoiced.push( new vm.Invoice(p));
});
})
}, },
toggleArchive: function () { toggleArchive: function () {
var vm = dbo.invoicereport; var vm = dbo.invoicereport
vm.archive( !vm.archive() ); vm.archive(!vm.archive())
vm.initModule(); vm.initModule()
}, },
sortList: function ( orderType ) { sortList: function (orderType) {
var vm = dbo.invoicereport; var vm = dbo.invoicereport
vm.orderType = orderType; vm.orderType = orderType
vm.orderDirection = !vm.orderDirection; vm.orderDirection = !vm.orderDirection
vm.initModule(); vm.initModule()
}, },
resetTotals: function () { resetTotals: function () {
var vm = dbo.invoicereport; var vm = dbo.invoicereport
vm.totalToInvoicingExcl( 0 ); vm.totalToInvoicingExcl(0)
vm.totalToInvoicingIncl( 0 ); vm.totalToInvoicingIncl(0)
vm.totalInvoicedOtherYears( 0 ); vm.totalInvoicedOtherYears(0)
vm.totalInvoicedThisYear( 0 ); vm.totalInvoicedThisYear(0)
vm.invoicesTotal( 0 ); vm.invoicesTotal(0)
vm.totalPayment( 0 ); vm.totalPayment(0)
vm.totalToPay( 0 ); vm.totalToPay(0)
vm.needInvoice( 0 ); vm.needInvoice(Number(0))
vm.forecastThisYear( 0 ); vm.forecastThisYear(0)
vm.forecastOtherYears( 0 ); vm.forecastOtherYears(0)
vm.forecastRemaining( 0 ); vm.forecastRemaining(0)
vm.totalProjectPayments( 0 ); vm.totalProjectPayments(0)
vm.monthTotals.removeAll(); vm.monthTotals.removeAll()
vm.monthPaymentTotals.removeAll(); vm.monthPaymentTotals.removeAll()
for ( var i = 1; i <= 12; i++ ) { for (var i = 1; i <= 12; i++) {
vm.monthTotals.push( {monthID: i, forecastamount: ko.observable( 0 )} ); vm.monthTotals.push({ monthID: i, forecastamount: ko.observable(0) })
vm.monthPaymentTotals.push( {monthID: i, paymentamount: ko.observable( 0 )} ); vm.monthPaymentTotals.push({ monthID: i, paymentamount: ko.observable(0) })
} }
}, },
setInvoiceOverviewTotals: function ( data ) { setInvoiceOverviewTotals: function (data) {
var vm = dbo.invoicereport; var vm = dbo.invoicereport
_.each( data, function ( p ) { _.each(data, function (p) {
vm.totalToInvoicingExcl( vm.totalToInvoicingExcl() + Number( p.totalToInvoicingExcl.replace( '.', '' ) ) ); vm.totalToInvoicingExcl(vm.totalToInvoicingExcl() + Number(p.totalToInvoicingExcl.replace('.', '')))
vm.totalToInvoicingIncl( vm.totalToInvoicingIncl() + Number( p.totalToInvoicingIncl.replace( '.', '' ) ) ); vm.totalToInvoicingIncl(vm.totalToInvoicingIncl() + Number(p.totalToInvoicingIncl.replace('.', '')))
vm.totalInvoicedOtherYears( vm.totalInvoicedOtherYears() + Number( p.totalInvoicedOtherYears.replace( '.', '' ) ) ); vm.totalInvoicedOtherYears(vm.totalInvoicedOtherYears() + Number(p.totalInvoicedOtherYears.replace('.', '')))
vm.totalInvoicedThisYear( vm.totalInvoicedThisYear() + Number( p.totalInvoicedThisYear.replace( '.', '' ) ) ); vm.totalInvoicedThisYear(vm.totalInvoicedThisYear() + Number(p.totalInvoicedThisYear.replace('.', '')))
vm.invoicesTotal( vm.invoicesTotal() + Number( p.invoicesTotal.replace( '.', '' ) ) ); vm.invoicesTotal(vm.invoicesTotal() + Number(p.invoicesTotal.replace('.', '')))
vm.totalPayment( vm.totalPayment() + Number( p.projectPayment.replace( '.', '' ) ) ); vm.totalPayment(vm.totalPayment() + Number(p.projectPayment.replace('.', '')))
vm.totalToPay( vm.totalToPay() + Number( p.invoiceToPay.replace( '.', '' ) ) ); vm.totalToPay(vm.totalToPay() + Number(p.invoiceToPay.replace('.', '')))
vm.needInvoice( vm.needInvoice() + Number( p.needInvoice.replace( '.', '' ) ) ); vm.needInvoice(Number(vm.needInvoice()) + Number(p.needInvoice.replace('.', '')))
} ); })
vm.totalToInvoicingExcl( dbo.helpers.thousandSeparator( vm.totalToInvoicingExcl() ) ); vm.totalToInvoicingExcl(dbo.helpers.thousandSeparator(vm.totalToInvoicingExcl()))
vm.totalToInvoicingIncl( dbo.helpers.thousandSeparator( vm.totalToInvoicingIncl() ) ); vm.totalToInvoicingIncl(dbo.helpers.thousandSeparator(vm.totalToInvoicingIncl()))
vm.totalInvoicedOtherYears( dbo.helpers.thousandSeparator( vm.totalInvoicedOtherYears() ) ); vm.totalInvoicedOtherYears(dbo.helpers.thousandSeparator(vm.totalInvoicedOtherYears()))
vm.totalInvoicedThisYear( dbo.helpers.thousandSeparator( vm.totalInvoicedThisYear() ) ); vm.totalInvoicedThisYear(dbo.helpers.thousandSeparator(vm.totalInvoicedThisYear()))
vm.invoicesTotal( dbo.helpers.thousandSeparator( vm.invoicesTotal() ) ); vm.invoicesTotal(dbo.helpers.thousandSeparator(vm.invoicesTotal()))
vm.totalPayment( dbo.helpers.thousandSeparator( vm.totalPayment() ) ); vm.totalPayment(dbo.helpers.thousandSeparator(vm.totalPayment()))
vm.totalToPay( dbo.helpers.thousandSeparator( vm.totalToPay() ) ); vm.totalToPay(dbo.helpers.thousandSeparator(vm.totalToPay()))
vm.needInvoice( dbo.helpers.thousandSeparator( vm.needInvoice() ) ); vm.needInvoice(dbo.helpers.thousandSeparator(vm.needInvoice()))
}, },
setForecastsTotals: function ( data ) { setForecastsTotals: function (data) {
var vm = dbo.invoicereport; var vm = dbo.invoicereport
_.each( data, function ( p ) { _.each(data, function (p) {
vm.forecastThisYear( vm.forecastThisYear() + Number( p.forecastThisYear.replace( '.', '' ) ) ); vm.forecastThisYear(vm.forecastThisYear() + Number(p.forecastThisYear.replace('.', '')))
vm.forecastOtherYears( vm.forecastOtherYears() + Number( p.forecastOtherYears.replace( '.', '' ) ) ); vm.forecastOtherYears(vm.forecastOtherYears() + Number(p.forecastOtherYears.replace('.', '')))
vm.forecastRemaining( vm.forecastRemaining() + Number( p.forecastRemaining.replace( '.', '' ) ) ); vm.forecastRemaining(vm.forecastRemaining() + Number(p.forecastRemaining.replace('.', '')))
} ); })
vm.forecastThisYear( dbo.helpers.thousandSeparator( vm.forecastThisYear() ) ); vm.forecastThisYear(dbo.helpers.thousandSeparator(vm.forecastThisYear()))
vm.forecastOtherYears( dbo.helpers.thousandSeparator( vm.forecastOtherYears() ) ); vm.forecastOtherYears(dbo.helpers.thousandSeparator(vm.forecastOtherYears()))
vm.forecastRemaining( dbo.helpers.thousandSeparator( vm.forecastRemaining() ) ); vm.forecastRemaining(dbo.helpers.thousandSeparator(vm.forecastRemaining()))
}, },
setForecastMonthsTotals: function ( data ) { setForecastMonthsTotals: function (data) {
var vm = dbo.invoicereport; console.log(data)
var vm = dbo.invoicereport
_.each( data, function ( p ) { _.each(data, function (p) {
_.each( p.forecastMonths(), function ( q ) { _.each(p.forecastMonths(), function (q) {
vm.forecastMonths( vm.forecastMonths() + q ); vm.forecastMonths(vm.forecastMonths() + q)
} ); })
} ); })
}, },
checkYear: function () { checkYear: function () {
var vm = dbo.invoicereport; var vm = dbo.invoicereport
if ( !Number.isInteger( Number( vm.selectedYear() ) ) ) return vm.validYear( false ); if (!Number.isInteger(Number(vm.selectedYear()))) return vm.validYear(false)
if ( Number( vm.selectedYear() ) > 2100 ) return vm.validYear( false ); if (Number(vm.selectedYear()) > 2100) return vm.validYear(false)
if ( Number( vm.selectedYear() ) < 2000 ) return vm.validYear( false ); if (Number(vm.selectedYear()) < 2000) return vm.validYear(false)
vm.validYear( true ); vm.validYear(true)
vm.initModule(); vm.initModule()
}, },
setActivetab: function ( page ) { setActivetab: function (page) {
var vm = dbo.invoicereport; var vm = dbo.invoicereport
vm.invoiceTab( page ); vm.invoiceTab(page)
}, },
Monthforecast: function ( data ) { Monthforecast: function (data) {
var vm = dbo.invoicereport; var vm = dbo.invoicereport
var self = this; var self = this
self.projectnumber = data.projectnumber; self.projectnumber = data.projectnumber
self.projectname = data.projectname; self.projectname = data.projectname
self.customer = data.customer; self.customer = data.customer
self.needInvoice = data.needInvoice; self.needInvoice = data.needInvoice
self.forecastOtherYears = data.forecastOtherYears; self.forecastOtherYears = data.forecastOtherYears
self.forecastRemaining = data.forecastRemaining; self.forecastRemaining = data.forecastRemaining
self.forecastMonths = ko.observableArray( [] ); self.forecastMonths = ko.observableArray([])
_.each( data.forecastMonths, function ( p, i ) { _.each(data.forecastMonths, function (p, i) {
self.forecastMonths.push( new vm.ForecastMonth( p ) ); self.forecastMonths.push(new vm.ForecastMonth(p))
_.each( vm.monthTotals(), function ( q ) { _.each(vm.monthTotals(), function (q) {
if ( q.monthID == i ) q.forecastamount( Number( q.forecastamount() ) + Number( p.forecastamount ) ); if (q.monthID == (i + 1)) q.forecastamount(Math.round(Number(q.forecastamount())) + Math.round(Number(p.forecastamount)))
} ); })
} ); })
}, },
ForecastMonth: function ( data ) { ForecastMonth: function (data) {
this.forecastamount = dbo.helpers.thousandSeparator( data.forecastamount ); this.forecastamount = dbo.helpers.thousandSeparator(Math.round(data.forecastamount))
}, },
Monthpayment: function ( data ) { Monthpayment: function (data) {
var vm = dbo.invoicereport; var vm = dbo.invoicereport
var self = this; var self = this
self.projectname = data.projectname; self.projectname = data.projectname
self.customer = data.customer; self.customer = data.customer
self.totalProjectPayments = data.totalProjectPayments; self.totalProjectPayments = data.totalProjectPayments
self.paymentMonths = ko.observableArray( [] ); self.paymentMonths = ko.observableArray([])
_.each( data.monthPayments, function ( p, i ) { _.each(data.monthPayments, function (p, i) {
self.paymentMonths.push( new vm.PaymentMonth( p ) ); self.paymentMonths.push(new vm.PaymentMonth(p))
_.each( vm.monthPaymentTotals(), function ( q ) { _.each(vm.monthPaymentTotals(), function (q) {
if ( q.monthID == i ) q.paymentamount( Number( q.paymentamount() ) + Number( p.paymentamount ) ); if (q.monthID == i) q.paymentamount(Math.round(Number(q.paymentamount())) + Math.round(Number(p.paymentamount)))
} ); })
} ); })
}, },
PaymentMonth: function ( data ) { PaymentMonth: function (data) {
this.paymentamount = dbo.helpers.thousandSeparator( data.paymentamount ); this.paymentamount = dbo.helpers.thousandSeparator(Math.round(data.paymentamount))
},
Invoice : function(data){
var vat = Math.round((data.invoiceamount * 21) / 100);
var inclVat = vat + Number(data.invoiceamount);
this.invoiceamount = dbo.helpers.thousandSeparator(data.invoiceamount)
this.vat = dbo.helpers.thousandSeparator(vat)
this.inclVat = dbo.helpers.thousandSeparator(inclVat)
this.project = data.projectnumber + ' ' + data.projectname
this.invoicedate = data.invoicedate
this.name = data.name
this.invoicenumber = ko.observable(data.invoicenumber)
}, },
createSpreadsheet: function () { createSpreadsheet: function () {
var vm = dbo.invoicereport; var vm = dbo.invoicereport
var orderDirection = vm.orderDirection ? 'ASC' : 'DESC'; var orderDirection = vm.orderDirection ? 'ASC' : 'DESC'
var archive = vm.archive() ? 'T' : 'F'; var archive = vm.archive() ? 'T' : 'F'
var url = 'index.php/reports/reportsController/createInvoicesSpreadsheet/' + vm.selectedYear() + '/' + vm.orderType + '/' + orderDirection + '/' + archive; var url = 'index.php/reports/reportsController/createInvoicesSpreadsheet/' + vm.selectedYear() + '/' + vm.orderType + '/' + orderDirection + '/' + archive
window.open( url, '_blank' ); window.open(url, '_blank')
} }
} }
dbo.invoicereport.init(); dbo.invoicereport.init()
ko.applyBindings( ko.applyBindings(
dbo.invoicereport, document.getElementById( "INVOICEREPORT" ) ); dbo.invoicereport, document.getElementById('INVOICEREPORT'))
} }
} }
@@ -40,6 +40,8 @@ dbo.monthlyemployeehoursInit = function () {
totalInvoicedYear : ko.observableArray( [] ), totalInvoicedYear : ko.observableArray( [] ),
validYear : ko.observable( true ), validYear : ko.observable( true ),
archive : ko.observable(), archive : ko.observable(),
field : 'projectnumber',
direction : 'asc',
init: function () { init: function () {
var vm = dbo.monthlyEmployeeHoursModel; var vm = dbo.monthlyEmployeeHoursModel;
@@ -54,6 +56,8 @@ dbo.monthlyemployeehoursInit = function () {
initModule: function () { initModule: function () {
var vm = dbo.monthlyEmployeeHoursModel; var vm = dbo.monthlyEmployeeHoursModel;
var archive = vm.archive() ? 'T' : 'F';
vm.totalBudget( 0 ); vm.totalBudget( 0 );
vm.totalOwnRevenue( 0 ); vm.totalOwnRevenue( 0 );
vm.totalCosts( 0 ); vm.totalCosts( 0 );
@@ -67,15 +71,14 @@ dbo.monthlyemployeehoursInit = function () {
vm.totalOwp( 0 ); vm.totalOwp( 0 );
vm.totalPerEmployee.removeAll(); vm.totalPerEmployee.removeAll();
vm.totalInvoicedYear.removeAll(); vm.totalInvoicedYear.removeAll();
dbo.userDataService.getUniqueProjectEmployees( function ( data ) { dbo.userDataService.getUniqueEmployeesWithActivity( archive, function ( data ) {
vm.uniqueEmployees.removeAll(); vm.uniqueEmployees.removeAll();
$.each( data, function ( i, p ) { $.each( data, function ( i, p ) {
vm.uniqueEmployees.push( new vm.UniqueEmployee( p ) ) vm.uniqueEmployees.push( new vm.UniqueEmployee( p ) )
} ); } );
} ); } );
var archive = vm.archive() ? 'T' : 'F'; dbo.reportsDataService.getRecapProjects( vm.field, vm.direction, archive, function ( data ) {
dbo.reportsDataService.getRecapProjects( archive, function ( data ) {
vm.recap.removeAll(); vm.recap.removeAll();
vm.uniqueYears.removeAll(); vm.uniqueYears.removeAll();
$.each( data, function ( i, p ) { $.each( data, function ( i, p ) {
@@ -124,6 +127,19 @@ dbo.monthlyemployeehoursInit = function () {
} ); } );
}, },
setSorting: function ( field ) {
var vm = dbo.monthlyEmployeeHoursModel;
if ( vm.field == field ) {
vm.direction = vm.direction == 'desc' ? 'asc' : 'desc';
} else {
vm.direction = 'asc';
}
vm.field = field;
vm.initModule();
},
toggleArchive: function () { toggleArchive: function () {
var vm = dbo.monthlyEmployeeHoursModel; var vm = dbo.monthlyEmployeeHoursModel;
@@ -68,7 +68,7 @@ dbo.reservationsInit = function () {
var vm = dbo.reservationsModel; var vm = dbo.reservationsModel;
var self = this; var self = this;
self.projectnumber = data.projectnumber; self.projectnumber = data.projectnumber + ' ' + data.projectname;
self.costs = dbo.helpers.numberWithPoints( data.costs ); self.costs = dbo.helpers.numberWithPoints( data.costs );
self.reservation = dbo.helpers.numberWithPoints( data.reservation ); self.reservation = dbo.helpers.numberWithPoints( data.reservation );
self.payed = dbo.helpers.numberWithPoints( data.payed ); self.payed = dbo.helpers.numberWithPoints( data.payed );