This commit is contained in:
2018-04-24 08:31:00 +02:00
parent e49fa05a9a
commit 6bc0b37f06
4 changed files with 55 additions and 34 deletions
@@ -5,7 +5,7 @@
* Date: 21/04/2018 * Date: 21/04/2018
* Time: 20:08 * Time: 20:08
*/ */
include_once('../application/models/eloquent/Employeetarget.php'); //include_once('../application/models/eloquent/Employeetarget.php');
@@ -24,7 +24,7 @@ class EmployeeTargetController extends MY_Controller {
public function getEmployeeTargets( $employeeID ) public function getEmployeeTargets( $employeeID )
{ {
$employeeTargets = Employeetarget::whereUserId( $employeeID ) $employeeTargets = Employeetarget::whereUserId( $employeeID )
->orderBy( 'startdate' ) ->orderBy( 'id' )
->get(); ->get();
$this->json( $employeeTargets ); $this->json( $employeeTargets );
-5
View File
@@ -56,18 +56,13 @@
</div> </div>
<?php endforeach; ?> <?php endforeach; ?>
<?php endif; ?> <?php endif; ?>
<?php endforeach; ?> <?php endforeach; ?>
</div> </div>
</div> </div>
<?php $this->load->view( 'partials/_js' ); ?> <?php $this->load->view( 'partials/_js' ); ?>
<!-- jQuery CDN --> <!-- jQuery CDN -->
<!-- Bootstrap Js CDN --> <!-- Bootstrap Js CDN -->
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function () { $(document).ready(function () {
$('#sidebarCollapse').on('click', function () { $('#sidebarCollapse').on('click', function () {
@@ -14,29 +14,56 @@
<table class="table table-condensed"> <table class="table table-condensed">
<thead> <thead>
<tr> <tr>
<th>start</th> <th colspan="2">start</th>
<th>eind</th> <th colspan="2">eind</th>
<th colspan="2">&nbsp;</th>
</tr>
<tr>
<th>maand</th>
<th>jaar</th>
<th>maand</th>
<th>jaar</th>
<th>target per maand</th> <th>target per maand</th>
<th>&nbsp;</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<!-- ko foreach:employeeTargets --> <!-- ko foreach:employeeTargets -->
<tr> <tr>
<td> <td>
<input type="text" <select data-bind="options:years,
placeholder="startdatum" optionsText:'year',
class="form-control" optionsValue:'year',
readonly value:startyear,
data-bind="datepicker:{dateFormat: 'dd-mm-yy' }, disable: ! changeable()"
value:startdate"> class="form-control">
</select>
</td> </td>
<td> <td>
<input type="text" <select data-bind="options:months,
placeholder="einddatum" optionsText:'month',
class="form-control" optionsValue:'month_id',
readonly value:startmonth,
data-bind="datepicker:{dateFormat: 'dd-mm-yy' }, disable: ! changeable()"
value:enddate"> class="form-control">
</select>
</td>
<td>
<select data-bind="options:years,
optionsText:'year',
optionsValue:'year',
value:endyear,
disable: ! changeable()"
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> <td>
<input type="text" <input type="text"
@@ -54,7 +81,7 @@
</tbody> </tbody>
<tfoot> <tfoot>
<tr> <tr>
<th colspan="4"> <th colspan="6">
<i class="icon fa-plus-square-o pull-right pointer" <i class="icon fa-plus-square-o pull-right pointer"
data-bind="click:addEmployeeTarget"></i> data-bind="click:addEmployeeTarget"></i>
</th> </th>
+11 -12
View File
@@ -54,27 +54,26 @@ $( function () {
dbo.employeeTargetDataService.getEmployeeTargets( vm.employeeID, function ( data ) { dbo.employeeTargetDataService.getEmployeeTargets( vm.employeeID, function ( data ) {
vm.employeeTargets.removeAll(); vm.employeeTargets.removeAll();
var targetLength = data.length
var i=0;
_.each( data, function ( p ) { _.each( data, function ( p ) {
console.log( 'jhaVCGHJkq' ); vm.employeeTargets.push( new vm.Employeetarget( p, targetLength, i ) );
vm.employeeTargets.push( new Employeetarget( p ) ); i++;
} ); } );
} ); } );
}, },
Employeetarget: function ( data ) { Employeetarget: function ( data, targetLength, i ) {
var self = this; var self = this;
self.id = data.id; self.id = data.id;
self.startdate = ko.observable( data.startdate ); self.startyear = ko.observable( data.startyear );
self.enddate = ko.observable( data.enddate ); self.startmonth = ko.observable( data.startmonth );
self.endyear = ko.observable( data.endyear );
self.endmonth = ko.observable( data.endmonth );
self.target = ko.observable( data.target ); self.target = ko.observable( data.target );
self.validTarget = ko.pureComputed( function () { self.changeAble = ko.pureComputed( function () {
if ( !self.startdate() ) return false; if(i == (targetLength - 1))
console.log( 1 );
if ( self.target() == 0 ) return;
console.log( 2 );
if ( ! Number.isInteger( self.target() ) ) return false;
console.log( 3 );
return true; return true;
} ); } );