Invoice report

This commit is contained in:
2018-03-07 17:03:45 +01:00
parent f540bab261
commit ad478b02b1
25 changed files with 1006 additions and 125 deletions
@@ -212,6 +212,42 @@ class ProjectsController extends MY_Controller {
$this->json( ['success' => TRUE, 'projecthourID' => $paymentID] );
}
public function saveForecast()
{
$forecastValidation = new ForecastValidation();
if ( ! $forecastValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $forecastValidation->getErrorMessages()] );
$forecast = $this->input->post();
$forecastID = $forecast['id'];
unset( $forecast['id'] );
$forecastID = Forecast::saveForecast( $forecastID, $forecast );
$this->json( ['success' => TRUE, 'forecastID' => $forecastID] );
}
public function saveReservation()
{
$reservationValidation = new ReservationValidation();
if ( ! $reservationValidation->getValidationResult() )
return $this->json( [
'success' => FALSE, 'messages' => $reservationValidation->getErrorMessages()] );
$reservation = $this->input->post();
$reservationID = $reservation['id'];
unset( $reservation['id'] );
$reservationID = Reservation::saveReservation( $reservationID, $reservation );
$this->json( ['success' => TRUE, 'reservationID' => $reservationID] );
}
public function archiveProject( $projectID, $status )
{
Project::whereId( $projectID )->update( ['archive' => $status] );
@@ -261,4 +297,26 @@ class ProjectsController extends MY_Controller {
$this->json( ['result' => TRUE] );
}
public function removeForecast( $forecastID )
{
$removeForecast = new RemoveForecast( $forecastID );
if ( $removeForecast->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] );
Forecast::removeForecast( $forecastID );
$this->json( ['result' => TRUE] );
}
public function removeReservation( $reservationID )
{
$removeReservation = new RemoveReservation( $reservationID );
if ( $removeReservation->getAllowDelete() === FALSE ) return $this->json( ['result' => FALSE] );
Forecast::removeReservation( $reservationID );
$this->json( ['result' => TRUE] );
}
}
@@ -62,6 +62,17 @@ class EmployeeHoursController extends MY_Controller {
$result = $query->result();
foreach ( $result as $project )
{
$sql = QinvoiceMonthOverview::fire( $project->id, $year );
$query = $this->db->query( $sql );
$months = $query->result();
$project->months = $months;
}
$this->json( $result );
}
@@ -0,0 +1,36 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 27/12/2017
* Time: 17:45
*/
class RemoveForecast {
private $forecastID;
private $allowDelete = TRUE;
public function __construct( $forecastID )
{
$this->setForecastID( $forecastID );
$this->handle();
}
public function getAllowDelete()
{
return $this->allowDelete;
}
private function setForecastID( $forecastID )
{
$this->forecastID = $forecastID;
}
private function handle()
{
}
}
@@ -0,0 +1,36 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 27/12/2017
* Time: 17:45
*/
class RemoveReservation {
private $reservationID;
private $allowDelete = TRUE;
public function __construct( $reservationID )
{
$this->setReservationID( $reservationID );
$this->handle();
}
public function getAllowDelete()
{
return $this->allowDelete;
}
private function setReservationID( $reservationID )
{
$this->reservationID = $reservationID;
}
private function handle()
{
}
}
@@ -0,0 +1,40 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 10/07/16
* Time: 13:35
*/
require_once( APPPATH . 'libraries/validation/inputValidations/BaseValidation.php' );
class ForecastValidation extends BaseValidation {
protected $validationFields = [
'project_id' => [
'validations' => 'required|integer',
'fieldname' => 'project'
],
'year' => [
'validations' => 'integer',
'fieldname' => 'jaar'
],
'month_id' => [
'validations' => 'integer',
'fieldname' => 'maand'
],
'forecastamount' => [
'validations' => 'number',
'fieldname' => 'bedrag'
]
];
public function __construct()
{
parent::__construct();
$this->ci =& get_instance();
}
}
@@ -0,0 +1,32 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 10/07/16
* Time: 13:35
*/
require_once( APPPATH . 'libraries/validation/inputValidations/BaseValidation.php' );
class ReservationValidation extends BaseValidation {
protected $validationFields = [
'project_id' => [
'validations' => 'required|integer',
'fieldname' => 'project'
],
'reservationamount' => [
'validations' => 'number',
'fieldname' => 'bedrag'
]
];
public function __construct()
{
parent::__construct();
$this->ci =& get_instance();
}
}
+38
View File
@@ -0,0 +1,38 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 07/03/2018
* Time: 09:24
*/
class Forecast extends BaseModel {
public function project()
{
return $this->belongsTo( 'Project' );
}
public static function saveForecast( $forecastID, $forecast )
{
$forecast = (array) $forecast;
if ( $forecastID == 0 )
{
$forecast = self::create( $forecast );
$forecastID = $forecast['id'];
}
else
{
self::whereId( $forecastID )->update( $forecast );
}
return $forecastID;
}
public static function removeForecast( $forecastID )
{
Forecast::whereId( $forecastID )->delete();
}
}
+12
View File
@@ -31,6 +31,16 @@ class Project extends BaseModel {
return $this->hasMany( 'Invoice' );
}
public function forecasts()
{
return $this->hasMany( 'Forecast' );
}
public function reservations()
{
return $this->hasMany( 'Reservation' );
}
public function projectleader()
{
return $this->belongsTo( 'User', 'projectleader_id' );
@@ -96,6 +106,8 @@ class Project extends BaseModel {
'projectemployees.user' => function ( $q ) {
$q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" );
}] )
->with(['forecasts'])
->with(['reservations'])
->with( 'projectemployees.projecthours' )
->with( 'projectcosts.external' )
->with( 'invoices.payments' )
@@ -0,0 +1,38 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 07/03/2018
* Time: 09:24
*/
class Reservation extends BaseModel {
public function project()
{
return $this->belongsTo( 'Project' );
}
public static function saveReservation( $reservationID, $reservation )
{
$reservation = (array) $reservation;
if ( $reservationID == 0 )
{
$reservation = self::create( $reservation );
$reservationID = $reservation['id'];
}
else
{
self::whereId( $reservationID )->update( $reservation );
}
return $reservationID;
}
public static function removeReservation( $reservationID )
{
Reservation::whereId( $reservationID )->delete();
}
}
@@ -0,0 +1,43 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 07/03/2018
* Time: 15:31
*/
class QinvoiceMonthOverview {
public static function fire( $projectID, $year )
{
$sql = "SELECT MNT.id,
month,
COALESCE(forecastamount, 0) AS forecastamount,
COALESCE(paymentamount, 0) AS paymentamount
FROM months MNT
LEFT JOIN (
SELECT SUM(forecastamount) AS forecastamount, month_id
FROM forecasts
WHERE project_id = {$projectID}
AND `year` = {$year}
GROUP BY month_id
) AS FCT
ON MNT.id = FCT.month_id + 1
LEFT JOIN (
SELECT SUM(paymentamount) AS paymentamount, MONTH(paymentdate) AS month_id
FROM payments PAY
JOIN invoices INV
ON INV.id = PAY.invoice_id
WHERE INV.project_id = {$projectID}
AND YEAR(paymentdate) = {$year}
GROUP BY month_id
) AS PAY
ON MNT.id = PAY.month_id
JOIN projects PRJ
GROUP BY MNT.id
ORDER BY MNT.id ";
return $sql;
}
}
@@ -16,11 +16,16 @@ class Qinvoiceoverview {
PRJ.projectname,
(own_revenue + other_revenue ) AS revenues,
CUS.name AS customername,
IF( YEAR(invoicedate) = {$year},SUM(invoiceamount), 0) AS currentyear,
IF( YEAR(invoicedate) != {$year},SUM(invoiceamount), 0) AS otheryear,
COALESCE(Q1.currentyearpayed, 0) AS currentyearpayed,
COALESCE(Q1.otheryearpayed, 0) AS otheryearpayed,
CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname
SUM(IF( YEAR(invoicedate) = {$year},invoiceamount, 0)) AS currentyear,
SUM(IF( YEAR(invoicedate) != {$year},invoiceamount, 0)) AS otheryear,
SUM(COALESCE(Q1.currentyearpayed, 0)) AS currentyearpayed,
SUM(COALESCE(Q1.otheryearpayed, 0)) AS otheryearpayed,
CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname,
( SELECT vatrate FROM vats WHERE archive = 'F' LIMIT 1 ) AS vatrate,
COALESCE(reserved, 0 ) AS reserved,
COALESCE(reservedpayed, 0 ) AS reservedpayed,
COALESCE(currentforecast, 0) AS currentforecast,
COALESCE(otherforecast, 0) AS otherforecast
FROM invoices INV
RIGHT JOIN projects PRJ
ON PRJ.id = INV.project_id
@@ -38,6 +43,22 @@ class Qinvoiceoverview {
GROUP BY invoice_id
) AS Q1
ON INV.id = Q1.invoice_id
LEFT JOIN (
SELECT project_id,
SUM(IF(payed='UNPAYED', reservationamount, 0)) reserved,
SUM(IF(payed='PAYED', reservationamount, 0)) reservedpayed
FROM reservations
GROUP BY project_id
) AS Q2
ON PRJ.id = Q2.project_id
LEFT JOIN (
SELECT project_id,
SUM(IF(year = {$year}, IF(month_id >= MONTH(NOW()) -1, forecastamount, 0), 0)) AS currentforecast,
SUM(IF(year > {$year}, forecastamount, 0)) AS otherforecast
FROM forecasts
GROUP BY project_id
) AS Q3
ON PRJ.id = Q3.project_id
GROUP BY PRJ.projectnumber, PRJ.projectname ";
return $sql;
@@ -0,0 +1,78 @@
<div class="panel panel-bordered panel-primary panel-line">
<div class="panel-heading panel-heading-project">
<h3 class="">
prognoses
</h3>
</div>
<div class="panel-body panel-body-project">
<table class="table table-sm">
<thead>
<th class="table-cyanish-header" width="25%">
jaar
</th>
<th class="table-cyanish-header" width="25%">
maand
</th>
<th class="table-cyanish-header align-right" width="35%">
bedrag
</th>
<th class="table-cyanish-header" width="15%">&nbsp;</th>
</thead>
<tbody data-bind="foreach:forecasts">
<tr>
<td>
<span data-bind="text:dbo.helpers.findArrayElement('year', 'year', year(), $root.years()),
visible:! inEdit()"></span>
<select class="form-control form-control-sm"
data-bind="options:$root.years,
optionsText:'year',
optionsValue:'year',
value:year,
optionsCaption:'voer jaar in',
visible: inEdit(),
event:{change:$root.saveForecast}">
</select>
</td>
<td>
<span data-bind="text:dbo.helpers.findArrayElement('monthID', 'month', month_id(), $root.months()),
visible:! inEdit()"></span>
<select class="form-control form-control-sm"
data-bind="options:$root.months,
optionsText:'month',
optionsValue:'monthID',
value:month_id,
optionsCaption:'voer maand in',
visible: inEdit(),
event:{change:$root.saveForecast}">
</select>
</td>
<td class="align-right">
<span data-bind="visible:!inEdit()">
<i class="icon fa-euro"></i>
<span data-bind="text:dbo.helpers.numberWithPoints(forecastamount())"></span>
</span>
<input type="text"
class="form-control form-control-sm align-right"
paceholder="bedrag"
data-bind="textInput:forecastamount, visible:inEdit,
event:{change:$root.saveForecast,keyup:$root.validateNumber.bind($data, 'forecastamount')}"/>
</td>
<td>
<i class="icon fa-edit pointer" title="wijzig" data-bind="click:$root.editForecast"></i>
<i class="icon fa-trash redish pointer" title="verwijder"
data-bind="click:$root.removeForecast"></i>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<th colspan="4">
<button class="btn btn-primary btn-round btn-sm" data-bind="click:addForecast">
nieuwe prognose
</button>
</th>
</tr>
</tfoot>
</table>
</div>
</div>
@@ -126,7 +126,6 @@
</th>
<th class="table-cyanish-header-light">
</th>
<th width="50%">&nbsp;</th>
</thead>
<tbody data-bind="foreach:payments">
<tr>
@@ -0,0 +1,55 @@
<div class="panel panel-bordered panel-primary panel-line">
<div class="panel-heading panel-heading-project">
<h3 class="">
Reserveringen
</h3>
</div>
<div class="panel-body panel-body-project">
<table class="table table-sm">
<thead>
<th class="table-cyanish-header" width="40%">
bedrag
</th>
<th class="table-cyanish-header" width="40%">
betaald
</th>
<th class="table-cyanish-header" width="20%">&nbsp;</th>
</thead>
<tbody data-bind="foreach:reservations">
<tr>
<td class="align-right">
<span data-bind="visible:!inEdit()">
<i class="icon fa-euro"></i>
<span data-bind="text:dbo.helpers.numberWithPoints(reservationamount())"></span>
</span>
<input type="text"
class="form-control form-control-sm align-right"
paceholder="bedrag"
data-bind="textInput:reservationamount, visible:inEdit,
event:{change:$root.saveReservation,keyup:$root.validateNumber.bind($data, 'reservationamount')}"/>
</td>
<td>
<i class="icon fa-square-o pointer" title="niet betaald"
data-bind="click:$root.setPayment.bind($data, 'PAYED'), visible:payed()=='UNPAYED'"></i>
<i class="icon fa-check pointer" title="betaald"
data-bind="click:$root.setPayment.bind($data, 'UNPAYED'), visible: payed()=='PAYED'"></i>
</td>
<td>
<i class="icon fa-edit pointer" title="wijzig" data-bind="click:$root.editReservation"></i>
<i class="icon fa-trash redish pointer" title="verwijder"
data-bind="click:$root.removeReservation"></i>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<th colspan="4">
<button class="btn btn-primary btn-round btn-sm" data-bind="click:addReservation">
nieuwe reservering
</button>
</th>
</tr>
</tfoot>
</table>
</div>
</div>
+7 -1
View File
@@ -58,11 +58,17 @@
<div class="col-md-7">
<?php $this->load->view( 'modals/partials/_projectcosts' ); ?>
</div>
<div class="col-md-5">
<?php $this->load->view('modals/partials/_forecasts'); ?>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="col-md-9">
<?php $this->load->view( 'modals/partials/_invoices' ); ?>
</div>
<div class="col-md-3">
<?php $this->load->view( 'modals/partials/_reservations' ); ?>
</div>
</div>
</div>
<div class="tab-pane animation-slide-top" id="employees">
@@ -14,91 +14,28 @@
</div>
<div class="row">
<div class="col-md-12">
<table class="table table-condensed" style="font-size:0.8em;">
<thead>
<tr>
<th class="rotate">
<div><span>project</span></div>
</th>
<th class="rotate">
<div><span>klant</span></div>
</th>
<th class="rotate">
<div><span>status afgehandeld</span></div>
</th>
<th class="rotate">
<div><span>projectleider</span></div>
</th>
<th class="rotate">
<div><span>te factureren(excl btw)</span></div>
</th>
<th class="rotate">
<div><span>te factureren(incl btw)</span></div>
</th>
<th class="rotate">
<div><span>gefactureerd voorgaande jaren(incl btw)</span></div>
</th>
<th class="rotate">
<div><span>gefactureerd lopend jaar(incl btw)</span></div>
</th>
<th class="rotate">
<div><span>totaal gefactureerd(incl btw)</span></div>
</th>
<th class="rotate">
<div><span>betaald voorgaande jaren</span></div>
</th>
<th class="rotate">
<div><span>betaald lopend jaar</span></div>
</th>
<th class="rotate">
<div><span>totaal betaald</span></div>
</th>
</tr>
</thead>
<tbody>
<!-- ko foreach: projects -->
<tr>
<td><span data-bind="text:projectnumber"></span></td>
<td><span data-bind="text:customername"></span></td>
<td><span data-bind="text:statusProject == 'CLOSED' ? 'afgesloten' : 'open'"></span></td>
<td><span data-bind="text:fullname"></span>
</td>
<td class="align-right">
<i class="icon fa-euro"></i>
<span data-bind="text:openstaand"></span>
</td>
<td class="align-right">
<i class="icon fa-euro"></i>
<span data-bind="text:openstaandIncl"></span>
</td>
<td class="align-right">
<i class="icon fa-euro"></i>
<span data-bind="text:invoicedOtherYears"></span>
</td>
<td class="align-right">
<i class="icon fa-euro"></i>
<span data-bind="text:invoicedCurentYear"></span>
</td>
<td class="align-right">
<i class="icon fa-euro"></i>
<span data-bind="text:totalInvoiced"></span>
</td>
<td class="align-right">
<i class="icon fa-euro"></i>
<span data-bind="text:invoicedOtherYearsPayed"></span>
</td>
<td class="align-right">
<i class="icon fa-euro"></i>
<span data-bind="text:invoicedCurentYearPayed"></span>
</td>
<td class="align-right">
<i class="icon fa-euro"></i>
<span data-bind="text:totalInvoicedPayed"></span>
</td>
</tr>
<!-- /ko -->
</tbody>
</table>
<div class="nav-tabs-horizontal">
<ul class="nav nav-tabs nav-tabs-solid">
<li class="nav-item" data-bind="click:setActivetab.bind($data, 'invoice')" style="z-index:10">
<a class="nav-link" data-bind="css:{'active':invoiceTab() == 'invoice'}">facturen</a>
</li>
<li class="nav-item" data-bind="click:setActivetab.bind($data, 'forecast')" style="z-index:10">
<a class="nav-link" data-bind="css:{'active':invoiceTab() == 'forecast'}">prognoses</a>
</li>
<li class="nav-item" data-bind="click:setActivetab.bind($data, 'monthforecast')" style="z-index:10">
<a class="nav-link" data-bind="css:{'active':invoiceTab() == 'monthforecast'}">maand prognoses</a>
</li>
<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>
</li>
<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>
</li>
</ul>
<div class="tab-content">
<?php $this->load->view('reports/invoices/_invoicetable'); ?>
</div>
</div>
</div>
</div>
</div>
@@ -0,0 +1,172 @@
<table class="table table-condensed" style="font-size:0.8em;">
<thead>
<tr>
<th class="rotate">
<div><span>project</span></div>
</th>
<th class="rotate">
<div><span>klant</span></div>
</th>
<th class="rotate">
<div><span>status afgehandeld</span></div>
</th>
<th class="rotate">
<div><span>projectleider</span></div>
</th>
<!-- ko if:$root.invoiceTab() == 'invoice' -->
<th class="rotate">
<div><span>te factureren(excl btw)</span></div>
</th>
<th class="rotate">
<div><span>te factureren(incl btw)</span></div>
</th>
<th class="rotate">
<div><span>gefactureerd voorgaande jaren(incl btw)</span></div>
</th>
<th class="rotate">
<div><span>gefactureerd lopend jaar(incl btw)</span></div>
</th>
<th class="rotate">
<div><span>totaal gefactureerd(incl btw)</span></div>
</th>
<th class="rotate">
<div><span>betaald voorgaande jaren</span></div>
</th>
<th class="rotate">
<div><span>betaald lopend jaar</span></div>
</th>
<th class="rotate">
<div><span>totaal betaald</span></div>
</th>
<th class="rotate">
<div><span>nog niet betaald</span></div>
</th>
<!-- /ko -->
<!-- ko if:$root.invoiceTab() == 'forecast' -->
<th class="rotate">
<div><span>nog te factureren</span></div>
</th>
<th class="rotate">
<div><span>nog te factureren lopend jaar</span></div>
</th>
<th class="rotate">
<div><span>nog te factureren na lopend jaar</span></div>
</th>
<th class="rotate">
<div><span>verschil prognose - werkelijk</span></div>
</th>
<!-- /ko -->
<!-- ko if:$root.invoiceTab() == 'monthforecast' || $root.invoiceTab() == 'monthpayments' -->
<!-- ko foreach:months -->
<th><span data-bind="text:month"></span></th>
<!-- /ko -->
<!-- /ko -->
</tr>
</thead>
<tbody>
<!-- ko foreach: projects -->
<tr>
<td><span data-bind="text:projectnumber"></span></td>
<td><span data-bind="text:customername"></span></td>
<td><span data-bind="text:statusProject == 'CLOSED' ? 'afgesloten' : 'open'"></span></td>
<td><span data-bind="text:fullname"></span>
</td>
<!-- ko if:$root.invoiceTab() == 'invoice' -->
<td class="align-right">
<i class="icon fa-euro"></i>
<span data-bind="text:revenues"></span>
</td>
<td class="align-right">
<i class="icon fa-euro"></i>
<span data-bind="text:totalInvoice"></span>
</td>
<td class="align-right">
<i class="icon fa-euro"></i>
<span data-bind="text:invoicedOtherYears"></span>
</td>
<td class="align-right">
<i class="icon fa-euro"></i>
<span data-bind="text:invoicedCurentYear"></span>
</td>
<th class="align-right focus-green">
<i class="icon fa-euro"></i>
<span data-bind="text:totalInvoiced"></span>
</th>
<td class="align-right">
<i class="icon fa-euro"></i>
<span data-bind="text:invoicedOtherYearsPayed"></span>
</td>
<td class="align-right">
<i class="icon fa-euro"></i>
<span data-bind="text:invoicedCurentYearPayed"></span>
</td>
<th class="align-right focus-green">
<i class="icon fa-euro"></i>
<span data-bind="text:totalInvoicedPayed"></span>
</th>
<th class="align-right">
<i class="icon fa-euro"></i>
<span data-bind="text:notPayed"></span>
</th>
<!-- /ko -->
<!-- ko if:$root.invoiceTab() == 'forecast' -->
<td class="align-right">
<i class="icon fa-euro"></i>
<span data-bind="text:toInvoice"></span>
</td>
<td class="align-right">
<i class="icon fa-euro"></i>
<span data-bind="text:currentforecast"></span>
</td>
<td class="align-right">
<i class="icon fa-euro"></i>
<span data-bind="text:otherforecast"></span>
</td>
<th class="align-right">
<i class="icon fa-euro"></i>
<span data-bind="text:missingForecast"></span>
</th>
<!-- /ko -->
<!-- ko if:$root.invoiceTab() == 'monthforecast' -->
<!-- ko foreach:months -->
<td class="align-right">
<span data-bind="text:forecastamount">
</span>
</td>
<!-- /ko -->
<!-- /ko -->
<!-- ko if:$root.invoiceTab() == 'monthpayments' -->
<!-- ko foreach:months -->
<td class="align-right">
<span data-bind="text:paymentamount">
</span>
</td>
<!-- /ko -->
<!-- /ko -->
</tr>
<!-- /ko -->
</tbody>
<tfoot>
<tr>
<th colspan="4" class="align-right">
totaal
</th>
<!-- ko if:$root.invoiceTab() == 'monthforecast' -->
<!-- ko foreach:months -->
<th class="align-right">
<span data-bind="text:dbo.helpers.numberWithPoints($root['forecast' + month]())">
</span>
</th>
<!-- /ko -->
<!-- /ko -->
<!-- ko if:$root.invoiceTab() == 'monthpayments' -->
<!-- ko foreach:months -->
<th class="align-right">
<span data-bind="text:dbo.helpers.numberWithPoints($root['payment' + month]())">
</span>
</th>
<!-- /ko -->
<!-- /ko -->
</tr>
</tfoot>
</table>
+5
View File
@@ -99,6 +99,11 @@ th.rotate > div > span {
height:20px;
border:1px solid #777;
}
th.focus-green{
background-color:#dcf7b0;
border:0;
font-weight: bold;
}
/*********SWITCH************/
.onoffswitch {
@@ -13,6 +13,14 @@ dbo.invoiceDataService = {
.done( function ( data ) {
callback( data );
} );
},
getMonthDetails: function ( year, callback ) {
$.getJSON( 'index.php/reports/employeeHoursController/getMonthDetails/' + year )
.done( function ( data ) {
callback( data );
} );
}
}
@@ -41,12 +41,6 @@ dbo.projectDataService = {
} );
},
addProject: function ( callback ) {
$.getJSON( 'index.php/projects/projectsController/addProject', function ( data ) {
callback( data );
} );
},
createProject: function ( offerID, callback ) {
$.getJSON( 'index.php/projects/projectsController/creatProjectFromOffer/' + offerID )
.done( function ( data ) {
@@ -99,6 +93,20 @@ dbo.projectDataService = {
} );
},
saveForecast: function ( submitDATA, callback ) {
$.post( 'index.php/projects/projectsController/saveForecast', submitDATA )
.done( function ( data ) {
callback( data );
} );
},
saveReservation: function ( submitDATA, callback ) {
$.post( 'index.php/projects/projectsController/saveReservation', submitDATA )
.done( function ( data ) {
callback( data );
} );
},
archiveProject: function ( userID, status, callback ) {
$.get( 'index.php/projects/projectsController/archiveProject/' + userID + '/' + status )
.done( function () {
@@ -132,6 +140,20 @@ dbo.projectDataService = {
.done( function ( data ) {
callback( data );
} );
},
removeForecast: function ( forecastID, callback ) {
$.getJSON( 'index.php/projects/projectsController/removeForecast/' + forecastID )
.done( function ( data ) {
callback( data );
} );
},
removeReservation: function ( reservationID, callback ) {
$.getJSON( 'index.php/projects/projectsController/removeReservation/' + reservationID )
.done( function ( data ) {
callback( data );
} );
}
+24 -7
View File
@@ -31,17 +31,34 @@ $( function () {
};
} );
function uploadFile(file, foreignID, tablename, callback){
function uploadFile( file, foreignID, tablename, callback ) {
var url = 'index.php/utils/fileUpload/upload/' + foreignID + '/' + tablename;
var xhr = new XMLHttpRequest();
var fd = new FormData();
xhr.open("POST", url, true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && xhr.status == 200) {
xhr.open( "POST", url, true );
xhr.onreadystatechange = function () {
if ( xhr.readyState == 4 && xhr.status == 200 ) {
callback();
}
};
fd.append("userfile", file);
fd.append( "userfile", file );
xhr.send( fd );
}
dbo.monthLabels = ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'];
dbo.currentMonth = (new Date()).getMonth();
dbo.monthArray = [];
for ( var I = 0; I < 12; I++ ) {
dbo.monthArray.push( {monthID: I, month: dbo.monthLabels[I]} );
}
dbo.currentYear = (new Date()).getFullYear();
dbo.years = []
for ( var I = (dbo.currentYear - 2); I <= dbo.currentYear + 2; I++ ) {
dbo.years.push( {year: I} );
}
xhr.send(fd);
}
+184 -1
View File
@@ -23,6 +23,8 @@ $( function () {
projectcosts : ko.observableArray( [] ),
vats : ko.observableArray( [] ),
availableEmployees: ko.observableArray( [] ),
forecasts : ko.observableArray( [] ),
reservations : ko.observableArray( [] ),
showProject : ko.observable( false ),
projectID : null,
callback : null,
@@ -37,6 +39,8 @@ $( function () {
ownRevenue : ko.observable(),
otherRevenue : ko.observable(),
projectname : ko.observable(),
years : ko.observableArray( dbo.years ),
months : ko.observableArray( dbo.monthArray ),
init: function () {
var vm = dbo.editProjectModal;
@@ -119,6 +123,14 @@ $( function () {
vm.saveProjecthour( this );
},
setPayment: function ( status ) {
var vm = dbo.editProjectModal;
this.payed( status );
vm.saveReservation( this );
},
editProjecthour: function () {
var self = this;
var vm = dbo.editProjectModal;
@@ -143,6 +155,30 @@ $( function () {
} );
},
editForecast: function () {
var self = this;
var vm = dbo.editProjectModal;
$.each( vm.forecasts(), function ( i, p ) {
if ( p.id == self.id ) {
p.inEdit( !p.inEdit() );
} else {
p.inEdit( false );
}
} );
},
editReservation: function () {
var self = this;
var vm = dbo.editProjectModal;
$.each( vm.reservations(), function ( i, p ) {
if ( p.id == self.id ) {
p.inEdit( !p.inEdit() );
} else {
p.inEdit( false );
}
} );
},
newOffer: function () {
var vm = dbo.editProjectModal;
var service = dbo.offersService;
@@ -244,6 +280,35 @@ $( function () {
} );
},
addForecast: function () {
var vm = dbo.editProjectModal;
var forecast = {
id : 0,
project_id : vm.projectID,
year : dbo.currentYear,
month_id : dbo.currentMonth,
forecastamount: 0,
inEdit : true
};
vm.forecasts.push( new vm.Forecast( forecast ) );
},
addReservation: function () {
var vm = dbo.editProjectModal;
var reservation = {
id : 0,
project_id : vm.projectID,
reservationamount: 0,
payed : 'UNPAYED',
inEdit : true
};
vm.reservations.push( new vm.Reservation( reservation ) );
},
editProject: function ( projectID, callback ) {
var vm = dbo.editProjectModal;
@@ -394,6 +459,39 @@ $( function () {
} );
},
saveForecast: function () {
var vm = dbo.editProjectModal;
var self = this;
var submitDATA = {
id : self.id,
project_id : self.project_id,
year : self.year(),
month_id : self.month_id(),
forecastamount: self.forecastamount()
}
dbo.projectDataService.saveForecast( submitDATA, function ( data ) {
if ( data.success ) self.id = data.forecastID;
} );
},
saveReservation: function ( self = false ) {
var vm = dbo.editProjectModal;
if ( !self ) self = this;
var submitDATA = {
id : self.id,
project_id : self.project_id,
payed : self.payed(),
reservationamount: self.reservationamount()
}
dbo.projectDataService.saveReservation( submitDATA, function ( data ) {
if ( data.success ) self.id = data.reservationID;
} );
},
removeProjectemployee: function () {
var vm = dbo.editProjectModal;
var self = this;
@@ -510,6 +608,64 @@ $( function () {
} );
},
removeForecast: function () {
var vm = dbo.editProjectModal;
var self = this;
tellMe( {
title : 'verwijderen prognose',
message : 'weet u zeker dat u deze prognose wilt verwijderen, dit kan niet ongedaan worden gemaakt',
notify : true,
noText : 'nee verwijder prognose niet',
yesText : 'ja verwijder de prognose',
modalClass: 'modal-warning'
}, function ( response ) {
console.log( response );
if ( response ) {
dbo.projectDataService.removeForecast( self.id, function ( data ) {
if ( data.result ) {
vm.refreshProject();
} else {
tellMe( {
title : 'fout bij verwijderen prognose',
message : 'de prognose kan niet worden verwijderd',
modalClass: 'modal-danger'
} );
}
} );
}
} );
},
removeReservation: function () {
var vm = dbo.editProjectModal;
var self = this;
tellMe( {
title : 'verwijderen reservering',
message : 'weet u zeker dat u deze reservering wilt verwijderen, dit kan niet ongedaan worden gemaakt',
notify : true,
noText : 'nee verwijder reservering niet',
yesText : 'ja verwijder de reservering',
modalClass: 'modal-warning'
}, function ( response ) {
console.log( response );
if ( response ) {
dbo.projectDataService.removeReservation( self.id, function ( data ) {
if ( data.result ) {
vm.refreshProject();
} else {
tellMe( {
title : 'fout bij verwijderen reserevring',
message : 'de reservering kan niet worden verwijderd',
modalClass: 'modal-danger'
} );
}
} );
}
} );
},
closeProject: function () {
var vm = dbo.editProjectModal;
@@ -577,6 +733,16 @@ $( function () {
vm.invoices.push( new vm.Invoice( p ) );
} );
vm.forecasts.removeAll();
$.each( data.forecasts, function ( i, p ) {
vm.forecasts.push( new vm.Forecast( p ) );
} );
vm.reservations.removeAll();
$.each( data.reservations, function ( i, p ) {
vm.reservations.push( new vm.Reservation( p ) );
} );
vm.busy = false;
dbo.charts.drawHoursVsBudget( 340, 230, 'hours-vs-budget' );
@@ -692,6 +858,23 @@ $( function () {
this.paymentdate = ko.observable( dbo.helpers.mysql2date( data.paymentdate ) );
this.paymentamount = ko.observable( data.paymentamount );
this.inEdit = ko.observable( inEdit );
},
Forecast: function ( data ) {
this.id = data.id;
this.project_id = data.project_id;
this.year = ko.observable( data.year );
this.month_id = ko.observable( data.month_id );
this.forecastamount = ko.observable( data.forecastamount );
this.inEdit = ko.observable( data.inEdit || false );
},
Reservation: function ( data ) {
this.id = data.id;
this.project_id = data.project_id;
this.reservationamount = ko.observable( data.reservationamount );
this.payed = ko.observable( data.payed );
this.inEdit = ko.observable( data.inEdit || false );
}
};
@@ -704,7 +887,7 @@ $( function () {
totalHours += Number( p.hours() );
}
} );
return totalHours.toFixed(2);
return totalHours.toFixed( 2 );
} );
dbo.editProjectModal.totalRevenue = ko.pureComputed( function () {
@@ -195,10 +195,10 @@ dbo.monthlyemployeehoursInit = function () {
drawCharts: function ( self ) {
if ( self.hourView() ) {
dbo.charts.drawHoursChart( 'hours-per-month-' + self.slug, self.chartData, dbo.charts.monthLabels, 'uren per maand', '#f28f25' );
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.charts.monthLabels, 'omzet per maand', '#f28f25' );
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' );
}
},
@@ -19,6 +19,8 @@ dbo.outgoinginvoicesInit = function () {
selectedYear : ko.observable(),
selectedMonthID: ko.observable(),
projects : ko.observableArray( [] ),
invoiceTab : ko.observable( 'invoice' ),
months : ko.observableArray( dbo.monthArray ),
init: function () {
var vm = dbo.outgoinginvoicesModel;
@@ -39,11 +41,16 @@ dbo.outgoinginvoicesInit = function () {
} );
},
setActivetab: function ( tab ) {
var vm = dbo.outgoinginvoicesModel;
vm.invoiceTab( tab );
},
initModule: function () {
var vm = dbo.outgoinginvoicesModel;
vm.refreshInvoiceDetails();
},
refreshInvoiceDetails: function () {
@@ -56,27 +63,55 @@ dbo.outgoinginvoicesInit = function () {
_.each( data, function ( p ) {
vm.projects.push( new vm.Project( p ) );
} );
} );
},
Project: function ( data ) {
var vm = dbo.outgoinginvoicesModel;
var self = this;
var openstaand = data.revenues - (Number( data.currentyear ) + Number( data.otheryear ));
this.projectnumber = data.projectnumber;
this.customername = data.customername;
this.statusProject = Math.abs( openstaand ) > 2 ? 'OPEN' : 'CLOSED';
this.fullname = data.fullname;
this.openstaand = dbo.helpers.numberWithPoints(Math.round(openstaand));
this.openstaandIncl = dbo.helpers.numberWithPoints(Math.round(openstaand * 1.21));
this.invoicedOtherYears = dbo.helpers.numberWithPoints(Math.round(data.otheryear));
this.invoicedCurentYear = dbo.helpers.numberWithPoints(Math.round(data.currentyear));
this.totalInvoiced = dbo.helpers.numberWithPoints(Math.round(data.currentyear) + Math.round(data.otheryear));
this.invoicedOtherYearsPayed = dbo.helpers.numberWithPoints(Math.round(data.otheryearpayed));
this.invoicedCurentYearPayed = dbo.helpers.numberWithPoints(Math.round(data.currentyearpayed));
this.totalInvoicedPayed = dbo.helpers.numberWithPoints(Math.round(data.currentyearpayed) + Math.round(data.otheryearpayed));
var totalInvoice = data.revenues * (1 + (data.vatrate / 100));
var totalInvoiced = Math.round( data.currentyear ) + Math.round( data.otheryear );
var totalInvoicedPayed = Math.round( data.currentyearpayed ) + Math.round( data.otheryearpayed );
var notPayed = totalInvoiced - totalInvoicedPayed;
self.projectnumber = data.projectnumber;
self.customername = data.customername;
self.statusProject = Math.abs( openstaand ) > 2 ? 'OPEN' : 'CLOSED';
self.fullname = data.fullname;
self.revenues = dbo.helpers.numberWithPoints( data.revenues );
self.totalInvoice = dbo.helpers.numberWithPoints( totalInvoice );
self.openstaand = dbo.helpers.numberWithPoints( Math.round( openstaand ) );
self.openstaandIncl = dbo.helpers.numberWithPoints( Math.round( openstaand * 1.21 ) );
self.invoicedOtherYears = dbo.helpers.numberWithPoints( Math.round( data.otheryear ) );
self.invoicedCurentYear = dbo.helpers.numberWithPoints( Math.round( data.currentyear ) );
self.totalInvoiced = dbo.helpers.numberWithPoints( totalInvoiced );
self.invoicedOtherYearsPayed = dbo.helpers.numberWithPoints( Math.round( data.otheryearpayed ) );
self.invoicedCurentYearPayed = dbo.helpers.numberWithPoints( Math.round( data.currentyearpayed ) );
self.totalInvoicedPayed = dbo.helpers.numberWithPoints( totalInvoicedPayed );
self.notPayed = dbo.helpers.numberWithPoints( notPayed );
self.toInvoice = dbo.helpers.numberWithPoints( totalInvoice - totalInvoiced );
self.currentforecast = dbo.helpers.numberWithPoints( data.currentforecast );
self.otherforecast = dbo.helpers.numberWithPoints( data.otherforecast );
self.missingForecast =
dbo.helpers.numberWithPoints( totalInvoice - totalInvoiced - data.otherforecast );
self.months = ko.observableArray( [] );
_.each( data.months, function ( p ) {
self.months.push( new vm.Month( p ) );
if ( !vm['forecast' + p.month] ) vm['forecast' + p.month] = ko.observable( 0 );
vm['forecast' + p.month]( Number( vm['forecast' + p.month]() ) + Number( p.forecastamount ) );
if ( !vm['payment' + p.month] ) vm['payment' + p.month] = ko.observable( 0 );
vm['payment' + p.month]( Number( vm['payment' + p.month]() ) + Number( p.paymentamount ) );
} );
},
Month: function ( data ) {
this.forecastamount = dbo.helpers.numberWithPoints( Number( data.forecastamount ).toFixed( 0 ) );
this.paymentamount = dbo.helpers.numberWithPoints( Number( data.paymentamount ).toFixed( 0 ) );
}
}
dbo.outgoinginvoicesModel.init();
-1
View File
@@ -9,7 +9,6 @@ dbo.charts = {
pieColors : ['#ffcf30', '#06b2dc', '#048a44', '#a63305', '#a0c03b', '#ffcb22', '#89c540', '#f77c01', '#1094f6', '#6733ba'],
barColor : ['#f3a921', '#f2770c', '#72221a', '#04843b', '#d63f2e', '#fec220'],
monthLabels: ['januari', 'februari', 'maart', 'april', 'mei', 'juni', 'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
charts : [],
drawHoursVsBudget: function ( hours, budget, element ) {