Diversen nav opmerkingen
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
* Date: 21/04/2018
|
||||
* Time: 20:08
|
||||
*/
|
||||
//include_once('../application/models/eloquent/Employeetarget.php');
|
||||
|
||||
//include_once('../application/models/eloquent/Employeetarget.php');
|
||||
|
||||
|
||||
class EmployeeTargetController extends MY_Controller {
|
||||
@@ -30,5 +30,26 @@ class EmployeeTargetController extends MY_Controller {
|
||||
$this->json( $employeeTargets );
|
||||
}
|
||||
|
||||
public function saveEmployeeTarget()
|
||||
{
|
||||
$employeeTargetValidation = new EmployeeTargetValidation();
|
||||
|
||||
if ( ! $employeeTargetValidation->getValidationResult() )
|
||||
return $this->json( [
|
||||
'success' => FALSE, 'messages' => $employeeTargetValidation->getErrorMessages()] );
|
||||
|
||||
$target = $this->input->post();
|
||||
|
||||
$targetID = $target['id'];
|
||||
unset( $target['id'] );
|
||||
|
||||
$target['endmonth'] = $target['endmonth'] ? $target['endmonth'] : NULL;
|
||||
$target['endyear'] = $target['endyear'] ? $target['endyear'] : NULL;
|
||||
|
||||
$targetID = Employeetarget::saveTarget( $targetID, $target );
|
||||
|
||||
$this->json( ['success' => TRUE, 'targetID' => $targetID] );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -51,6 +51,11 @@ class ReportsController extends MY_Controller {
|
||||
|
||||
$result = $query->result();
|
||||
|
||||
foreach($result as $user)
|
||||
{
|
||||
$user->targethours = Employeetarget::getTargetHoursPerEmployee( $user->user_id, $year, $month);
|
||||
}
|
||||
|
||||
$this->json( $result );
|
||||
}
|
||||
|
||||
|
||||
@@ -27,22 +27,30 @@ class ReservationsController extends MY_Controller {
|
||||
{
|
||||
$projects[ $result->projectID ] = [
|
||||
'projectnumber' => $result->projectnumber,
|
||||
'costs' => 0,
|
||||
'reservation' => 0,
|
||||
'payed' => 0,
|
||||
'saldo' => 0,
|
||||
'saldoToPay' => 0,
|
||||
'other_revenue' => 0,
|
||||
'customers' => []
|
||||
];
|
||||
}
|
||||
|
||||
$projects[ $result->projectID ]['reservation'] += $result->reservation;
|
||||
$projects[ $result->projectID ]['costs'] += $result->costs;
|
||||
$projects[ $result->projectID ]['payed'] += $result->payed;
|
||||
$projects[ $result->projectID ]['saldo'] += $result->saldo;
|
||||
$projects[ $result->projectID ]['saldoToPay'] += $result->saldoToPay;
|
||||
$projects[ $result->projectID ]['other_revenue'] = $result->other_revenue;
|
||||
|
||||
$projects[ $result->projectID ]['externals'][] = [
|
||||
'external' => $result->contactperson,
|
||||
'reservation' => $result->reservation,
|
||||
'costs' => $result->costs,
|
||||
'payed' => $result->payed,
|
||||
'saldo' => $result->saldo
|
||||
'saldo' => $result->saldo,
|
||||
'saldoToPay' => $result->saldoToPay
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -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 EmployeeTargetValidation extends BaseValidation {
|
||||
|
||||
|
||||
protected $validationFields = [
|
||||
'user_id' => [
|
||||
'validations' => 'required|integer',
|
||||
'fieldname' => 'gebruiker'
|
||||
],
|
||||
'startmonth' => [
|
||||
'validations' => 'required|decimal',
|
||||
'fieldname' => 'startmaand'
|
||||
],
|
||||
'startyear' => [
|
||||
'validations' => 'required|integer',
|
||||
'fieldname' => 'startjaar'
|
||||
],
|
||||
'target' =>[
|
||||
'validations' => 'integer',
|
||||
'fieldname' => 'uren target'
|
||||
]
|
||||
];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->ci =& get_instance();
|
||||
}
|
||||
}
|
||||
@@ -15,4 +15,48 @@ class Employeetarget extends BaseModel {
|
||||
return $this->belongsTo( 'User' );
|
||||
}
|
||||
|
||||
public static function saveTarget( $targetID, $target )
|
||||
{
|
||||
$target = (array) $target;
|
||||
|
||||
if ( $targetID == 0 )
|
||||
{
|
||||
$target = self::create( $target );
|
||||
$targetID = $target['id'];
|
||||
}
|
||||
else
|
||||
{
|
||||
self::whereId( $targetID )->update( $target );
|
||||
}
|
||||
|
||||
return $targetID;
|
||||
}
|
||||
|
||||
public static function getTargetHoursPerEmployee( $employeeID, $year, $monthID )
|
||||
{
|
||||
$months = $monthID == 0 ? [1,2,3,4,5,6,7,8,9,10,11,12] : [$monthID];
|
||||
|
||||
$targetHours = 0;
|
||||
|
||||
foreach($months as $month)
|
||||
{
|
||||
$targetHours += self::getCurrentMonthTarget( $employeeID, $year, $month);
|
||||
}
|
||||
|
||||
return $targetHours;
|
||||
}
|
||||
|
||||
public static function getCurrentMonthTarget( $employeeID, $year, $month )
|
||||
{
|
||||
$monthTarget = Self::whereUserId($employeeID)
|
||||
->where('startyear', '<=', $year)
|
||||
->where('startmonth', '<=', $month)
|
||||
->orderBy('startyear', 'DESC')
|
||||
->orderBy('startmonth', 'DESC');
|
||||
|
||||
if( $monthTarget->count() == 0 ) return 0;
|
||||
|
||||
return $monthTarget->first()->target;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -14,12 +14,12 @@ class QEmployeeHours {
|
||||
SELECT monthID,
|
||||
user_id,
|
||||
CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname,
|
||||
SUM(projecthours) AS projecthours,
|
||||
SUM(profitablehours) AS profitablehours,
|
||||
SUM(nonprofitablehours) AS nonprofitablehours,
|
||||
SUM(revenues) AS revenues,
|
||||
SUM(nonprojecthours) AS nonprojecthours,
|
||||
SUM(projecthours + nonprojecthours) AS totalhours,
|
||||
ROUND(SUM(projecthours), 0) AS projecthours,
|
||||
ROUND(SUM(profitablehours), 0) AS profitablehours,
|
||||
ROUND(SUM(nonprofitablehours), 0) AS nonprofitablehours,
|
||||
ROUND(SUM(revenues), 0) AS revenues,
|
||||
ROUND(SUM(nonprojecthours), 0) AS nonprojecthours,
|
||||
ROUND(SUM(projecthours + nonprojecthours), 0) AS totalhours,
|
||||
targethours
|
||||
FROM (
|
||||
SELECT employee_id AS user_id,
|
||||
|
||||
@@ -10,31 +10,47 @@ class ReservationTotals {
|
||||
|
||||
public static function fire()
|
||||
{
|
||||
$sql = "SELECT projectID, externalID, reservation, payed, (reservation - payed) AS saldo, PRJ.projectnumber, EXT.contactperson
|
||||
// UNION ALL wordt gebruikt voor een full outer join
|
||||
$sql = "SELECT Q5.project_id AS projectID, external_id AS externalID,
|
||||
costs, reservation, payed, (reservation - payed) AS saldo,
|
||||
(costs - payed) AS saldoToPay, PRJ.projectnumber, EXT.contactperson,
|
||||
ROUND(( (other_revenue * (100 + (SELECT vatrate from vats where active='T' LIMIT 1))) / 100 ), 0) other_revenue
|
||||
FROM (
|
||||
SELECT COALESCE(RES.project_id, PRC.project_id) AS projectID,
|
||||
COALESCE(RES.external_id, PRC.external_id) AS externalID,
|
||||
SUM(COALESCE(reservationamount, 0)) AS reservation,
|
||||
SUM(COALESCE(payed, 0)) AS payed
|
||||
FROM reservations RES
|
||||
LEFT JOIN projectcosts PRC
|
||||
ON RES.project_id = PRC.project_id AND RES.external_id = PRC.external_id
|
||||
GROUP BY COALESCE(RES.project_id, PRC.project_id), COALESCE(PRC.external_id, PRC.external_id)
|
||||
SELECT COALESCE(reservation, 0) AS reservation, costs, payed, Q2.external_id, Q2.project_id
|
||||
FROM (
|
||||
SELECT SUM(reservationamount) AS reservation, external_id, project_id
|
||||
FROM reservations
|
||||
GROUP BY external_id, project_id
|
||||
) Q1
|
||||
RIGHT JOIN
|
||||
(
|
||||
SELECT SUM(costs) AS costs, SUM(payed) AS payed, external_id, project_id
|
||||
FROM projectcosts
|
||||
GROUP BY external_id, project_id
|
||||
) Q2
|
||||
ON Q1.external_id = Q2.external_id AND Q1.project_id = Q2.project_id
|
||||
UNION ALL
|
||||
SELECT COALESCE(RES.project_id, PRC.project_id) AS projectID,
|
||||
COALESCE(RES.external_id, PRC.external_id) AS externalID,
|
||||
SUM(COALESCE(reservationamount, 0)) AS reservation,
|
||||
SUM(COALESCE(payed, 0)) AS payed
|
||||
FROM reservations RES
|
||||
RIGHT JOIN projectcosts PRC
|
||||
ON RES.project_id = PRC.project_id AND RES.external_id = PRC.external_id
|
||||
WHERE RES.id IS NULL
|
||||
GROUP BY COALESCE(RES.project_id, PRC.project_id), COALESCE(RES.external_id, PRC.external_id)
|
||||
) Q3
|
||||
SELECT reservation, COALESCE(costs, 0), COALESCE(payed, 0), Q3.external_id, Q3.project_id
|
||||
FROM (
|
||||
SELECT SUM(reservationamount) AS reservation, external_id, project_id
|
||||
FROM reservations
|
||||
GROUP BY external_id, project_id
|
||||
) Q3
|
||||
LEFT JOIN
|
||||
(
|
||||
SELECT SUM(costs) AS costs, SUM(payed) AS payed, external_id, project_id, id
|
||||
FROM projectcosts
|
||||
GROUP BY external_id, project_id
|
||||
) Q4
|
||||
ON Q3.external_id = Q4.external_id AND Q3.project_id = Q4.project_id
|
||||
WHERE Q4.id IS NULL
|
||||
) Q5
|
||||
JOIN projects PRJ
|
||||
ON PRJ.id = Q3.projectID
|
||||
ON PRJ.id = Q5.project_id
|
||||
JOIN externals EXT
|
||||
ON EXT.id = Q3.externalID ";
|
||||
ON EXT.id = Q5.external_id
|
||||
JOIN offers OFF
|
||||
ON PRJ.id = OFF.project_id ";
|
||||
|
||||
return $sql;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
<div class="modal modal-fade-in-scale-up modal-primary" tabindex="-1" id="employee-target-modal">
|
||||
<div class="modal-dialog" role="document">
|
||||
<div class="modal-dialog" role="document" style="width:700px;">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">toevoegen / wijzigen medewerker uren
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</h5>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-md-10 col-md-offset-1">
|
||||
<div class="col-md-12">
|
||||
<table class="table table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -19,60 +19,72 @@
|
||||
<th colspan="2"> </th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>maand</th>
|
||||
<th>jaar</th>
|
||||
<th>maand</th>
|
||||
<th>jaar</th>
|
||||
<th>target per maand</th>
|
||||
<th width="25%">maand</th>
|
||||
<th width="17%">jaar</th>
|
||||
<th width="25%">maand</th>
|
||||
<th width="17%">jaar</th>
|
||||
<th width="16%" title="target per maand">target p/m</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<!-- ko foreach:employeeTargets -->
|
||||
<tr>
|
||||
<td>
|
||||
<select data-bind="options:years,
|
||||
<td data-bind="css:{'red-line': ! saved()}">
|
||||
<select data-bind="options:$root.months,
|
||||
optionsText:'month',
|
||||
optionsValue:'monthID',
|
||||
value:startmonth,
|
||||
disable: ! changeable(),
|
||||
event:{change:$root.setUnsaved}"
|
||||
class="form-control">
|
||||
</select>
|
||||
</td>
|
||||
<td data-bind="css:{'red-line': ! saved()}">
|
||||
<select data-bind="options:$root.years,
|
||||
optionsText:'year',
|
||||
optionsValue:'year',
|
||||
value:startyear,
|
||||
disable: ! changeable()"
|
||||
disable: ! changeable(),
|
||||
event:{change:$root.setUnsaved}"
|
||||
class="form-control">
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select data-bind="options:months,
|
||||
<td data-bind="css:{'red-line': ! saved()}">
|
||||
<select data-bind="options:$root.months,
|
||||
optionsText:'month',
|
||||
optionsValue:'month_id',
|
||||
value:startmonth,
|
||||
disable: ! changeable()"
|
||||
optionsValue:'monthID',
|
||||
value:endmonth,
|
||||
disable: ! changeable(),
|
||||
optionsCaption:'selecteer...',
|
||||
event:{change:$root.setUnsaved}"
|
||||
class="form-control">
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select data-bind="options:years,
|
||||
<td data-bind="css:{'red-line': ! saved()}">
|
||||
<select data-bind="options:$root.years,
|
||||
optionsText:'year',
|
||||
optionsValue:'year',
|
||||
value:endyear,
|
||||
disable: ! changeable()"
|
||||
disable: ! changeable(),
|
||||
optionsCaption:'selecteer...',
|
||||
event:{change:$root.setUnsaved}"
|
||||
class="form-control">
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<select data-bind="options:months,
|
||||
optionsText:'month',
|
||||
optionsValue:'month_id',
|
||||
value:endmonth"
|
||||
class="form-control">
|
||||
</select>
|
||||
</td>
|
||||
<td>
|
||||
<td data-bind="css:{'red-line': ! saved()}">
|
||||
<input type="text"
|
||||
class="form-control"
|
||||
data-bind="textInput:target">
|
||||
data-bind="textInput:target,
|
||||
disable: ! changeable(),
|
||||
event:{keyup:$root.checkNumeric},
|
||||
event:{change:$root.setUnsaved}">
|
||||
</td>
|
||||
<td>
|
||||
<td data-bind="css:{'red-line': ! saved()}">
|
||||
<button class="btn btn-success"
|
||||
data-bind="disable: ! validTarget()">
|
||||
data-bind="disable: ! validTarget(),
|
||||
click:$root.saveEmployeeTarget,
|
||||
visible: changeable()">
|
||||
opslaan
|
||||
</button>
|
||||
</td>
|
||||
@@ -83,7 +95,7 @@
|
||||
<tr>
|
||||
<th colspan="6">
|
||||
<i class="icon fa-plus-square-o pull-right pointer"
|
||||
data-bind="click:addEmployeeTarget"></i>
|
||||
data-bind="click:addEmployeeTarget, visible:newTarget()"></i>
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
|
||||
@@ -5,10 +5,8 @@
|
||||
<label>jaar</label>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="col-md-2">
|
||||
<input type="text" class="form-control" data-bind="textInput:selectedYear, event:{keyup:checkYear}" >
|
||||
<div class="invalid-feedback" data-bind="visible: ! validYear()">geen geldig jaar</div>
|
||||
</div>
|
||||
<input type="text" class="form-control" data-bind="textInput:selectedYear, event:{keyup:checkYear}">
|
||||
<div class="invalid-feedback" data-bind="visible: ! validYear()">geen geldig jaar</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
@@ -24,7 +22,7 @@
|
||||
</ul>
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active">
|
||||
<?php $this->load->view('reports/employeehours/employeemonthhours_view'); ?>
|
||||
<?php $this->load->view( 'reports/employeehours/employeemonthhours_view' ); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
<div id="OUTGOINGINVOICES">
|
||||
<div class="row">
|
||||
<div class="col-xl-1">
|
||||
<div class="col-md-1">
|
||||
<label>jaar</label>
|
||||
</div>
|
||||
<div class="col-xl-3">
|
||||
<select class="form-control form-control-sm"
|
||||
data-bind="options:years,
|
||||
optionsText:'year',
|
||||
optionsValue: 'id',
|
||||
value:selectedYear,
|
||||
event:{change:refreshInvoiceDetails}"></select>
|
||||
<div class="col-md-2">
|
||||
<input type="text" class="form-control" data-bind="textInput:selectedYear, event:{keyup:checkYear}">
|
||||
<div class="invalid-feedback" data-bind="visible: ! validYear()">geen geldig jaar</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
|
||||
@@ -1,14 +1,18 @@
|
||||
<div id="RESERVATIONS">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="col-md-12">
|
||||
<table class="table table-condensed">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="5px"> </th>
|
||||
<th>project</th>
|
||||
<th class="align-right">Budget derden</th>
|
||||
<th class="align-right">gefactureerd</th>
|
||||
<th class="align-right">gereserveerd</th>
|
||||
<th class="align-right">betaald</th>
|
||||
<th class="align-right">saldo</th>
|
||||
<th class="align-right">saldo te betalen</th>
|
||||
<th class="align-right">saldo reservering</th>
|
||||
<th class="align-right">saldo te factureren</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<!-- ko foreach:projects -->
|
||||
@@ -25,15 +29,27 @@
|
||||
<th>
|
||||
<span data-bind="text:projectnumber"></span>
|
||||
</th>
|
||||
<th class="align-right" data-bind="visible: ! showExternals()">
|
||||
<span data-bind="text:otherRevenue"></span>
|
||||
</th>
|
||||
<th class="align-right" data-bind="visible: ! showExternals()">
|
||||
<span data-bind="text:costs"></span>
|
||||
</th>
|
||||
<th class="align-right" data-bind="visible: ! showExternals()">
|
||||
<span data-bind="text:reservation"></span>
|
||||
</th>
|
||||
<th class="align-right" data-bind="visible: ! showExternals()">
|
||||
<span data-bind="text:payed"></span>
|
||||
</th>
|
||||
<th class="align-right" data-bind="visible: ! showExternals()">
|
||||
<span data-bind="text:saldoToPay"></span>
|
||||
</th>
|
||||
<th class="align-right" data-bind="visible: ! showExternals()">
|
||||
<span data-bind="text:saldo"></span>
|
||||
</th>
|
||||
<th class="align-right" data-bind="visible: ! showExternals()">
|
||||
<span data-bind="text:saldoInvoices"></span>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- ko if:showExternals() -->
|
||||
<!-- ko foreach: externals -->
|
||||
@@ -42,30 +58,50 @@
|
||||
<td>
|
||||
<span data-bind="text:externalName"></span>
|
||||
</td>
|
||||
<td> </td>
|
||||
<td class="align-right">
|
||||
<span data-bind="text:costs"></span>
|
||||
</td>
|
||||
<td class="align-right">
|
||||
<span data-bind="text:reservation"></span>
|
||||
</td>
|
||||
<td class="align-right">
|
||||
<span data-bind="text:payed"></span>
|
||||
</td>
|
||||
<td class="align-right">
|
||||
<span data-bind="text:saldoToPay"></span>
|
||||
</td>
|
||||
<td class="align-right">
|
||||
<span data-bind="text:saldo"></span>
|
||||
</td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<!-- /ko -->
|
||||
<!-- /ko -->
|
||||
<!-- ko if:showExternals() -->
|
||||
<tr class="subtotal">
|
||||
<th colspan="2">Totaal</th>
|
||||
<th class="align-right">
|
||||
<span data-bind="text:otherRevenue"></span>
|
||||
</th>
|
||||
<th class="align-right">
|
||||
<span data-bind="text:costs"></span>
|
||||
</th>
|
||||
<th class="align-right">
|
||||
<span data-bind="text:reservation"></span>
|
||||
</th>
|
||||
<th class="align-right">
|
||||
<span data-bind="text:payed"></span>
|
||||
</th>
|
||||
<th class="align-right">
|
||||
<span data-bind="text:saldoToPay"></span>
|
||||
</th>
|
||||
<th class="align-right">
|
||||
<span data-bind="text:saldo"></span>
|
||||
</th>
|
||||
<th class="align-right">
|
||||
<span data-bind="text:saldoInvoices"></span>
|
||||
</th>
|
||||
</tr>
|
||||
<!-- /ko -->
|
||||
</tbody>
|
||||
@@ -73,9 +109,13 @@
|
||||
<tfoot>
|
||||
<tr class="grandtotal">
|
||||
<th colspan="2">Grand totaal</th>
|
||||
<th class="align-right"><span data-bind="text:otherRevenue"></span></th>
|
||||
<th class="align-right"><span data-bind="text:costs"></span></th>
|
||||
<th class="align-right"><span data-bind="text:reservation"></span></th>
|
||||
<th class="align-right"><span data-bind="text:payed"></span></th>
|
||||
<th class="align-right"><span data-bind="text:saldoToPay"></span></th>
|
||||
<th class="align-right"><span data-bind="text:saldo"></span></th>
|
||||
<th class="align-right"><span data-bind="text:saldoInvoices"></span></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<th class="rotate"><div><span>uren niet declarabel</span></div></th>
|
||||
<th class="rotate"><div><span>uren indirect</span></div></th>
|
||||
<th class="rotate"><div><span>totaal bestede uren</span></div></th>
|
||||
<th class="rotate"><div><span>uren target(1.600 jaar)</span></div></th>
|
||||
<th class="rotate"><div><span>uren jaartarget</span></div></th>
|
||||
<th class="rotate"><div><span>aandeel uren besteed tov target</span></div></th>
|
||||
<th class="rotate"><div><span>bezettingsgraad totaal<br />aantal gewerkte uren</span></div></th>
|
||||
<th class="rotate"><div><span>bezettingsgraad t.o.v. target<br />factureerbare uren</span></div></th>
|
||||
|
||||
Reference in New Issue
Block a user