Wijzigingen nav opmerking Peter 24-12-2018

This commit is contained in:
2019-01-02 16:57:41 +01:00
parent 9569522c83
commit efcd9f2c09
19 changed files with 201 additions and 44 deletions
@@ -68,11 +68,19 @@ class EmployeeHoursController extends MY_Controller {
$employeehourID = Projecthour::saveProjecthour( $employeehourID, $data );
}
elseif ( $hourType == 'OFFERS' )
{
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] );
}
@@ -27,9 +27,15 @@ class OffersController extends MY_Controller {
}
public function getAllOffers( $projectID, $archive = 'F' )
public function getAllOffers()
{
$offers = Offer::getAllOffers( $projectID, $archive );
$projectID = $this->clean_input( 'projectID' );
$archive = $this->clean_input( 'archive' );
$search = $this->clean_input( 'search' );
$order = $this->clean_input( 'order' );
$direction = $this->clean_input( 'direction' );
$offers = Offer::getAllOffers( $projectID, $archive, $search, $order, $direction );
$this->json( $offers );
}
@@ -27,9 +27,14 @@ class ProjectsController extends MY_Controller {
}
public function getAllProjects( $archive = 'F' )
public function getAllProjects( )
{
$projects = Project::getAllProjects( $archive );
$archive = $this->clean_input( 'archive' );
$search = $this->clean_input( 'search' );
$order = $this->clean_input( 'order' );
$direction = $this->clean_input( 'direction' );
$projects = Project::getAllProjects( $archive, $search, $order, $direction );
$this->json( $projects );
}
@@ -360,3 +365,5 @@ class ProjectsController extends MY_Controller {
}
}
+1 -1
View File
@@ -16,7 +16,7 @@ class MY_Controller extends CI_Controller {
{
parent::__construct();
$this->version = '0.02.01';
$this->version = '1.00.00';
$this->load->library( 'beheer/session/RetrieveUserSession' );
@@ -56,7 +56,7 @@ class MonthForecast {
private function setInitialsForecastMonths()
{
for ( $i = 1; $i <= 12; $i ++ )
for ( $i = 0; $i <= 12; $i ++ )
{
$this->forecastMonths[ $i ] = ['forecastamount' => 0];
}
+7 -4
View File
@@ -26,15 +26,18 @@ class Offer extends BaseModel {
return $this->belongsTo( 'Customer' );
}
public static function getAllOffers( $projectID, $archive = 'F' )
public static function getAllOffers( $projectID, $archive = 'F', $search, $order, $direction )
{
$offers = Offer::orderBy( 'startdate' )
$offers = Offer::selectRAW('offers.*')
->join('customers AS CUS', 'CUS.id', '=', 'offers.customer_id')
->with( 'customer' )
->with( 'project' );
->with( 'project' )
->where('offernumber', 'LIKE', "%{$search}%")
->orderBy($order, $direction);
if ( $projectID ) $offers = $offers->whereProjectId( $projectID );
if ( $archive == 'F' ) $offers = $offers->whereArchive( 'F' );
if ( $archive == 'F' ) $offers = $offers->where( 'offers.archive', '=', 'F' );
$offers = $offers->get();
+8 -2
View File
@@ -61,11 +61,17 @@ class Project extends BaseModel {
return $this->belongsTo( 'Customer' );
}
public static function getAllProjects( $archive = 'F' )
public static function getAllProjects( $archive, $search, $order, $direction )
{
$projects = Project::getBaseProject();
if ( $archive == 'F' ) $projects = $projects->whereArchive( 'F' );
$projects = $projects->selectRaw('projects.*')
->join('customers AS CUS', 'CUS.id', '=', 'projects.customer_id')
->join('users AS USR', 'USR.id', '=', 'projects.projectleader_id')
->where('projects.projectnumber', 'LIKE', "%{$search}%")
->orderBy($order, $direction);
if ( $archive == 'F' ) $projects = $projects->where( 'projects.archive', '=', 'F' );
$projects = $projects->get();
+4 -1
View File
@@ -54,7 +54,10 @@ class User extends BaseModel {
{
$usersWithProjects =
User::selectRaw( "users.id, CONCAT(users.firstname, ' ', users.middlename, ' ', users.lastname) AS fullname" )
->with( 'projectemployees.project' )
->with( [
'projectemployees.project' => function ( $q ) {
$q->whereArchive( 'F' );
}] )
->get();
return $usersWithProjects;
@@ -35,7 +35,10 @@ class EmployeehoursMonthly {
USR.id AS employee_id,
hours,
DATE_FORMAT(hourdate, '%d-%m-%Y') AS hourdate,
PEM.project_id
CASE
WHEN hourtype_id = 3 THEN offer_id
ELSE PEM.project_id
END AS project_id
FROM projecthours PRH
JOIN projectemployees PEM
ON PEM.id = PRH.projectemployee_id
@@ -84,7 +84,7 @@
event:{change:$root.saveEmployeehours}"></select>
<!-- /ko -->
<!-- ko if: hourType() == 'OFFERS' -->
<span data-bind="text:dbo.helpers.findArrayElement('projectID', 'projectname', projectID(), projects()),
<span data-bind="text:dbo.helpers.findArrayElement('id', 'offername', projectID(), $root.offersWithoutProject()),
visible: ! inEdit()"></span>
<select class="form-control form-control-sm"
data-bind="options:$root.offersWithoutProject,
+28 -9
View File
@@ -1,14 +1,33 @@
<div class="row">
<div class="col-xs-6">
<div class="form-group">
<div class="input-group">
<input type="text"
data-bind="textInput:search,event:{keyup:searchOffers}"
class="form-control"
name=""
placeholder="Zoek...">
<span class="input-group-btn">
<button type="text"
class="btn btn-primary">
<i class="icon wb-search" aria-hidden="true"></i>
</button>
</span>
</div>
</div>
</div>
</div>
<table class="table table-sm">
<thead>
<tr>
<th class="table-tealish-header">nummer</th>
<th class="table-tealish-header">klant</th>
<th class="table-tealish-header">project</th>
<th class="table-tealish-header">datum</th>
<th class="table-tealish-header">kans</th>
<th class="table-tealish-header">geaccepteerd</th>
<th class="table-tealish-header">afgewezen</th>
<th class="table-tealish-header">&nbsp;</th>
<th class="table-tealish-header pointer" data-bind="click:directionOrderOffers.bind($data, 'offernumber')">nummer</th>
<th class="table-tealish-header pointer" data-bind="click:directionOrderOffers.bind($data, 'CUS.name')">klant</th>
<th class="table-tealish-header pointer" data-bind="click:directionOrderOffers.bind($data, 'offername')">offertenaam</th>
<th class="table-tealish-header pointer" data-bind="click:directionOrderOffers.bind($data, 'startdate')">datum</th>
<th class="table-tealish-header pointer" data-bind="click:directionOrderOffers.bind($data, 'acceptance_chance')">kans</th>
<th class="table-tealish-header pointer" data-bind="click:directionOrderOffers.bind($data, 'accepteddate')">geaccepteerd</th>
<th class="table-tealish-header pointer" data-bind="click:directionOrderOffers.bind($data, 'rejectdate')">afgewezen</th>
<th class="table-tealish-header pointer">&nbsp;</th>
</tr>
</thead>
<tbody data-bind="foreach:offers">
@@ -20,7 +39,7 @@
<span data-bind="text:customerName"></span>
</td>
<td data-bind="click:$root.selectOffer" class="pointer">
<span data-bind="text:projectNumber"></span>
<span data-bind="text:offername"></span>
</td>
<td data-bind="click:$root.selectOffer" class="pointer">
<span data-bind="text:startdate"></span>
+27 -4
View File
@@ -1,10 +1,33 @@
<div class="row">
<div class="col-xs-6">
<div class="form-group">
<div class="input-group">
<input type="text"
data-bind="textInput:search,event:{keyup:searchProjects}"
class="form-control"
name=""
placeholder="Zoek...">
<span class="input-group-btn">
<button type="text"
class="btn btn-primary">
<i class="icon wb-search" aria-hidden="true"></i>
</button>
</span>
</div>
</div>
</div>
</div>
<table class="table table-sm">
<thead>
<tr>
<th class="table-tealish-header">nummer</th>
<th class="table-tealish-header">projectleider</th>
<th class="table-tealish-header">klant</th>
<th class="table-tealish-header">start</th>
<th class="table-tealish-header pointer"
data-bind="click:directionOrderProjects.bind($data, 'projectnumber')">nummer</th>
<th class="table-tealish-header pointer"
data-bind="click:directionOrderProjects.bind($data, 'USR.firstname')">projectleider</th>
<th class="table-tealish-header pointer"
data-bind="click:directionOrderProjects.bind($data, 'CUS.name')">klant</th>
<th class="table-tealish-header pointer"
data-bind="click:directionOrderProjects.bind($data, 'startdate')">start</th>
<th class="table-tealish-header align-right">eigen tarief omzet</th>
<th class="table-tealish-header align-right">overige kosten</th>
<th class="table-tealish-header align-right">Kosten derden</th>
@@ -7,8 +7,8 @@
dbo.offerDataService = {
getAllOffers: function ( projectID, archive = 'F', callback ) {
$.getJSON( 'index.php/projects/offersController/getAllOffers/' + projectID + '/' + archive )
getAllOffers: function ( offersObject, callback ) {
$.post( 'index.php/projects/offersController/getAllOffers', offersObject, 'json' )
.done( function ( data ) {
callback( data );
} );
@@ -7,8 +7,8 @@
dbo.projectDataService = {
getAllProjects: function ( archive = 'F', callback ) {
$.getJSON( 'index.php/projects/projectsController/getAllProjects/' + archive )
getAllProjects: function ( projectsObject, callback ) {
$.post( 'index.php/projects/projectsController/getAllProjects', projectsObject, 'json' )
.done( function ( data ) {
callback( data );
} );
+4 -4
View File
@@ -56,10 +56,10 @@ dbo.helpers = {
},
findArrayElement: function ( toFind, element, value, array ) {
// console.log( toFind ); // het element in de array
// console.log( element );
// console.log( value );
// console.log( array );
console.log( toFind ); // het element in de array
console.log( element );
console.log( value );
console.log( array );
if ( !Array.isArray( array ) ) return null;
var foundValue = null
@@ -182,12 +182,12 @@ dbo.employeehoursInit = function () {
self.projecten = ko.observableArray( [] );
_.each( data.projectemployees, function ( p ) {
self.projecten.push( new vm.Project( p ) );
} );
_.each( vm.offersWithoutProject(), function ( p ) {
console.log( p );
self.projecten.push( new vm.Offer( p, self.id ) );
if ( p.project )
self.projecten.push( new vm.Project( p ) );
} );
// _.each( vm.offersWithoutProject(), function ( p ) {
// self.projecten.push( new vm.Offer( p, self.id ) );
// } );
},
Project: function ( data ) {
@@ -7,6 +7,7 @@
dbo.offersInit = function () {
var timeout;
if ( dbo.offersModel !== undefined ) {
@@ -21,6 +22,9 @@ dbo.offersInit = function () {
documents : ko.observableArray( [] ),
selectedRowID: ko.observable(),
projectID : 0,
search : ko.observable(''),
order : ko.observable('offernumber'),
direction : ko.observable(),
init: function () {
var service = dbo.offersService;
@@ -29,6 +33,23 @@ dbo.offersInit = function () {
service.refreshOffers();
},
searchOffers: function () {
var service = dbo.offersService;
if ( timeout ) {
clearTimeout( timeout );
timeout = null;
}
timeout = setTimeout( function () {
service.refreshOffers();
}, 700 );
},
directionOrderOffers : function(field){
var service = dbo.offersService;
service.directionOrderOffers(field);
},
newOffer: function () {
var service = dbo.offersService;
service.vm = dbo.offersModel;
@@ -7,6 +7,7 @@
dbo.projectsInit = function () {
var timeout;
if ( dbo.projectsModel !== undefined ) {
dbo.projectsModel.refreshProjects();
@@ -18,6 +19,9 @@ dbo.projectsInit = function () {
archive : ko.observable( false ),
selectedRowID: ko.observable(),
busy : false,
search : ko.observable(),
order : ko.observable( 'projectnumber' ),
direction : ko.observable(),
init: function () {
var vm = dbo.projectsModel;
@@ -25,6 +29,31 @@ dbo.projectsInit = function () {
vm.refreshProjects();
},
searchProjects: function () {
var vm = dbo.projectsModel;
if ( timeout ) {
clearTimeout( timeout );
timeout = null;
}
timeout = setTimeout( function () {
vm.refreshProjects();
}, 700 );
},
directionOrderProjects: function ( field ) {
var vm = dbo.projectsModel;
if ( field == vm.order() ) {
vm.direction( !vm.direction() );
} else {
vm.direction( true );
}
vm.order( field );
vm.refreshProjects();
},
newProject: function () {
var vm = dbo.projectsModel;
dbo.editProjectModal.addProject( function () {
@@ -103,8 +132,14 @@ dbo.projectsInit = function () {
refreshProjects: function () {
var vm = dbo.projectsModel;
var projectsObject = {
archive : vm.archive() ? 'T' : 'F',
search : vm.search(),
order : vm.order(),
direction: vm.direction() ? 'ASC' : 'DESC'
}
dbo.projectDataService.getAllProjects( vm.archive() ? 'T' : 'F', function ( data ) {
dbo.projectDataService.getAllProjects( projectsObject, function ( data ) {
vm.projects.removeAll();
$.each( data, function ( i, p ) {
vm.projects.push( new vm.Project( p ) );
+24 -1
View File
@@ -78,11 +78,34 @@ dbo.offersService = {
} );
},
directionOrderOffers: function ( field ) {
var vm = dbo.offersModel;
var self = dbo.offersService;
if ( field == vm.order() ) {
vm.direction( !vm.direction() );
} else {
vm.direction( true );
}
vm.order( field );
self.refreshOffers();
},
refreshOffers: function () {
var vm = dbo.offersService.vm;
var self = dbo.offersService;
dbo.offerDataService.getAllOffers( vm.projectID , vm.archive() ? 'T' : 'F', function ( data ) {
var offersObject = {
projectID: vm.projectID,
archive : vm.archive() ? 'T' : 'F',
search : vm.search(),
order : vm.order(),
direction: vm.direction() ? 'ASC' : 'DESC'
}
dbo.offerDataService.getAllOffers( offersObject, function ( data ) {
vm.offers.removeAll();
$.each( data, function ( i, p ) {
vm.offers.push( new self.Offer( p ) );