diversen nav opmerkingen
This commit is contained in:
@@ -41,6 +41,18 @@ class usersController extends MY_Controller {
|
||||
$this->json( $user );
|
||||
}
|
||||
|
||||
public function getCurrentUser()
|
||||
{
|
||||
$this->json( $this->user );
|
||||
}
|
||||
|
||||
public function getUserWithprojects()
|
||||
{
|
||||
$usersWithProjects = User::getUserWithprojects();
|
||||
|
||||
$this->json( $usersWithProjects );
|
||||
}
|
||||
|
||||
public function getUniqueprojectEmployees()
|
||||
{
|
||||
$projectEmployees = User::getUniqueProjectUsers();
|
||||
|
||||
@@ -22,11 +22,15 @@ class EmployeeHoursController extends MY_Controller {
|
||||
$this->load->library( $libraries );
|
||||
}
|
||||
|
||||
public function getEmployeehours( $month, $year )
|
||||
public function getEmployeehours( $month, $year, $employeeID )
|
||||
{
|
||||
$employeehours = Employeehour::getEmployeehours( $month, $year );
|
||||
$sql = EmployeehoursMonthly::fire( $month, $year, $employeeID );
|
||||
|
||||
$this->json( $employeehours );
|
||||
$query = $this->db->query( $sql );
|
||||
|
||||
$result = $query->result();
|
||||
|
||||
$this->json( $result );
|
||||
}
|
||||
|
||||
public function getHourtypes()
|
||||
@@ -42,11 +46,31 @@ class EmployeeHoursController extends MY_Controller {
|
||||
$data = $this->input->post();
|
||||
|
||||
$employeehourID = $data['id'];
|
||||
$hourType = $data['hourType'];
|
||||
$projectID = $data['project_id'];
|
||||
unset( $data['id'] );
|
||||
unset( $data['hourType'] );
|
||||
unset( $data['project_id'] );
|
||||
|
||||
$data['hourdate'] = date2mysql( $data['hourdate'] );
|
||||
|
||||
$employeehourID = Employeehour::saveEmployeehour( $employeehourID, $data );
|
||||
if ( $hourType == 'PROJECTS' )
|
||||
{
|
||||
$projectemployee = Projectemployee::select( 'id' )
|
||||
->whereUserId( $data['employee_id'] )
|
||||
->whereprojectId( $projectID )
|
||||
->first();
|
||||
$data['projectemployee_id'] = $projectemployee->id;
|
||||
unset( $data['employee_id'] );
|
||||
|
||||
$data['hourtype_id'] = $data['hourtype_id'] - 8;
|
||||
|
||||
$employeehourID = Projecthour::saveProjecthour( $employeehourID, $data );
|
||||
}
|
||||
else
|
||||
{
|
||||
$employeehourID = Employeehour::saveEmployeehour( $employeehourID, $data );
|
||||
}
|
||||
|
||||
$this->json( ['employeehourID' => $employeehourID] );
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ class ProjectsController extends MY_Controller {
|
||||
|
||||
if ( AUTHENTICATED == FALSE ) die( 'NO ACCESS' );
|
||||
|
||||
$models = [];
|
||||
$models = ['projects/Invoices_model'];
|
||||
$libraries = [];
|
||||
|
||||
$this->load->model( $models );
|
||||
@@ -38,6 +38,9 @@ class ProjectsController extends MY_Controller {
|
||||
{
|
||||
$project = Project::getProject( $projectID );
|
||||
|
||||
$project->outstanding =
|
||||
$this->Invoices_model->getOutstandingPerProject( $project->id );
|
||||
|
||||
$this->json( $project );
|
||||
}
|
||||
|
||||
|
||||
@@ -23,15 +23,22 @@ class Employeehour extends BaseModel {
|
||||
|
||||
public static function getEmployeehours( $month, $year )
|
||||
{
|
||||
$employeehours = Employeehour::whereRaw( "MONTH(hourdate) ={$month} AND YEAR(hourdate) = {$year}" )
|
||||
$employeehours = Employeehour::whereRaw( "MONTH(hourdate) = " . ( $month + 1 ) . " AND YEAR(hourdate) = {$year}" )
|
||||
->with( [
|
||||
'user' => function ( $q ) {
|
||||
$q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" );
|
||||
}] )
|
||||
->with( 'hourtype' )
|
||||
->get();
|
||||
->with( 'hourtype' );
|
||||
|
||||
return $employeehours;
|
||||
$projecthours = Employeehour::whereRaw("MONTH(hourdate) = " . ( $month + 1 ) . " AND YEAR(hourdate) = {$year}" )->with( [
|
||||
'user' => function ( $q ) {
|
||||
$q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" );
|
||||
}] )
|
||||
->with( 'hourtype' );
|
||||
|
||||
$results = $employeehours->union($projecthours)->get();
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
public static function saveEmployeehour( $employeehourID, $data )
|
||||
|
||||
@@ -45,6 +45,16 @@ class User extends BaseModel {
|
||||
return $userrole;
|
||||
}
|
||||
|
||||
public static function getUserWithprojects()
|
||||
{
|
||||
$usersWithProjects =
|
||||
User::selectRaw( "users.id, CONCAT(users.firstname, ' ', users.middlename, ' ', users.lastname) AS fullname" )
|
||||
->with( 'projectemployees.project' )
|
||||
->get();
|
||||
|
||||
return $usersWithProjects;
|
||||
}
|
||||
|
||||
public static function checkUsername( $username )
|
||||
{
|
||||
$username = strtoupper( $username );
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 15/03/2018
|
||||
* Time: 10:47
|
||||
*/
|
||||
|
||||
class EmployeehoursMonthly {
|
||||
|
||||
public static function fire($month, $year, $employeeID)
|
||||
{
|
||||
$month = $month + 1;
|
||||
$sql = "
|
||||
SELECT *
|
||||
FROM (
|
||||
SELECT CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname,
|
||||
hourtype_id,
|
||||
EMH.id,
|
||||
USR.id AS employee_id,
|
||||
hours,
|
||||
DATE_FORMAT(hourdate, '%d-%m-%Y') AS hourdate,
|
||||
NULL AS project_id
|
||||
FROM employeehours EMH
|
||||
JOIN users USR
|
||||
ON USR.id = EMH.employee_id
|
||||
WHERE MONTH(hourdate) = {$month}
|
||||
AND YEAR(hourdate) = {$year} ";
|
||||
if( $employeeID != 0 ) $sql.="AND USR.id = {$employeeID} ";
|
||||
$sql.="
|
||||
UNION
|
||||
SELECT CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname,
|
||||
(SELECT id FROM hourtypes WHERE `key` = 'PROJECTS' LIMIT 1) AS hourtype_id,
|
||||
PRH.id,
|
||||
USR.id AS employee_id,
|
||||
hours,
|
||||
DATE_FORMAT(hourdate, '%d-%m-%Y') AS hourdate,
|
||||
PEM.project_id
|
||||
FROM projecthours PRH
|
||||
JOIN projectemployees PEM
|
||||
ON PEM.id = PRH.projectemployee_id
|
||||
JOIN users USR
|
||||
ON USR.id = PEM.user_id
|
||||
WHERE MONTH(hourdate) = {$month}
|
||||
AND YEAR(hourdate) = {$year} ";
|
||||
if( $employeeID != 0 ) $sql.="AND USR.id = {$employeeID} ";
|
||||
$sql.="
|
||||
) Q1
|
||||
ORDER BY fullname, hourdate ";
|
||||
|
||||
return $sql;
|
||||
}
|
||||
}
|
||||
@@ -23,4 +23,20 @@ class Invoices_model extends MY_Model {
|
||||
|
||||
return $invoiced;
|
||||
}
|
||||
|
||||
public function getOutstandingPerProject( $projectID )
|
||||
{
|
||||
$this->sql = "
|
||||
SELECT (own_revenue + other_revenue) - SUM(INV.invoiceamount) AS outstanding
|
||||
FROM invoices INV
|
||||
JOIN projects PRJ
|
||||
ON PRJ.id = INV.project_id
|
||||
JOIN offers OFF
|
||||
ON PRJ.id = OFF.project_id
|
||||
WHERE PRJ.id = {$projectID} ";
|
||||
|
||||
$invoiced = $this->get_query_row( 'outstanding' );
|
||||
|
||||
return $invoiced;
|
||||
}
|
||||
}
|
||||
@@ -168,6 +168,26 @@
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-xl-3 form-control-label">
|
||||
kosten derden
|
||||
</label>
|
||||
<div class="col-xl-4">
|
||||
<div class="input-group input-group-icon">
|
||||
<span class="input-group-addon">
|
||||
<i class="icon fa-euro"></i>
|
||||
</span>
|
||||
<input type="text"
|
||||
placeholder="eigen omzet"
|
||||
class="form-control align-right"
|
||||
data-bind="textInput:costs,
|
||||
event:{keyup:validateNumber}">
|
||||
</div>
|
||||
<small>
|
||||
kosten derden (incl btw)
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<label class="col-xl-3 form-control-label">
|
||||
acceptatie datum
|
||||
|
||||
@@ -72,6 +72,11 @@
|
||||
</button>
|
||||
</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="4">
|
||||
<b><h5>openstaand: <span data-bind="text:dbo.helpers.numberWithPoints(Math.round(outstanding()))"></span></h5></b>
|
||||
</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -86,7 +86,7 @@
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="form-group row">
|
||||
<h4 class="form-control-label">eigenomzet:
|
||||
<h4 class="form-control-label">eigen omzet:
|
||||
<i class="icon fa-euro"> </i><span data-bind="text:ownRevenue"></span>
|
||||
</h4>
|
||||
</div>
|
||||
|
||||
@@ -55,19 +55,19 @@
|
||||
<!-- <div class="col-md-5">-->
|
||||
<!-- --><?php //$this->load->view( 'modals/partials/_projectoffers' ); ?>
|
||||
<!-- </div>-->
|
||||
<div class="col-md-7">
|
||||
<div class="col-md-8">
|
||||
<?php $this->load->view( 'modals/partials/_projectcosts' ); ?>
|
||||
</div>
|
||||
<div class="col-md-5">
|
||||
<?php $this->load->view('modals/partials/_forecasts'); ?>
|
||||
<div class="col-md-4">
|
||||
<?php $this->load->view( 'modals/partials/_reservations' ); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-9">
|
||||
<div class="col-md-8">
|
||||
<?php $this->load->view( 'modals/partials/_invoices' ); ?>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<?php $this->load->view( 'modals/partials/_reservations' ); ?>
|
||||
<div class="col-md-4">
|
||||
<?php $this->load->view('modals/partials/_forecasts'); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,36 +3,45 @@
|
||||
<div class="col-md-2">
|
||||
<select class="form-control form-control-sm"
|
||||
data-bind="options:years,
|
||||
optionsText:'id',
|
||||
optionsValue:'id',
|
||||
optionsText:'year',
|
||||
optionsValue:'year',
|
||||
value:selectedYear,
|
||||
event:{change:refreshEmployeehours}"></select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<select class="form-control form-control-sm"
|
||||
data-bind="options:months,
|
||||
optionsText:'monthName',
|
||||
optionsValue:'id',
|
||||
optionsText:'month',
|
||||
optionsValue:'monthID',
|
||||
value:selectedMonth,
|
||||
event:{change:refreshEmployeehours}"></select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<select class="form-control form-control-sm"
|
||||
data-bind="options:employees,
|
||||
optionsText:'fullname',
|
||||
optionsValue:'id',
|
||||
value:$root.selectedEmployeeID,
|
||||
event:{change:refreshEmployeehours}"></select>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="row">
|
||||
<div class="col-xl-8">
|
||||
<div class="col-xl-10">
|
||||
<table class="table table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="table-tealish-header">medewerker</th>
|
||||
<th class="table-tealish-header">datum</th>
|
||||
<th class="table-tealish-header">soort uren</th>
|
||||
<th class="table-tealish-header">project</th>
|
||||
<th class="table-tealish-header">uren</th>
|
||||
<th class="table-tealish-header" width="40px"> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody data-bind="foreach:employeehours">
|
||||
<tr>
|
||||
<td>
|
||||
<td data-bind="css:{'red-line': id() == 0}">
|
||||
<span data-bind="text:dbo.helpers.findArrayElement('id', 'fullname', employee_id(), $root.employees()),
|
||||
visible: ! inEdit()"></span>
|
||||
<select class="form-control form-control-sm"
|
||||
@@ -42,16 +51,17 @@
|
||||
value:employee_id,
|
||||
optionsCaption: 'selecteer...',
|
||||
visible:inEdit(),
|
||||
event:{change:$root.saveEmployeehours}"></select>
|
||||
enable: ! $root.selectedEmployeeID,
|
||||
event:{change:$root.changeEmployee}"></select>
|
||||
</td>
|
||||
<td>
|
||||
<td data-bind="css:{'red-line': id() == 0}">
|
||||
<span data-bind="text:hourdate, visible:! inEdit()"></span>
|
||||
<input class="form-control form-control-sm"
|
||||
data-bind="datepicker:{dateFormat: 'dd-mm-yy' },
|
||||
value:hourdate, visible:inEdit(),
|
||||
event:{change:$root.saveEmployeehour}"
|
||||
</td>
|
||||
<td>
|
||||
<td data-bind="css:{'red-line': id() == 0}">
|
||||
<span data-bind="text:dbo.helpers.findArrayElement('id', 'description', hourtype_id(), $root.hourtypes()),
|
||||
visible: ! inEdit()"></span>
|
||||
<select class="form-control form-control-sm"
|
||||
@@ -63,7 +73,21 @@
|
||||
visible:inEdit(),
|
||||
event:{change:$root.saveEmployeehours}"></select>
|
||||
</td>
|
||||
<td class="align-right">
|
||||
<td data-bind="css:{'red-line': id() == 0}">
|
||||
<!-- ko if: hourType() == 'PROJECTS' -->
|
||||
<span data-bind="text:dbo.helpers.findArrayElement('projectID', 'projectname', projectID(), projects()),
|
||||
visible: ! inEdit()"></span>
|
||||
<select class="form-control form-control-sm"
|
||||
data-bind="options:projects,
|
||||
optionsText:'projectname',
|
||||
optionsValue:'projectID',
|
||||
value:projectID,
|
||||
optionsCaption:'selecteer...',
|
||||
visible:inEdit(),
|
||||
event:{change:$root.saveEmployeehours}"></select>
|
||||
<!-- /ko -->
|
||||
</td>
|
||||
<td class="align-right" data-bind="css:{'red-line': id() == 0}">
|
||||
<span data-bind=" visible: ! inEdit()">
|
||||
<span data-bind="text:hours"></span>
|
||||
uur
|
||||
@@ -74,7 +98,7 @@
|
||||
data-bind="textInput:hours, visible:inEdit,
|
||||
event:{change:$root.saveEmployeehours,keyup:$root.validateNumber.bind($data, 'hours')}"/>
|
||||
</td>
|
||||
<td>
|
||||
<td data-bind="css:{'red-line': id() == 0}">
|
||||
<i class="icon fa-edit pointer" title="wijzig" data-bind="click:$root.editEmployeehour"></i>
|
||||
<i class="icon fa-trash redish pointer" title="verwijder"
|
||||
data-bind="click:$root.removeEmployeehour"></i>
|
||||
@@ -83,7 +107,7 @@
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<td colspan="3" class="">
|
||||
<td colspan="3">
|
||||
<button class="btn btn-primary btn-round btn-sm" data-bind="click:newEmployeehour">
|
||||
nieuwe uren
|
||||
</button>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<select class="form-control form-control-sm"
|
||||
data-bind="options:years,
|
||||
optionsText:'year',
|
||||
optionsValue: 'id',
|
||||
optionsValue: 'year',
|
||||
value:selectedYear,
|
||||
event:{change:refreshTab}"></select>
|
||||
</div>
|
||||
|
||||
@@ -22,17 +22,17 @@
|
||||
</th>
|
||||
<!-- /ko -->
|
||||
<th class="rotate">
|
||||
<div><span>totaal</span></div>
|
||||
<div><span>eigen budget beschikbaar (ex btw)</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>budget (ex btw)</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>derden (ex btw)</span></div>
|
||||
</th>
|
||||
<th class="rotate">
|
||||
<div><span>beschikbaar</span></div>
|
||||
<div><span>totaal geschreven omzet</span></div>
|
||||
</th>
|
||||
<!-- <th class="rotate">-->
|
||||
<!-- <div><span>derden (ex btw)</span></div>-->
|
||||
<!-- </th>-->
|
||||
<!-- <th class="rotate">-->
|
||||
<!-- <div><span>beschikbaar</span></div>-->
|
||||
<!-- </th>-->
|
||||
<th class="rotate">
|
||||
<div><span>saldo</span></div>
|
||||
</th>
|
||||
@@ -58,21 +58,21 @@
|
||||
<span data-bind="text:revenues"></span>
|
||||
</td>
|
||||
<!-- /ko -->
|
||||
<th class="align-right">
|
||||
<td class="align-right">
|
||||
<span data-bind="text:ownRevenue"></span>
|
||||
</td>
|
||||
<td class="align-right">
|
||||
<span data-bind="text:totalEmployeeRevenues"></span>
|
||||
</th>
|
||||
<td class="align-right">
|
||||
<span data-bind="text:budget"></span>
|
||||
</td>
|
||||
<td class="align-right">
|
||||
<span data-bind="text:externCosts"></span>
|
||||
</td>
|
||||
<th class="align-right">
|
||||
<span data-bind="text:budgetAvailable"></span>
|
||||
</th>
|
||||
<th class="align-right">
|
||||
<span data-bind="text:saldo"></span>
|
||||
<span data-bind="text:availableRevenue"></span>
|
||||
</th>
|
||||
<!-- <td class="align-right">-->
|
||||
<!-- <span data-bind="text:externCosts"></span>-->
|
||||
<!-- </td>-->
|
||||
<!-- <th class="align-right">-->
|
||||
<!-- <span data-bind="text:saldo"></span>-->
|
||||
<!-- </th>-->
|
||||
<th class="align-right">
|
||||
<span data-bind="text:workInProgress"></span>
|
||||
</th>
|
||||
@@ -91,21 +91,21 @@
|
||||
<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:totalBudget"></span>
|
||||
</th>
|
||||
<th class="align-right">
|
||||
<span data-bind="text:totalCosts"></span>
|
||||
</th>
|
||||
<th class="align-right">
|
||||
<span data-bind="text:totalAvailableBudget"></span>
|
||||
</th>
|
||||
<th class="align-right">
|
||||
<span data-bind="text:totalSaldo"></span>
|
||||
<span data-bind="text:totalAvailableRevenues"></span>
|
||||
</th>
|
||||
<!-- <th class="align-right">-->
|
||||
<!-- <span data-bind="text:totalCosts"></span>-->
|
||||
<!-- </th>-->
|
||||
<!-- <th class="align-right">-->
|
||||
<!-- <span data-bind="text:totalSaldo"></span>-->
|
||||
<!-- </th>-->
|
||||
<th class="align-right">
|
||||
<span data-bind="text:totalWorkInProgress"></span>
|
||||
</th>
|
||||
|
||||
Reference in New Issue
Block a user