employeehours

This commit is contained in:
2018-01-31 21:56:13 +01:00
parent 05c165c9ed
commit b634d0b139
24 changed files with 700 additions and 85 deletions
@@ -0,0 +1,62 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 31/01/2018
* Time: 20:08
*/
class EmployeehoursController extends MY_Controller {
public function __construct()
{
parent::__construct();
if ( AUTHENTICATED == FALSE ) die( 'NO ACCESS' );
$models = [];
$libraries = [];
$this->load->model( $models );
$this->load->library( $libraries );
}
public function getEmployeehours( $month, $year )
{
$employeehours = Employeehour::getEmployeehours( $month, $year );
$this->json( $employeehours );
}
public function getHourtypes()
{
$hourtypes = Hourtype::all();
$this->json( $hourtypes );
}
public function saveEmployeehour()
{
//TODO: validatie inbouwen
$data = $this->input->post();
$employeehourID = $data['id'];
unset( $data['id'] );
$data['hourdate'] = date2mysql( $data['hourdate'] );
$employeehourID = Employeehour::saveEmployeehour( $employeehourID, $data );
$this->json( ['employeehourID' => $employeehourID] );
}
public function removeEmployeehour( $employeehourID )
{
//TODO:check op delete
Employeehour::whereId( $employeehourID )->delete();
$this->json( ['result' => TRUE] );
}
}
@@ -119,8 +119,6 @@ class ProjectsController extends MY_Controller {
$projectemployeeID = $projectemployee['id'];
unset( $projectemployee['id'] );
$projectemployee['startdate'] = date2mysql( $projectemployee['startdate'] );
Projectemployee::saveProjectemployee( $projectemployeeID, $projectemployee );
$this->json( ['success' => TRUE] );
@@ -28,6 +28,10 @@ class ProjectcostValidation extends BaseValidation {
'costs' => [
'validations' => 'number',
'fieldname' => 'kosten'
],
'payed' => [
'validations' => 'number',
'fieldname' => 'betaald'
]
];
@@ -0,0 +1,52 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 21/12/2017
* Time: 18:05
*/
class Employeehour extends BaseModel {
protected $table = "employeehours";
public function user()
{
return $this->belongsTo( 'User', 'employee_id' );
}
public function hourtype()
{
return $this->belongsTo( 'Hourtype' );
}
public static function getEmployeehours( $month, $year )
{
$employeehours = Employeehour::whereRaw( "MONTH(hourdate) ={$month} AND YEAR(hourdate) = {$year}" )
->with( [
'user' => function ( $q ) {
$q->selectRaw( "id, CONCAT(firstname, ' ', middlename, ' ', lastname) AS fullname" );
}] )
->with( 'hourtype' )
->get();
return $employeehours;
}
public static function saveEmployeehour( $employeehourID, $data )
{
if ( $employeehourID == 0 )
{
$employeehour = Employeehour::create( $data );
$employeehourID = $employeehour->id;
}
else
{
Employeehour::whereId( $employeehourID )->update( $data );
}
return $employeehourID;
}
}
+18
View File
@@ -0,0 +1,18 @@
<?php
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 21/12/2017
* Time: 18:05
*/
class Hourtype extends BaseModel {
protected $table = "hourtypes";
public function employeehours()
{
return $this->hasMany( 'Employeehour' );
}
}
@@ -150,6 +150,22 @@
</div>
</div>
</div>
<div class="form-group row">
<label class="col-xl-3 form-control-label">
IBAN
</label>
<div class="col-xl-9">
<div class="input-group input-group-icon">
<span class="input-group-addon">
<i class="icon fa-institution"></i>
</span>
<input type="text"
placeholder="IBAN"
class="form-control"
data-bind="textInput:iban">
</div>
</div>
</div>
<div class="form-group row">
<label class="col-xl-3 form-control-label">
tarief (per uur)
+31 -5
View File
@@ -7,16 +7,22 @@
<div class="panel-body panel-body-project">
<table class="table table-sm">
<thead>
<th class="table-cyanish-header">
<th class="table-cyanish-header" width="35%">
medewerker
</th>
<th class="table-cyanish-header">
<th class="table-cyanish-header" width="15%">
datum
</th>
<th class="table-cyanish-header align-right">
<th class="table-cyanish-header" width="15%">
declarabel
</th>
<th class="table-cyanish-header align-right" width="12%">
uren
</th>
<th class="table-cyanish-header" width="40px">
<th class="table-cyanish-header align-right" width="15%">
omzet
</th>
<th class="table-cyanish-header" width="8%">
&nbsp;
</th>
</thead>
@@ -39,11 +45,15 @@
<span data-bind="text:hourdate, visible:! inEdit()"></span>
<input type="text"
class="form-control form-control-sm"
placeholder="start"
placeholder="datum"
data-bind="datepicker:{dateFormat: 'dd-mm-yy' },
value:hourdate, visible:inEdit,
event:{change:$root.saveProjecthour}"/>
</td>
<td class="align-center">
<i class="icon fa-check" data-bind="visible:hourtype_id() == 1, click:$root.setHourtype.bind($data,2)"></i>
<i class="icon fa-square-o" data-bind="visible:hourtype_id() != 1, click:$root.setHourtype.bind($data, 1)"></i>
</td>
<td class="align-right">
<span data-bind=" visible: ! inEdit()">
<span data-bind="text:hours"></span>
@@ -55,6 +65,10 @@
data-bind="textInput:hours, visible:inEdit,
event:{change:$root.saveProjecthour,keyup:$root.validateNumber.bind($data, 'hours')}"/>
</td>
<td class="align-right">
<i class="icon fa-euro"></i>
<span data-bind="text:dbo.helpers.numberWithPoints(revenue())"></span>
</td>
<td>
<i class="icon fa-edit pointer" title="wijzig" data-bind="click:$root.editProjecthour"></i>
<i class="icon fa-trash redish pointer" title="verwijder"
@@ -63,6 +77,18 @@
</tr>
</tbody>
<tfoot>
<tr>
<th class="table-cyanish-header" colspan="2">Totaal</th>
<th class="table-cyanish-header">&nbsp;</th>
<th class="table-cyanish-header align-right">
<span data-bind="text:totalHours"></span> uur
</th>
<th class="table-cyanish-header align-right">
<i class="icon fa-euro"></i>
<span data-bind="text:dbo.helpers.numberWithPoints(totalRevenue())"></span>
</th>
<th class="table-cyanish-header">&nbsp;</th>
</tr>
<tr>
<td colspan="5">
<button class="btn btn-primary btn-round btn-sm" data-bind="click:newProjecthour">
+12 -12
View File
@@ -26,10 +26,10 @@
<th class="table-cyanish-header align-right">
prognose(excl)
</th>
<th class="table-cyanish-header">
<th class="table-cyanish-header align-right">
prognose datum
</th>
<th class="table-cyanish-header">
<th class="table-cyanish-header align-right">
btw tarief
</th>
<th class="table-cyanish-header" width="40px">
@@ -54,7 +54,7 @@
<span data-bind="text:invoicedate, visible:! inEdit()"></span>
<input type="text"
class="form-control form-control-sm"
placeholder="start"
placeholder="datum"
data-bind="datepicker:{dateFormat: 'dd-mm-yy' },
value:invoicedate, visible:inEdit,
event:{change:$root.saveInvoice}"/>
@@ -62,7 +62,7 @@
<td class="align-right">
<span data-bind=" visible: ! inEdit()">
<i class="icon fa-euro"></i>
<span data-bind="text:invoiceamount"></span>
<span data-bind="text:dbo.helpers.numberWithPoints(invoiceamount())"></span>
</span>
<input type="text"
class="form-control form-control-sm align-right"
@@ -72,16 +72,16 @@
</td>
<td class="align-right">
<i class="icon fa-euro"></i>
<span data-bind="text:inclBtw"></span>
<span data-bind="text:dbo.helpers.numberWithPoints(inclBtw())"></span>
</td>
<td class="align-right">
<i class="icon fa-euro"></i>
<span data-bind="text:outstanding"></span>
<span data-bind="text:dbo.helpers.numberWithPoints(outstanding())"></span>
</td>
<td class="align-right">
<span data-bind=" visible: ! inEdit()">
<i class="icon fa-euro"></i>
<span data-bind="text:forecastamount"></span>
<span data-bind="text:dbo.helpers.numberWithPoints(forecastamount())"></span>
</span>
<input type="text"
class="form-control form-control-sm align-right"
@@ -89,16 +89,16 @@
data-bind="textInput:forecastamount, visible:inEdit,
event:{change:$root.saveInvoice,keyup:$root.validateNumber.bind($data, 'forecastamount')}"/>
</td>
<td>
<td class="align-right">
<span data-bind="text:forecastdate, visible:! inEdit()"></span>
<input type="text"
class="form-control form-control-sm"
placeholder="start"
placeholder="datum"
data-bind="datepicker:{dateFormat: 'dd-mm-yy' },
value:forecastdate, visible:inEdit,
event:{change:$root.saveInvoice}"/>
</td>
<td>
<td class="align-right">
<span data-bind="visible:! inEdit()">
<span data-bind="text:dbo.helpers.findArrayElement('id', 'vatrate', vat_id(), $root.vats())"></span>
%
@@ -141,7 +141,7 @@
<span data-bind="text:paymentdate, visible:! inEdit()"></span>
<input type="text"
class="form-control form-control-sm"
placeholder="start"
placeholder="datum"
data-bind="datepicker:{dateFormat: 'dd-mm-yy' },
value:paymentdate, visible:inEdit,
event:{change:$root.savePayment}"/>
@@ -149,7 +149,7 @@
<td>
<span data-bind=" visible: ! inEdit()">
<i class="icon fa-euro"></i>
<span data-bind="text:paymentamount"></span>
<span data-bind="text:dbo.helpers.numberWithPoints(paymentamount())"></span>
</span>
<input type="text"
class="form-control form-control-sm align-right"
@@ -16,9 +16,15 @@
<th class="table-cyanish-header">
datum
</th>
<th class="table-cyanish-header">
<th class="table-cyanish-header align-right">
bedrag
</th>
<th class="table-cyanish-header align-right">
betaald
</th>
<th class="table-cyanish-header align-right">
te betalen
</th>
<th class="table-cyanish-header" width="40px">
&nbsp;
</th>
@@ -38,7 +44,7 @@
event:{change:$root.saveProjectcosts}">
</select>
</td>
<td class="align-right">
<td>
<span data-bind=" visible: ! inEdit()">
<span data-bind="text:description"></span>
</span>
@@ -46,7 +52,7 @@
class="form-control form-control-sm align-right"
paceholder="omschrijving"
data-bind="textInput:description, visible:inEdit,
event:{change:$root.saveProjectcosts"/>
event:{change:$root.saveProjectcosts}"/>
</td>
<td>
<span data-bind="text:date, visible:! inEdit()"></span>
@@ -60,7 +66,7 @@
<td class="align-right">
<span data-bind=" visible: ! inEdit()">
<i class="icon fa-euro"></i>
<span data-bind="text:costs"></span>
<span data-bind="text:dbo.helpers.numberWithPoints(costs())"></span>
</span>
<input type="text"
class="form-control form-control-sm align-right"
@@ -68,6 +74,23 @@
data-bind="textInput:costs, visible:inEdit,
event:{change:$root.saveProjectcosts,keyup:$root.validateNumber.bind($data, 'costs')}"/>
</td>
<td class="align-right">
<span data-bind=" visible: ! inEdit()">
<i class="icon fa-euro"></i>
<span data-bind="text:dbo.helpers.numberWithPoints(payed())"></span>
</span>
<input type="text"
class="form-control form-control-sm align-right"
paceholder="bedrag"
data-bind="textInput:payed, visible:inEdit,
event:{change:$root.saveProjectcosts,keyup:$root.validateNumber.bind($data, 'payed')}"/>
</td>
<td class="align-right">
<span>
<i class="icon fa-euro"></i>
<span data-bind="text:dbo.helpers.numberWithPoints(toPay())"></span>
</span>
</td>
<td>
<i class="icon fa-edit pointer" title="wijzig" data-bind="click:$root.editProjectcosts"></i>
<i class="icon fa-trash redish pointer" title="verwijder"
@@ -73,6 +73,14 @@
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<h3>te besteden uren :<span data-bind="text:(totalBudget() - totalHours())"></span></h3>
</div>
<div class="col-md-3">
<h3></h3>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="graph-holder">
@@ -10,10 +10,10 @@
<th class="table-cyanish-header">
naam
</th>
<th class="table-cyanish-header">
<th class="table-cyanish-header align-right">
tarief
</th>
<th class="table-cyanish-header">
<th class="table-cyanish-header align-right">
budget
</th>
<th class="table-cyanish-header" width="40px">
@@ -35,18 +35,18 @@
event:{change:$root.saveProjectemployee},
visible:inEdit"></select>
</td>
<td>
<td class="align-right">
<span data-bind=" visible: ! inEdit()">
<i class="icon fa-euro"></i>
<span data-bind="text:tarif"></span>
</span>
</span class="align-right">
<input type="text"
class="form-control form-control-sm"
paceholder="tarief"
data-bind="textInput:tarif, visible:inEdit,
event:{change:$root.saveProjectemployee,keyup:$root.validateNumber.bind($data, 'tarif')}"/>
</td>
<td>
<td class="align-right">
<span data-bind="visible: ! inEdit()"><span data-bind="text:budget"></span> uur</span>
<input type="text"
class="form-control form-control-sm"
@@ -62,6 +62,13 @@
</tr>
</tbody>
<tfoot>
<tr>
<th class="table-cyanish-header align-right" colspan="2">&nbsp;</th>
<th class="table-cyanish-header align-right">
<span data-bind="text:totalBudget"></span> uur
</th>
<th class="table-cyanish-header align-right"></th>
</tr>
<tr>
<td colspan="6">
<button class="btn btn-primary btn-round btn-sm" data-bind="click:addProjectemployee">
@@ -1,7 +1,7 @@
<div class="panel panel-bordered panel-primary panel-line">
<div class="panel-heading panel-heading-project">
<h3 class="">
offertes
offerte
</h3>
</div>
<div class="panel-body panel-body-project">
@@ -13,10 +13,10 @@
<th class="table-cyanish-header">
start
</th>
<th class="table-cyanish-header">
<th class="table-cyanish-header align-right">
eigen omzet
</th>
<th class="table-cyanish-header">
<th class="table-cyanish-header align-right">
overig omzet
</th>
<th class="table-cyanish-header">
@@ -31,11 +31,11 @@
<td>
<span data-bind="text:startdate"></span>
</td>
<td>
<span data-bind="text:own_revenue"></span>
<td class="align-right">
<span data-bind="text:dbo.helpers.numberWithPoints(own_revenue.toFixed(0))"></span>
</td>
<td>
<span data-bind="text:other_revenue"></span>
<td class="align-right">
<span data-bind="text:dbo.helpers.numberWithPoints(other_revenue.toFixed(0))"></span>
</td>
<!-- <td>-->
<!-- <i class="icon fa-edit pointer" title="wijzig" data-bind="click:$root.editOffer"></i>-->
@@ -44,15 +44,6 @@
<!-- </td>-->
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="5">
<!-- <button class="btn btn-primary btn-round btn-sm" data-bind="click:newOffer">-->
<!-- nieuwe offerte-->
<!-- </button>-->
</td>
</tr>
</tfoot>
</table>
</div>
</div>
+12 -7
View File
@@ -1,7 +1,4 @@
<div class="project-page" id="project-modal" data-bind="fadeVisible:showProject()">
<button class="btn btn-danger" data-bind="click:closeProject" style="position:absolute">
sluit
</button>
<div class="container" style="margin-top:15px;padding-top:15px;">
<div class="nav-tabs-horizontal nav-tabs-animate nav-tab-reverse">
@@ -41,16 +38,24 @@
bestanden en opmerkingen</a>
</li>
</ul>
<div style="position:relative; float:right;">
<h3 style="position:absolute;top:-65px; right:30px; width:350px;">
Projectnummer: <span data-bind="text:projectnumber"></span>
</h3>
<button class="btn btn-danger" data-bind="click:closeProject" style="position:absolute;right:0px;top:-50px">
sluit
</button>
</div>
<div class="tab-content">
<div class="tab-pane animation-slide-top active" id="dashboard">
<?php $this->load->view('modals/partials/_projectdashboard'); ?>
</div>
<div class="tab-pane animation-slide-top" id="financial">
<div class="row" data-bind="fadeVisible:customerID()">
<div class="col-md-6">
<div class="col-md-5">
<?php $this->load->view( 'modals/partials/_projectoffers' ); ?>
</div>
<div class="col-md-6">
<div class="col-md-7">
<?php $this->load->view( 'modals/partials/_projectcosts' ); ?>
</div>
</div>
@@ -62,10 +67,10 @@
</div>
<div class="tab-pane animation-slide-top" id="employees">
<div class="row" data-bind="fadeVisible:customerID()">
<div class="col-md-6" data-bind="fadeVisible:customerID()">
<div class="col-md-5" data-bind="fadeVisible:customerID()">
<?php $this->load->view( 'modals/partials/_projectemployees' ); ?>
</div>
<div class="col-md-6">
<div class="col-md-7">
<?php $this->load->view( 'modals/partials/_hours' ); ?>
</div>
</div>
@@ -0,0 +1,98 @@
<div class="container">
<div class="row">
<div class="col-md-2">
<select class="form-control form-control-sm"
data-bind="options:years,
optionsText:'id',
optionsValue:'id',
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',
value:selectedMonth,
event:{change:refreshEmployeehours}"></select>
</div>
</div>
<br/>
<div class="row">
<div class="col-xl-8">
<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">uren</th>
<th class="table-tealish-header" width="40px">&nbsp;</th>
</tr>
</thead>
<tbody data-bind="foreach:employeehours">
<tr>
<td>
<span data-bind="text:dbo.helpers.findArrayElement('id', 'fullname', employee_id(), $root.employees()),
visible: ! inEdit()"></span>
<select class="form-control form-control-sm"
data-bind="options:$root.employees,
optionsText:'fullname',
optionsValue:'id',
value:employee_id,
optionsCaption: 'selecteer...',
visible:inEdit(),
event:{change:$root.saveEmployeehours}"></select>
</td>
<td>
<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>
<span data-bind="text:dbo.helpers.findArrayElement('id', 'description', hourtype_id(), $root.hourtypes()),
visible: ! inEdit()"></span>
<select class="form-control form-control-sm"
data-bind="options:$root.hourtypes,
optionsText:'description',
optionsValue:'id',
value:hourtype_id,
optionsCaptiuon:'selecteer...',
visible:inEdit(),
event:{change:$root.saveEmployeehours}"></select>
</td>
<td class="align-right">
<span data-bind=" visible: ! inEdit()">
<span data-bind="text:hours"></span>
uur
</span>
<input type="text"
class="form-control form-control-sm align-right"
paceholder="uren"
data-bind="textInput:hours, visible:inEdit,
event:{change:$root.saveEmployeehours,keyup:$root.validateNumber.bind($data, 'hours')}"/>
</td>
<td>
<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>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="3" class="">
<button class="btn btn-primary btn-round btn-sm" data-bind="click:newEmployeehour">
nieuwe uren
</button>
</td>
</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
+5 -5
View File
@@ -32,10 +32,10 @@
<span data-bind="text:enddate"></span>
</td>
<td data-bind="click:$root.selectPoject" class="pointer align-right">
<span data-bind="text:totalOwnrevenue.toFixed(0)"></span>
<span data-bind="text:dbo.helpers.numberWithPoints(totalOwnrevenue.toFixed(0))"></span>
</td>
<td data-bind="click:$root.selectPoject" class="pointer align-right">
<span data-bind="text:totalOtherrevenue.toFixed(0)"></span>
<span data-bind="text:dbo.helpers.numberWithPoints(totalOtherrevenue.toFixed(0))"></span>
</td>
<td>
<i class="icon fa-edit pointer" title="wijzig" data-bind="click:$root.editProject"></i>
@@ -55,9 +55,9 @@
<tfoot>
<tr>
<td colspan="6" class="">
<button class="btn btn-primary btn-round btn-sm" data-bind="click:newProject">
nieuw project
</button>
<!-- <button class="btn btn-primary btn-round btn-sm" data-bind="click:newProject">-->
<!-- nieuw project-->
<!-- </button>-->
</td>
<td colspan="3" class="">
<div class="row form-horizontal">
+3
View File
@@ -67,8 +67,10 @@
<script src="js/lib/modules/beheer/externalsModule.js?version=<?= $this->version ?>"></script>
<script src="js/lib/modules/projects/offersModule.js?version=<?= $this->version ?>"></script>
<script src="js/lib/modules/projects/projectsModule.js?version=<?= $this->version ?>"></script>
<script src="js/lib/modules/projects/employeehoursModule.js?version=<?= $this->version ?>"></script>
<!-- ***********MODALS************* -->
<script src="js/lib/modals/userModal.js?version=<?= $this->version ?>"></script>
<script src="js/lib/modals/customerModal.js?version=<?= $this->version ?>"></script>
<script src="js/lib/modals/externalModal.js?version=<?= $this->version ?>"></script>
@@ -91,6 +93,7 @@
<script src="js/lib/dataservices/documentsDataservice.js"></script>
<script src="js/lib/dataservices/projectsDataservice.js"></script>
<script src="js/lib/dataservices/vatDataservice.js"></script>
<script src="js/lib/dataservices/employeehoursDataservice.js"></script>
<script src="js/lib/services/chartService.js"></script>
+4
View File
@@ -22,6 +22,10 @@
text-align: right;
}
.align-center{
text-align: center;
}
.site-menu-sub > li {
margin-left: 30px;
padding-left: 10px;
@@ -0,0 +1,38 @@
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 31/01/2018
* Time: 20:41
*/
dbo.employeehoursDataService = {
getEmployeehours: function ( $month, $year, callback ) {
$.getJSON( 'index.php/projects/employeehoursController/getEmployeehours/' + $month + '/' + $year )
.done( function ( data ) {
callback( data );
} );
},
getHourtypes: function ( callback ) {
$.getJSON( 'index.php/projects/employeehoursController/getHourtypes' )
.done( function ( data ) {
callback( data );
} );
},
saveEmployeehour: function ( submitDATA, callback ) {
$.post( 'index.php/projects/employeehoursController/saveEmployeehour', submitDATA, 'json' )
.done( function ( data ) {
callback( data );
} );
},
removeEmployeehour: function ( employeehourID, callback ) {
$.getJSON( 'index.php/projects/employeehoursController/removeEmployeehour/' + employeehourID )
.done( function ( data ) {
callback( data );
} )
}
};
+4
View File
@@ -81,5 +81,9 @@ dbo.helpers = {
var newDate = dateParts[2] + '-' + dateParts[1] + '-' + dateParts[0];
return newDate;
},
numberWithPoints :function(myNumber) {
return myNumber.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".");
}
}
+6 -3
View File
@@ -19,6 +19,7 @@ $( function () {
remarks : ko.observable(),
rate : ko.observable(),
kvk_number : ko.observable(),
iban : ko.observable(),
callback : null,
init: function () {
@@ -50,7 +51,8 @@ $( function () {
website : vm.website(),
remarks : vm.remarks(),
rate : vm.rate(),
kvk_number : vm.kvk_number()
kvk_number : vm.kvk_number(),
iban : vm.iban()
}
dbo.externalDataService.saveExternal( submitDATA, function ( data ) {
@@ -97,6 +99,7 @@ $( function () {
vm.remarks( external.remarks || '' );
vm.rate( external.rate || 0 );
vm.kvk_number( external.kvk_number || '' );
vm.iban( external.iban || '' );
},
showExternalModal: function () {
@@ -107,12 +110,12 @@ $( function () {
$( "#external-modal" ).modal( 'hide' );
},
validateNumber : function ( ) {
validateNumber: function () {
var vm = dbo.editExternalModal;
vm.rate( dbo.helpers.validateNumber( vm.rate(), false ) );
}
};
};
dbo.editExternalModal.init();
+2
View File
@@ -80,6 +80,7 @@ $( function () {
modalClass: 'modal-success'
}, function(){
vm.hideOfferModal();
vm.callback();
} );
} else {
tellMe( {
@@ -106,6 +107,7 @@ $( function () {
} );
}else{
vm.hideOfferModal();
vm.callback();
}
} );
},
+96 -22
View File
@@ -27,6 +27,7 @@ $( function () {
projectID : null,
callback : null,
customerID : ko.observable( null ),
projectnumber : ko.observable(),
projectleaderID : ko.observable(),
archive : ko.observable( false ),
startdate : ko.observable( null ),
@@ -105,6 +106,15 @@ $( function () {
} );
},
setHourtype: function ( status ) {
if ( !this.inEdit() ) return;
var vm = dbo.editProjectModal;
this.hourtype_id( status );
vm.saveProjecthour( this );
},
editProjecthour: function () {
var self = this;
var vm = dbo.editProjectModal;
@@ -179,6 +189,7 @@ $( function () {
projectemployee_id: null,
hourdate : null,
hours : 0,
hourtype_id : 1,
inEdit : true
};
@@ -318,8 +329,8 @@ $( function () {
} );
},
saveProjecthour: function () {
var self = this;
saveProjecthour: function ( self = false ) {
if ( !self ) self = this;
if ( !self.projectemployee_id() ) return;
@@ -327,6 +338,7 @@ $( function () {
id : self.id,
projectemployee_id: self.projectemployee_id(),
hourdate : self.hourdate(),
hourtype_id : self.hourtype_id(),
hours : self.hours()
};
@@ -346,7 +358,8 @@ $( function () {
external_id: self.external_id(),
description: self.description(),
date : self.date(),
costs : self.costs()
costs : self.costs(),
payed : self.payed()
};
dbo.projectDataService.saveProjectcost( submitDATA, function ( data ) {
@@ -502,6 +515,7 @@ $( function () {
vm.customerID( data.customer_id );
vm.startdate( dbo.helpers.mysql2date( data.startdate ) );
vm.enddate( dbo.helpers.mysql2date( data.enddate ) );
vm.projectnumber( data.projectnumber );
vm.projectEmployees.removeAll();
vm.projecthours.removeAll();
@@ -522,6 +536,7 @@ $( function () {
} );
vm.offers.removeAll();
$.each( data.offers, function ( i, p ) {
vm.offers.push( new dbo.offersService.Offer( p ) );
} );
@@ -533,8 +548,8 @@ $( function () {
vm.busy = false;
dbo.charts.drawHoursVsBudget(340, 230, 'hours-vs-budget');
dbo.charts.drawInvoicesVsPayed(36000, 24000, 11000, 'invoice-vs-payed');
dbo.charts.drawHoursVsBudget( 340, 230, 'hours-vs-budget' );
dbo.charts.drawInvoicesVsPayed( 36000, 24000, 11000, 'invoice-vs-payed' );
} );
},
@@ -550,25 +565,50 @@ $( function () {
},
Projecthour: function ( data, fullname ) {
var self = this;
var vm = dbo.editProjectModal;
var inEdit = sessionStorage.Projecthour == data.id;
if ( !inEdit ) inEdit = data.inEdit || false;
this.id = data.id;
this.fullname = ko.observable( fullname );
this.projectemployee_id = ko.observable( data.projectemployee_id );
this.hourdate = ko.observable( dbo.helpers.mysql2date( data.hourdate ) );
this.hours = ko.observable( data.hours );
this.inEdit = ko.observable( inEdit );
self.id = data.id;
self.fullname = ko.observable( fullname );
self.projectemployee_id = ko.observable( data.projectemployee_id );
self.hourdate = ko.observable( dbo.helpers.mysql2date( data.hourdate ) );
self.hours = ko.observable( data.hours );
self.hourtype_id = ko.observable( data.hourtype_id );
self.inEdit = ko.observable( inEdit );
self.revenue = ko.pureComputed( function () {
if ( !self.projectemployee_id() ) return 0;
var tarif = dbo.helpers.findArrayElement( 'id', 'tarif', self.projectemployee_id(), vm.projectEmployees() )();
if ( isNaN( tarif ) ) return 0;
if ( isNaN( self.hours() ) ) return 0;
if ( self.hourtype_id() != 1 ) return 0;
return (tarif * self.hours()).toFixed( 0 );
} );
},
Projectcost: function ( data ) {
this.id = data.id;
this.external_id = ko.observable( data.external_id );
this.contactperson = ko.observable( data.external ? data.external.contactperson : '' );
this.description = ko.observable( data.description );
this.date = ko.observable( dbo.helpers.mysql2date( data.date ) );
this.costs = ko.observable( data.costs );
this.inEdit = ko.observable( data.inEdit || false );
var self = this;
self.id = data.id;
self.external_id = ko.observable( data.external_id );
self.contactperson = ko.observable( data.external ? data.external.contactperson : '' );
self.description = ko.observable( data.description );
self.date = ko.observable( dbo.helpers.mysql2date( data.date ) );
self.costs = ko.observable( data.costs );
self.payed = ko.observable( data.payed );
self.inEdit = ko.observable( data.inEdit || false );
this.toPay = ko.pureComputed( function () {
if ( isNaN( self.costs() ) ) return 0;
if ( isNaN( self.payed() ) ) return 0;
return self.costs() - self.payed();
} )
},
Invoice: function ( data ) {
@@ -581,8 +621,8 @@ $( function () {
self.project_id = ko.observable( data.project_id );
self.invoicenumber = ko.observable( data.invoicenumber );
self.invoicedate = ko.observable( dbo.helpers.mysql2date( data.invoicedate ) );
self.invoiceamount = ko.observable( data.invoiceamount.toFixed( 2 ) );
self.forecastamount = ko.observable( data.forecastamount.toFixed( 2 ) );
self.invoiceamount = ko.observable( data.invoiceamount.toFixed( 0 ) );
self.forecastamount = ko.observable( data.forecastamount.toFixed( 0 ) );
self.forecastdate = ko.observable( dbo.helpers.mysql2date( data.forecastdate ) );
self.vat_id = ko.observable( data.vat_id );
@@ -592,7 +632,7 @@ $( function () {
if ( !self.vat_id() ) return self.invoiceamount();
return (Number( self.invoiceamount() ) + (self.invoiceamount() *
(dbo.helpers.findArrayElement( 'id', 'vatrate', self.vat_id(), this.vats() ) / 100))).toFixed( 2 );
(dbo.helpers.findArrayElement( 'id', 'vatrate', self.vat_id(), this.vats() ) / 100))).toFixed( 0 );
}, dbo.editProjectModal );
self.showPayments = ko.observable( data.showPayments || false );
@@ -608,7 +648,7 @@ $( function () {
$.each( self.payments(), function ( i, p ) {
payed += Number( p.paymentamount() );
} );
return (self.inclBtw() - payed).toFixed( 2 );
return (self.inclBtw() - payed).toFixed( 0 );
} );
},
@@ -624,6 +664,40 @@ $( function () {
}
};
dbo.editProjectModal.totalHours = ko.pureComputed( function () {
var vm = dbo.editProjectModal;
var totalHours = 0
$.each( vm.projecthours(), function ( i, p ) {
if ( p.hourtype_id() == 1 ) {
totalHours += Number( p.hours() );
}
} );
return totalHours;
} );
dbo.editProjectModal.totalRevenue = ko.pureComputed( function () {
var vm = dbo.editProjectModal;
var totalRevenue = 0
$.each( vm.projecthours(), function ( i, p ) {
if ( p.hourtype_id() == 1 ) {
totalRevenue += Number( p.revenue() );
}
} );
return totalRevenue.toFixed( 0 );
} );
dbo.editProjectModal.totalBudget = ko.pureComputed( function () {
var vm = dbo.editProjectModal;
var totalBudget = 0;
$.each( vm.projectEmployees(), function ( i, p ) {
totalBudget += Number( p.budget() );
} );
return totalBudget;
} );
ko.applyBindings( dbo.editProjectModal, document.getElementById( 'project-modal' ) );
} );
@@ -0,0 +1,180 @@
/**
* Created by Pensare Software.
* User: Theo Weijmer
* Date: 05/01/2018
* Time: 15:54
*/
dbo.employeehoursInit = function () {
if ( dbo.employeehoursModel !== undefined ) {
dbo.employeehoursModel.refreshHours();
} else {
dbo.employeehoursModel = {
employeehours: ko.observableArray( [] ),
archive : ko.observable( false ),
months : ko.observableArray( [] ),
years : ko.observableArray( [] ),
hourtypes : ko.observableArray( [] ),
employees : ko.observableArray( [] ),
selectedYear : ko.observable(),
selectedMonth: ko.observable(),
busy : false,
init: function () {
var vm = dbo.employeehoursModel;
vm.createMonths();
vm.createYears();
var d = new Date();
vm.selectedMonth( d.getMonth() + 1 );
vm.selectedYear( d.getFullYear() );
dbo.employeehoursDataService.getHourtypes( function ( data ) {
vm.hourtypes( data );
dbo.userDataService.getAllUsers( 'F', function ( data ) {
vm.employees( data );
vm.refreshEmployeehours();
} );
} );
},
newEmployeehour: function () {
var vm = dbo.employeehoursModel;
var employeehour = {
id : 0,
employee_id: null,
hourdate : null,
hourtype_id: null,
hours : 0,
inEdit : true
};
vm.employeehours.push( new vm.Employeehour( employeehour ) );
},
toggleArchive: function () {
var vm = dbo.employeeemployeehoursModel;
vm.archive( !vm.archive() );
vm.refreshHours();
},
saveEmployeehours: function () {
var self = this;
if ( !self.employee_id() ) return;
if ( !self.hourtype_id() ) return;
if ( !self.hourdate() ) return;
var submitDATA = {
id : self.id,
employee_id: self.employee_id(),
hourdate : self.hourdate(),
hourtype_id: self.hourtype_id(),
hours : self.hours()
};
dbo.employeehoursDataService.saveEmployeehour( submitDATA, function ( data ) {
self.id = data.employeehourID;
} );
},
editEmployeehour: function () {
this.inEdit( !this.inEdit() );
},
removeEmployeehour: function () {
var vm = dbo.employeehoursModel;
var self = this;
tellMe( {
title : 'verwijderen uren',
message : 'weet u zeker dat u deze uren wilt verwijderen, dit kan niet ongedaan worden gemaakt',
notify : true,
noText : 'nee verwijder de uren niet',
yesText : 'ja verwijder de uren',
modalClass: 'modal-warning'
}, function ( response ) {
if ( response ) {
dbo.employeehoursDataService.removeEmployeehour( self.id, function ( data ) {
if ( data.result ) {
vm.refreshEmployeehours();
} else {
tellMe( {
title : 'fout bij verwijderen uren',
message : 'de uren konden niet worden verwijderd',
modalClass: 'modal-danger'
} );
}
} );
}
} );
},
createMonths: function () {
var vm = dbo.employeehoursModel;
var months = [
{id: 1, monthName: 'januari'},
{id: 2, monthName: 'februari'},
{id: 3, monthName: 'maart'},
{id: 4, monthName: 'april'},
{id: 5, monthName: 'mei'},
{id: 6, monthName: 'juni'},
{id: 7, monthName: 'juli'},
{id: 8, monthName: 'augustus'},
{id: 9, monthName: 'september'},
{id: 10, monthName: 'oktober'},
{id: 11, monthName: 'november'},
{id: 12, monthName: 'december'},
]
vm.months( months );
},
createYears: function () {
var vm = dbo.employeehoursModel;
var years = [{id: 2015}, {id: 2016}, {id: 2017}, {id: 2018}];
vm.years( years );
},
refreshEmployeehours: function () {
var vm = dbo.employeehoursModel;
vm.employeehours.removeAll();
dbo.employeehoursDataService.getEmployeehours( vm.selectedMonth(), vm.selectedYear(), function ( data ) {
$.each( data, function ( i, p ) {
vm.employeehours.push( new vm.Employeehour( p ) );
} );
} );
},
validateNumber: function ( field ) {
this[field]( dbo.helpers.validateNumber( this[field](), true ) );
},
Employeehour: function ( data ) {
var vm = dbo.employeehoursModel;
this.id = data.id;
this.employee_id = ko.observable( data.employee_id );
this.hourtype_id = ko.observable( data.hourtype_id );
this.hourdate = ko.observable( data.hourdate );
this.hours = ko.observable( data.hours );
this.inEdit = ko.observable( data.inEdit || false );
}
};
dbo.employeehoursModel.init();
ko.applyBindings( dbo.employeehoursModel, document.getElementById( 'EMPLOYEEHOURS' ) );
}
}
@@ -9,7 +9,7 @@
dbo.projectsInit = function () {
if ( dbo.projectsModel !== undefined ) {
dbo.projectsModel.refreshProjects();
} else {
dbo.projectsModel = {
@@ -129,10 +129,9 @@ dbo.projectsInit = function () {
self.revenues = ko.observableArray( [] );
$.each( data.offers, function ( i, p ) {
if ( p.accepteddate ) {
self.totalOwnrevenue += p.totalOwnrevenue;
self.totalOtherrevenue += p.totalOtherrevenue;
self.totalOwnrevenue += Number( p.own_revenue );
self.totalOtherrevenue += Number( p.other_revenue );
}
self.revenues.push( new vm.Revenue( p ) );
} );
},