Diversen opmerkingen Peter (23-08-2019)
This commit is contained in:
@@ -53,6 +53,13 @@ class usersController extends MY_Controller {
|
|||||||
$this->json( $usersWithProjects );
|
$this->json( $usersWithProjects );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getUserActiveProjects($userID)
|
||||||
|
{
|
||||||
|
$userActiveProjects = User::getUserActiveProjects($userID);
|
||||||
|
|
||||||
|
$this->json( $userActiveProjects );
|
||||||
|
}
|
||||||
|
|
||||||
public function getUniqueprojectEmployees()
|
public function getUniqueprojectEmployees()
|
||||||
{
|
{
|
||||||
$projectEmployees = User::getUniqueProjectUsers();
|
$projectEmployees = User::getUniqueProjectUsers();
|
||||||
|
|||||||
@@ -133,6 +133,8 @@ class ProjectsController extends MY_Controller {
|
|||||||
|
|
||||||
$projectID = Project::saveProject( $projectID, $project );
|
$projectID = Project::saveProject( $projectID, $project );
|
||||||
|
|
||||||
|
Offer::syncProjectname( $projectID );
|
||||||
|
|
||||||
$this->json( ['success' => TRUE, 'projectID' => $projectID] );
|
$this->json( ['success' => TRUE, 'projectID' => $projectID] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class MY_Controller extends CI_Controller {
|
|||||||
{
|
{
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
|
|
||||||
$this->version = '1.00.06';
|
$this->version = '1.00.10';
|
||||||
|
|
||||||
$this->load->library( 'beheer/session/RetrieveUserSession' );
|
$this->load->library( 'beheer/session/RetrieveUserSession' );
|
||||||
|
|
||||||
|
|||||||
@@ -28,12 +28,12 @@ class Offer extends BaseModel {
|
|||||||
|
|
||||||
public static function getAllOffers( $projectID, $archive = 'F', $search, $order, $direction )
|
public static function getAllOffers( $projectID, $archive = 'F', $search, $order, $direction )
|
||||||
{
|
{
|
||||||
$offers = Offer::selectRAW('offers.*')
|
$offers = Offer::selectRAW( 'offers.*' )
|
||||||
->join('customers AS CUS', 'CUS.id', '=', 'offers.customer_id')
|
->join( 'customers AS CUS', 'CUS.id', '=', 'offers.customer_id' )
|
||||||
->with( 'customer' )
|
->with( 'customer' )
|
||||||
->with( 'project' )
|
->with( 'project' )
|
||||||
->where('offernumber', 'LIKE', "%{$search}%")
|
->where( 'offernumber', 'LIKE', "%{$search}%" )
|
||||||
->orderBy($order, $direction);
|
->orderBy( $order, $direction );
|
||||||
|
|
||||||
if ( $projectID ) $offers = $offers->whereProjectId( $projectID );
|
if ( $projectID ) $offers = $offers->whereProjectId( $projectID );
|
||||||
|
|
||||||
@@ -44,12 +44,12 @@ class Offer extends BaseModel {
|
|||||||
return $offers;
|
return $offers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getOffersWithoutProject( )
|
public static function getOffersWithoutProject()
|
||||||
{
|
{
|
||||||
$offersWithoutProject = Offer::orderBy('startdate')
|
$offersWithoutProject = Offer::orderBy( 'startdate' )
|
||||||
// ->whereNull('rejectdate')
|
// ->whereNull('rejectdate')
|
||||||
// ->whereNull('project_id')
|
// ->whereNull('project_id')
|
||||||
->whereArchive('F')
|
->whereArchive( 'F' )
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
return $offersWithoutProject;
|
return $offersWithoutProject;
|
||||||
@@ -72,11 +72,25 @@ class Offer extends BaseModel {
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Offer::whereId( $offerID )->update( $offer );
|
Offer::whereId( $offerID )->update( $offer );
|
||||||
|
|
||||||
|
$offer = self::find( $offerID );
|
||||||
|
|
||||||
|
if ( ! is_null( $offer->project_id ) ) Project::syncOffername( $offer );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $offerID;
|
return $offerID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function syncProjectname( $projectID )
|
||||||
|
{
|
||||||
|
$project = Project::find( $projectID );
|
||||||
|
|
||||||
|
$offer = self::find( $projectID );
|
||||||
|
|
||||||
|
$offer->offername = $project->projectname;
|
||||||
|
$offer->save();
|
||||||
|
}
|
||||||
|
|
||||||
public static function removeOffer( $offerID )
|
public static function removeOffer( $offerID )
|
||||||
{
|
{
|
||||||
Offer::whereId( $offerID )->delete();
|
Offer::whereId( $offerID )->delete();
|
||||||
|
|||||||
@@ -96,7 +96,7 @@ class Project extends BaseModel {
|
|||||||
Project::whereId( $projectID )->delete();
|
Project::whereId( $projectID )->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getActiveProjects($archive = 'T')
|
public static function getActiveProjects( $archive = 'T' )
|
||||||
{
|
{
|
||||||
$projects = Project::selectRaw( "projects.id, YEAR(projects.startdate) AS instroom, YEAR(projects.enddate) AS uitstroom, projectnumber, current_financial_year,
|
$projects = Project::selectRaw( "projects.id, YEAR(projects.startdate) AS instroom, YEAR(projects.enddate) AS uitstroom, projectnumber, current_financial_year,
|
||||||
projectname, CUS.name, OFF.own_revenue, OFF.other_revenue" )
|
projectname, CUS.name, OFF.own_revenue, OFF.other_revenue" )
|
||||||
@@ -106,7 +106,7 @@ class Project extends BaseModel {
|
|||||||
->groupBy( 'OFF.own_revenue' )
|
->groupBy( 'OFF.own_revenue' )
|
||||||
->groupBy( 'OFF.other_revenue' );
|
->groupBy( 'OFF.other_revenue' );
|
||||||
|
|
||||||
if( $archive == 'F') $projects = $projects->where('projects.archive', '=', 'F');
|
if ( $archive == 'F' ) $projects = $projects->where( 'projects.archive', '=', 'F' );
|
||||||
|
|
||||||
$projects = $projects->get();
|
$projects = $projects->get();
|
||||||
|
|
||||||
@@ -172,6 +172,11 @@ class Project extends BaseModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $projectID;
|
return $projectID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function syncOffername( $offer )
|
||||||
|
{
|
||||||
|
self::whereId( $offer->project_id )
|
||||||
|
->update( ['projectname' => $offer->offername] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -63,6 +63,19 @@ class User extends BaseModel {
|
|||||||
return $usersWithProjects;
|
return $usersWithProjects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getUserActiveProjects( $userID )
|
||||||
|
{
|
||||||
|
$usersActiveProjects =
|
||||||
|
User::selectRaw( "PRJ.id AS projectID, projectname, projectnumber, CONCAT(projectnumber, '-', projectname) AS projectFull" )
|
||||||
|
->join( 'projectemployees AS PRE', 'PRE.user_id', '=', 'users.id' )
|
||||||
|
->join( 'projects AS PRJ', 'PRJ.id', '=', 'PRE.project_id' )
|
||||||
|
->where( 'PRJ.archive', '=', 'F' )
|
||||||
|
->where( 'users.id', '=', $userID )
|
||||||
|
->get();
|
||||||
|
|
||||||
|
return $usersActiveProjects;
|
||||||
|
}
|
||||||
|
|
||||||
public static function checkUsername( $username )
|
public static function checkUsername( $username )
|
||||||
{
|
{
|
||||||
$username = strtoupper( $username );
|
$username = strtoupper( $username );
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<div class="panel panel-bordered panel-primary panel-line">
|
<div class="panel panel-bordered panel-primary panel-line">
|
||||||
<div class="panel-heading panel-heading-project">
|
<div class="panel-heading panel-heading-project">
|
||||||
<h3 class="">
|
<h3 class="">
|
||||||
Reserveringen (incl. btw)
|
budget onderaannemers (incl. btw)
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body panel-body-project">
|
<div class="panel-body panel-body-project">
|
||||||
|
|||||||
@@ -28,87 +28,61 @@
|
|||||||
<table class="table table-sm">
|
<table class="table table-sm">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="table-tealish-header">medewerker</th>
|
<th class="table-tealish-header" width="15%">datum</th>
|
||||||
<th class="table-tealish-header">datum</th>
|
<th class="table-tealish-header" width="35%">soort uren</th>
|
||||||
<th class="table-tealish-header">soort uren</th>
|
<th class="table-tealish-header" width="35%">project</th>
|
||||||
<th class="table-tealish-header">project</th>
|
<th class="table-tealish-header" width="10%" style="min-width:100px;">uren</th>
|
||||||
<th class="table-tealish-header" style="min-width:100px;">uren</th>
|
<th class="table-tealish-header" width="5%"> </th>
|
||||||
<th class="table-tealish-header"> </th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody data-bind="foreach:employeehours">
|
<tbody data-bind="foreach:employeehours">
|
||||||
<tr>
|
<tr>
|
||||||
<td data-bind="css:{'red-line': id() == 0}">
|
<td data-bind="css:{'red-line': dirty}">
|
||||||
<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(),
|
|
||||||
enable: ! $root.selectedEmployeeID,
|
|
||||||
event:{change:$root.changeEmployee}"></select>
|
|
||||||
</td>
|
|
||||||
<td data-bind="css:{'red-line': id() == 0}">
|
|
||||||
<span data-bind="text:hourdate, visible:! inEdit()"></span>
|
|
||||||
<input class="form-control form-control-sm"
|
<input class="form-control form-control-sm"
|
||||||
data-bind="datepicker:{dateFormat: 'dd-mm-yy' },
|
data-bind="datepicker:{dateFormat: 'dd-mm-yy' },
|
||||||
value:hourdate, visible:inEdit(),
|
value:hourdate,
|
||||||
event:{change:$root.saveEmployeehour}"
|
event:{change:$root.saveEmployeehour}"
|
||||||
</td>
|
</td>
|
||||||
<td data-bind="css:{'red-line': id() == 0}">
|
<td data-bind="css:{'red-line': dirty}">
|
||||||
<span data-bind="text:dbo.helpers.findArrayElement('id', 'description', hourtype_id(), $root.hourtypes()),
|
|
||||||
visible: ! inEdit()"></span>
|
|
||||||
<select class="form-control form-control-sm"
|
<select class="form-control form-control-sm"
|
||||||
data-bind="options:$root.hourtypes,
|
data-bind="options:$root.hourtypes,
|
||||||
optionsText:'description',
|
optionsText:'description',
|
||||||
optionsValue:'id',
|
optionsValue:'id',
|
||||||
value:hourtype_id,
|
value:hourtype_id,
|
||||||
optionsCaptiuon:'selecteer...',
|
optionsCaption:'selecteer...',
|
||||||
visible:inEdit(),
|
|
||||||
event:{change:$root.saveEmployeehours}"></select>
|
event:{change:$root.saveEmployeehours}"></select>
|
||||||
</td>
|
</td>
|
||||||
<td data-bind="css:{'red-line': id() == 0}">
|
<td data-bind="css:{'red-line': dirty}">
|
||||||
<!-- ko if: hourType() == 'PROJECTS' -->
|
<!-- 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"
|
<select class="form-control form-control-sm"
|
||||||
data-bind="options:projects,
|
data-bind="options:$root.projects,
|
||||||
optionsText:'projectname',
|
optionsText:'projectFull',
|
||||||
optionsValue:'projectID',
|
optionsValue:'projectID',
|
||||||
value:projectID,
|
value:projectID,
|
||||||
optionsCaption:'selecteer...',
|
optionsCaption:'selecteer...',
|
||||||
visible:inEdit(),
|
|
||||||
event:{change:$root.saveEmployeehours}"></select>
|
event:{change:$root.saveEmployeehours}"></select>
|
||||||
<!-- /ko -->
|
<!-- /ko -->
|
||||||
<!-- ko if: hourType() == 'OFFERS' -->
|
<!-- ko if: hourType() == 'OFFERS' -->
|
||||||
<span data-bind="text:dbo.helpers.findArrayElement('id', 'offername', projectID(), $root.offersWithoutProject()),
|
|
||||||
visible: ! inEdit()"></span>
|
|
||||||
<select class="form-control form-control-sm"
|
<select class="form-control form-control-sm"
|
||||||
data-bind="options:$root.offersWithoutProject,
|
data-bind="options:$root.offersWithoutProject,
|
||||||
optionsText:'offername',
|
optionsText:'offername',
|
||||||
optionsValue:'id',
|
optionsValue:'id',
|
||||||
value:projectID,
|
value:projectID,
|
||||||
optionsCaption:'selecteer...',
|
optionsCaption:'selecteer...',
|
||||||
visible:inEdit(),
|
|
||||||
event:{change:$root.saveEmployeehours}"></select>
|
event:{change:$root.saveEmployeehours}"></select>
|
||||||
<!-- /ko -->
|
<!-- /ko -->
|
||||||
</td>
|
</td>
|
||||||
<td class="align-right" data-bind="css:{'red-line': id() == 0}">
|
<td class="align-right" data-bind="css:{'red-line': dirty}">
|
||||||
<span data-bind=" visible: ! inEdit()">
|
<input type="number"
|
||||||
<span data-bind="text:hours"></span>
|
|
||||||
uur
|
|
||||||
</span>
|
|
||||||
<input type="text"
|
|
||||||
class="form-control form-control-sm align-right"
|
class="form-control form-control-sm align-right"
|
||||||
paceholder="uren"
|
paceholder="uren"
|
||||||
data-bind="textInput:hours, visible:inEdit,
|
data-bind="textInput:hours,
|
||||||
event:{change:$root.saveEmployeehours,keyup:$root.validateNumber.bind($data, 'hours')}"/>
|
enable:canFillInHours,
|
||||||
|
event:{keyup:$root.saveDelayedEmployeehours,
|
||||||
|
change: $root.saveDelayedEmployeehours}"/>
|
||||||
</td>
|
</td>
|
||||||
<td data-bind="css:{'red-line': id() == 0}">
|
<td data-bind="css:{'red-line': dirty}">
|
||||||
<i class="icon fa-edit pointer" title="wijzig" data-bind="click:$root.editEmployeehour"></i>
|
<!-- <i class="icon fa-edit pointer" title="wijzig" data-bind="click:$root.editEmployeehour"></i>-->
|
||||||
<i class="icon fa-trash redish pointer" title="verwijder"
|
<i class="icon fa-trash redish pointer" title="verwijder"
|
||||||
data-bind="click:$root.removeEmployeehour"></i>
|
data-bind="click:$root.removeEmployeehour"></i>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
<span data-bind="text:acceptance_chance"></span> %
|
<span data-bind="text:acceptance_chance"></span> %
|
||||||
</td>
|
</td>
|
||||||
<td data-bind="click:$root.selectOffer" class="pointer align-right">
|
<td data-bind="click:$root.selectOffer" class="pointer align-right">
|
||||||
€ <span data-bind="text:Math.round((acceptance_chance * own_revenue) / 100)"></span>
|
€ <span data-bind="text:chanceOwnRevenue"></span>
|
||||||
</td>
|
</td>
|
||||||
<!-- <td data-bind="click:$root.selectOffer" class="pointer">-->
|
<!-- <td data-bind="click:$root.selectOffer" class="pointer">-->
|
||||||
<!-- <span data-bind="text:accepteddate"></span>-->
|
<!-- <span data-bind="text:accepteddate"></span>-->
|
||||||
@@ -78,6 +78,19 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<th colspan="4" class="align-right table-tealish-header">
|
||||||
|
Totaal
|
||||||
|
</th>
|
||||||
|
<th class="align-right table-tealish-header">
|
||||||
|
€ <span data-bind="text:totalOwnRevenue"></span>
|
||||||
|
</th>
|
||||||
|
<th class=" table-tealish-header"> </th>
|
||||||
|
<th class="align-right table-tealish-header">
|
||||||
|
€ <span data-bind="text:totalChanceOwnRevenue"></span>
|
||||||
|
</th>
|
||||||
|
<th class=" table-tealish-header"> </th>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="">
|
<td colspan="5" class="">
|
||||||
<button class="btn btn-primary btn-round btn-sm" data-bind="click:newOffer">
|
<button class="btn btn-primary btn-round btn-sm" data-bind="click:newOffer">
|
||||||
|
|||||||
@@ -77,6 +77,25 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
<tfoot>
|
<tfoot>
|
||||||
|
<tr>
|
||||||
|
<th colspan="4" class="align-right table-tealish-header">
|
||||||
|
Totaal
|
||||||
|
</th>
|
||||||
|
<th class="align-right table-tealish-header">
|
||||||
|
€ <span data-bind="text:totalOwnRevenue"></span>
|
||||||
|
</th>
|
||||||
|
<th class="align-right table-tealish-header">
|
||||||
|
€ <span data-bind="text:totalOtherrevenue"></span>
|
||||||
|
</th>
|
||||||
|
<th class="align-right table-tealish-header">
|
||||||
|
€ <span data-bind="text:totalCosts"></span>
|
||||||
|
</th>
|
||||||
|
<th class="align-right table-tealish-header">
|
||||||
|
€ <span data-bind="text:total"></span>
|
||||||
|
</th>
|
||||||
|
<th class="align-right table-tealish-header"></th>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="5" class="">
|
<td colspan="5" class="">
|
||||||
<!-- <button class="btn btn-primary btn-round btn-sm" data-bind="click:newProject">-->
|
<!-- <button class="btn btn-primary btn-round btn-sm" data-bind="click:newProject">-->
|
||||||
|
|||||||
@@ -10,13 +10,13 @@
|
|||||||
<th width="3%"> </th>
|
<th width="3%"> </th>
|
||||||
<th width="17%">project</th>
|
<th width="17%">project</th>
|
||||||
<th width="10%" class="align-right">Kosten derden</th>
|
<th width="10%" class="align-right">Kosten derden</th>
|
||||||
<th width="10%" class="align-right">gefactureerd</th>
|
<th width="10%" class="align-right">factuur INK</th>
|
||||||
<th width="10%" class="align-right">gereserveerd</th>
|
<th width="10%" class="align-right">budget onderaannemers</th>
|
||||||
<th width="10%" class="align-right">betaald</th>
|
<th width="10%" class="align-right">betaald</th>
|
||||||
<th width="10%" class="align-right">saldo te<br />betalen</th>
|
<th width="10%" class="align-right">saldo te<br />betalen</th>
|
||||||
<th width="10%" class="align-right">betaald via<br />reserveringen</th>
|
<th width="10%" class="align-right">betaald via<br />reserveringen</th>
|
||||||
<th width="10%" class="align-right">saldo reservering</th>
|
<th width="10%" class="align-right">saldo reservering</th>
|
||||||
<th width="10%" class="align-right">saldo te<br />factureren</th>
|
<th width="10%" class="align-right">saldo facturen INK</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<!-- ko foreach:projects -->
|
<!-- ko foreach:projects -->
|
||||||
|
|||||||
@@ -35,6 +35,13 @@ dbo.userDataService = {
|
|||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getUserActiveProjects: function ( userID, callback ) {
|
||||||
|
$.getJSON( 'index.php/beheer/usersController/getUserActiveProjects/' + userID )
|
||||||
|
.done( function ( data ) {
|
||||||
|
callback( data );
|
||||||
|
} );
|
||||||
|
},
|
||||||
|
|
||||||
getUniqueProjectEmployees: function ( callback ) {
|
getUniqueProjectEmployees: function ( callback ) {
|
||||||
$.post( 'index.php/beheer/usersController/getUniqueprojectEmployees', 'json' )
|
$.post( 'index.php/beheer/usersController/getUniqueprojectEmployees', 'json' )
|
||||||
.done( function ( data ) {
|
.done( function ( data ) {
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
dbo.employeehoursInit = function () {
|
dbo.employeehoursInit = function () {
|
||||||
|
|
||||||
|
var timeout;
|
||||||
|
|
||||||
if ( dbo.employeehoursModel !== undefined ) {
|
if ( dbo.employeehoursModel !== undefined ) {
|
||||||
dbo.employeehoursModel.init();
|
dbo.employeehoursModel.init();
|
||||||
} else {
|
} else {
|
||||||
@@ -24,6 +26,7 @@ dbo.employeehoursInit = function () {
|
|||||||
busy : false,
|
busy : false,
|
||||||
selectedEmployeeID : ko.observable(),
|
selectedEmployeeID : ko.observable(),
|
||||||
offersWithoutProject: ko.observableArray( [] ),
|
offersWithoutProject: ko.observableArray( [] ),
|
||||||
|
projects : ko.observableArray( [] ),
|
||||||
|
|
||||||
init: function () {
|
init: function () {
|
||||||
var vm = dbo.employeehoursModel;
|
var vm = dbo.employeehoursModel;
|
||||||
@@ -36,17 +39,15 @@ dbo.employeehoursInit = function () {
|
|||||||
vm.selectedMonth( dbo.currentMonth );
|
vm.selectedMonth( dbo.currentMonth );
|
||||||
vm.selectedYear( dbo.currentYear );
|
vm.selectedYear( dbo.currentYear );
|
||||||
|
|
||||||
|
vm.selectedEmployeeID( dbo.currentUser.id );
|
||||||
|
|
||||||
|
dbo.userDataService.getAllUsers( 'F', function ( data ) {
|
||||||
|
vm.employees( data );
|
||||||
|
|
||||||
dbo.employeehoursDataService.getHourtypes( function ( data ) {
|
dbo.employeehoursDataService.getHourtypes( function ( data ) {
|
||||||
vm.hourtypes( data );
|
vm.hourtypes( data );
|
||||||
dbo.offerDataService.getOffersWithoutProject( function ( data ) {
|
dbo.offerDataService.getOffersWithoutProject( function ( data ) {
|
||||||
vm.offersWithoutProject( data );
|
vm.offersWithoutProject( data );
|
||||||
dbo.userDataService.getUserWithprojects( function ( data ) {
|
|
||||||
vm.employees.removeAll();
|
|
||||||
_.each( data, function ( p ) {
|
|
||||||
vm.employees.push( new vm.Employee( p ) );
|
|
||||||
} );
|
|
||||||
vm.selectedEmployeeID( dbo.currentUser.id )
|
|
||||||
|
|
||||||
vm.busy = false;
|
vm.busy = false;
|
||||||
vm.refreshEmployeehours();
|
vm.refreshEmployeehours();
|
||||||
} );
|
} );
|
||||||
@@ -73,26 +74,42 @@ dbo.employeehoursInit = function () {
|
|||||||
hourtype_id: employeeHour ? employeeHour.hourtype_id() : 9,
|
hourtype_id: employeeHour ? employeeHour.hourtype_id() : 9,
|
||||||
project_id : employeeHour ? employeeHour.projectID() : null,
|
project_id : employeeHour ? employeeHour.projectID() : null,
|
||||||
hours : 0,
|
hours : 0,
|
||||||
inEdit : true
|
inEdit : true,
|
||||||
|
dirty : true
|
||||||
};
|
};
|
||||||
|
|
||||||
vm.employeehours.push( new vm.Employeehour( employeehour ) );
|
vm.employeehours.push( new vm.Employeehour( employeehour ) );
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleArchive: function () {
|
toggleArchive: function () {
|
||||||
var vm = dbo.employeeemployeehoursModel;
|
var vm = dbo.employeehoursModel;
|
||||||
|
|
||||||
vm.archive( !vm.archive() );
|
vm.archive( !vm.archive() );
|
||||||
|
|
||||||
vm.refreshHours();
|
vm.refreshHours();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
saveDelayedEmployeehours: function () {
|
||||||
|
var vm = dbo.employeehoursModel;
|
||||||
|
var self = this;
|
||||||
|
self.dirty( true );
|
||||||
|
if ( timeout ) {
|
||||||
|
clearTimeout( timeout );
|
||||||
|
timeout = null;
|
||||||
|
}
|
||||||
|
timeout = setTimeout( function () {
|
||||||
|
vm.saveEmployeehours( self );
|
||||||
|
}, 300 );
|
||||||
|
},
|
||||||
|
|
||||||
saveEmployeehours: function ( self = false ) {
|
saveEmployeehours: function ( self = false ) {
|
||||||
|
self.dirty( true );
|
||||||
if ( !self ) self = this;
|
if ( !self ) self = this;
|
||||||
|
|
||||||
if ( !self.employee_id() ) return;
|
if ( !self.employee_id() ) return;
|
||||||
if ( !self.hourtype_id() ) return;
|
if ( !self.hourtype_id() ) return;
|
||||||
if ( !self.hourdate() ) return;
|
if ( !self.hourdate() ) return;
|
||||||
|
if ( self.hours() <= 0 ) return;
|
||||||
if ( self.hourType() == 'PROJECTS' && !self.projectID() ) return;
|
if ( self.hourType() == 'PROJECTS' && !self.projectID() ) return;
|
||||||
if ( self.hourType() == 'OFFERS' && !self.projectID() ) return;
|
if ( self.hourType() == 'OFFERS' && !self.projectID() ) return;
|
||||||
|
|
||||||
@@ -108,6 +125,7 @@ dbo.employeehoursInit = function () {
|
|||||||
|
|
||||||
dbo.employeehoursDataService.saveEmployeehour( submitDATA, function ( data ) {
|
dbo.employeehoursDataService.saveEmployeehour( submitDATA, function ( data ) {
|
||||||
self.id( data.employeehourID );
|
self.id( data.employeehourID );
|
||||||
|
self.dirty( false );
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -156,7 +174,7 @@ dbo.employeehoursInit = function () {
|
|||||||
refreshEmployeehours: function () {
|
refreshEmployeehours: function () {
|
||||||
var vm = dbo.employeehoursModel;
|
var vm = dbo.employeehoursModel;
|
||||||
|
|
||||||
if( vm.busy == true ) return;
|
if ( vm.busy == true ) return;
|
||||||
|
|
||||||
var employeeID = vm.selectedEmployeeID() || 0;
|
var employeeID = vm.selectedEmployeeID() || 0;
|
||||||
|
|
||||||
@@ -195,6 +213,7 @@ dbo.employeehoursInit = function () {
|
|||||||
this.type = 'PROJECT';
|
this.type = 'PROJECT';
|
||||||
this.projectID = data.project.id;
|
this.projectID = data.project.id;
|
||||||
this.project = data.project.projectnumber + ' - ' + data.project.projectname;
|
this.project = data.project.projectnumber + ' - ' + data.project.projectname;
|
||||||
|
this.projectname = data.project.projectnumber + ' - ' + data.project.projectname;
|
||||||
},
|
},
|
||||||
|
|
||||||
Offer: function ( data, employeeID ) {
|
Offer: function ( data, employeeID ) {
|
||||||
@@ -215,24 +234,19 @@ dbo.employeehoursInit = function () {
|
|||||||
self.hours = ko.observable( data.hours );
|
self.hours = ko.observable( data.hours );
|
||||||
self.inEdit = ko.observable( data.inEdit || false );
|
self.inEdit = ko.observable( data.inEdit || false );
|
||||||
self.projectID = ko.observable( data.project_id );
|
self.projectID = ko.observable( data.project_id );
|
||||||
|
self.dirty = ko.observable( data.dirty || false );
|
||||||
self.hourType = ko.pureComputed( function () {
|
self.hourType = ko.pureComputed( function () {
|
||||||
return dbo.helpers.findArrayElement( 'id', 'key', this.hourtype_id(), vm.hourtypes() );
|
return dbo.helpers.findArrayElement( 'id', 'key', this.hourtype_id(), vm.hourtypes() );
|
||||||
}, this );
|
}, this );
|
||||||
|
self.canFillInHours = ko.pureComputed( function () {
|
||||||
|
if ( self.hourType() == 'PROJECTS' || self.hourType() == 'OFFERS' ) {
|
||||||
|
if ( !self.projectID() ) {
|
||||||
|
self.hours( 0 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
vm.setEmployeeProjects( self );
|
|
||||||
},
|
|
||||||
|
|
||||||
setEmployeeProjects: function ( self ) {
|
return true;
|
||||||
var vm = dbo.employeehoursModel;
|
|
||||||
|
|
||||||
var employeeProjects =
|
|
||||||
dbo.helpers.findArrayElement( 'id', 'projecten', self.employee_id(), vm.employees() );
|
|
||||||
self.projects = ko.observableArray( [] );
|
|
||||||
_.each( employeeProjects, function ( p ) {
|
|
||||||
self.projects.push( {
|
|
||||||
projectID : p.projectID,
|
|
||||||
projectname: p.project
|
|
||||||
} );
|
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -240,5 +254,11 @@ dbo.employeehoursInit = function () {
|
|||||||
dbo.employeehoursModel.init();
|
dbo.employeehoursModel.init();
|
||||||
|
|
||||||
ko.applyBindings( dbo.employeehoursModel, document.getElementById( 'EMPLOYEEHOURS' ) );
|
ko.applyBindings( dbo.employeehoursModel, document.getElementById( 'EMPLOYEEHOURS' ) );
|
||||||
|
|
||||||
|
dbo.employeehoursModel.selectedEmployeeID.subscribe( function () {
|
||||||
|
dbo.userDataService.getUserActiveProjects( dbo.currentUser.id, function ( data ) {
|
||||||
|
dbo.employeehoursModel.projects( data );
|
||||||
|
} );
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,11 +20,13 @@ dbo.offersInit = function () {
|
|||||||
archive : ko.observable( false ),
|
archive : ko.observable( false ),
|
||||||
comments : ko.observableArray( [] ),
|
comments : ko.observableArray( [] ),
|
||||||
documents : ko.observableArray( [] ),
|
documents : ko.observableArray( [] ),
|
||||||
selectedRowID: ko.observable(),
|
selectedRowID : ko.observable(),
|
||||||
projectID : 0,
|
projectID : 0,
|
||||||
search : ko.observable(''),
|
search : ko.observable( '' ),
|
||||||
order : ko.observable('offernumber'),
|
order : ko.observable( 'offernumber' ),
|
||||||
direction : ko.observable(),
|
direction : ko.observable(),
|
||||||
|
totalOwnRevenue : ko.observable( 0 ),
|
||||||
|
totalChanceOwnRevenue: ko.observable( 0 ),
|
||||||
|
|
||||||
init: function () {
|
init: function () {
|
||||||
var service = dbo.offersService;
|
var service = dbo.offersService;
|
||||||
@@ -44,10 +46,10 @@ dbo.offersInit = function () {
|
|||||||
}, 700 );
|
}, 700 );
|
||||||
},
|
},
|
||||||
|
|
||||||
directionOrderOffers : function(field){
|
directionOrderOffers: function ( field ) {
|
||||||
var service = dbo.offersService;
|
var service = dbo.offersService;
|
||||||
|
|
||||||
service.directionOrderOffers(field);
|
service.directionOrderOffers( field );
|
||||||
},
|
},
|
||||||
|
|
||||||
newOffer: function () {
|
newOffer: function () {
|
||||||
|
|||||||
@@ -17,11 +17,16 @@ dbo.projectsInit = function () {
|
|||||||
projects : ko.observableArray( [] ),
|
projects : ko.observableArray( [] ),
|
||||||
project : ko.observable(),
|
project : ko.observable(),
|
||||||
archive : ko.observable( false ),
|
archive : ko.observable( false ),
|
||||||
selectedRowID: ko.observable(),
|
selectedRowID : ko.observable(),
|
||||||
busy : false,
|
busy : false,
|
||||||
search : ko.observable(),
|
search : ko.observable(),
|
||||||
order : ko.observable( 'projectnumber' ),
|
order : ko.observable( 'projectnumber' ),
|
||||||
direction : ko.observable(),
|
direction : ko.observable(),
|
||||||
|
totalOwnRevenue : ko.observable( 0 ),
|
||||||
|
totalOtherrevenue: ko.observable( 0 ),
|
||||||
|
totalCosts : ko.observable( 0 ),
|
||||||
|
total : ko.observable( 0 ),
|
||||||
|
|
||||||
|
|
||||||
init: function () {
|
init: function () {
|
||||||
var vm = dbo.projectsModel;
|
var vm = dbo.projectsModel;
|
||||||
@@ -140,6 +145,10 @@ dbo.projectsInit = function () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dbo.projectDataService.getAllProjects( projectsObject, function ( data ) {
|
dbo.projectDataService.getAllProjects( projectsObject, function ( data ) {
|
||||||
|
vm.totalOwnRevenue(0);
|
||||||
|
vm.totalOtherrevenue(0);
|
||||||
|
vm.totalCosts(0);
|
||||||
|
vm.total(0);
|
||||||
vm.projects.removeAll();
|
vm.projects.removeAll();
|
||||||
$.each( data, function ( i, p ) {
|
$.each( data, function ( i, p ) {
|
||||||
vm.projects.push( new vm.Project( p ) );
|
vm.projects.push( new vm.Project( p ) );
|
||||||
@@ -164,6 +173,13 @@ dbo.projectsInit = function () {
|
|||||||
self.totalOtherrevenue = Number( data.offer.other_revenue );
|
self.totalOtherrevenue = Number( data.offer.other_revenue );
|
||||||
self.costs = Number( data.offer.costs );
|
self.costs = Number( data.offer.costs );
|
||||||
self.total = Number( data.offer.own_revenue ) + Number( data.offer.other_revenue ) + Number( data.offer.costs );
|
self.total = Number( data.offer.own_revenue ) + Number( data.offer.other_revenue ) + Number( data.offer.costs );
|
||||||
|
|
||||||
|
vm.totalOwnRevenue( vm.totalOwnRevenue() + self.totalOwnrevenue )
|
||||||
|
vm.totalOtherrevenue( vm.totalOtherrevenue() + self.totalOtherrevenue )
|
||||||
|
vm.totalCosts( vm.totalCosts() + self.costs )
|
||||||
|
vm.total( Math.round(vm.total() + self.total) )
|
||||||
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
Revenue: function ( data ) {
|
Revenue: function ( data ) {
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ dbo.offersService = {
|
|||||||
|
|
||||||
vm: null,
|
vm: null,
|
||||||
|
|
||||||
newOffer: function (projectID=false, customerID=false) {
|
newOffer: function ( projectID = false, customerID = false ) {
|
||||||
var service = dbo.offersService;
|
var service = dbo.offersService;
|
||||||
|
|
||||||
dbo.editOfferModal.newEditOffer( false, projectID, customerID, true, function () {
|
dbo.editOfferModal.newEditOffer( false, projectID, customerID, true, function () {
|
||||||
@@ -27,7 +27,7 @@ dbo.offersService = {
|
|||||||
service.refreshOffers();
|
service.refreshOffers();
|
||||||
},
|
},
|
||||||
|
|
||||||
editOffer: function ( that, projectID=false, custormerID=false, hasProject=false ) {
|
editOffer: function ( that, projectID = false, custormerID = false, hasProject = false ) {
|
||||||
var offer = that;
|
var offer = that;
|
||||||
|
|
||||||
dbo.editOfferModal.newEditOffer( offer, projectID, custormerID, hasProject, function () {
|
dbo.editOfferModal.newEditOffer( offer, projectID, custormerID, hasProject, function () {
|
||||||
@@ -108,12 +108,15 @@ dbo.offersService = {
|
|||||||
dbo.offerDataService.getAllOffers( offersObject, function ( data ) {
|
dbo.offerDataService.getAllOffers( offersObject, function ( data ) {
|
||||||
vm.offers.removeAll();
|
vm.offers.removeAll();
|
||||||
$.each( data, function ( i, p ) {
|
$.each( data, function ( i, p ) {
|
||||||
|
vm.totalOwnRevenue( 0 );
|
||||||
|
vm.totalChanceOwnRevenue( 0 );
|
||||||
vm.offers.push( new self.Offer( p ) );
|
vm.offers.push( new self.Offer( p ) );
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
},
|
},
|
||||||
|
|
||||||
Offer: function ( data ) {
|
Offer: function ( data ) {
|
||||||
|
var vm = dbo.offersModel;
|
||||||
this.id = data.id;
|
this.id = data.id;
|
||||||
this.offernumber = data.offernumber;
|
this.offernumber = data.offernumber;
|
||||||
this.offername = data.offername;
|
this.offername = data.offername;
|
||||||
@@ -127,9 +130,14 @@ dbo.offersService = {
|
|||||||
this.rejectdate = data.rejectdate ? dbo.helpers.mysql2date( data.rejectdate ) : null;
|
this.rejectdate = data.rejectdate ? dbo.helpers.mysql2date( data.rejectdate ) : null;
|
||||||
this.accepteddate = data.accepteddate ? dbo.helpers.mysql2date( data.accepteddate ) : null;
|
this.accepteddate = data.accepteddate ? dbo.helpers.mysql2date( data.accepteddate ) : null;
|
||||||
this.acceptance_chance = data.acceptance_chance ? data.acceptance_chance : 0;
|
this.acceptance_chance = data.acceptance_chance ? data.acceptance_chance : 0;
|
||||||
this.own_revenue = data.own_revenue;
|
|
||||||
this.other_revenue = data.other_revenue;
|
this.other_revenue = data.other_revenue;
|
||||||
|
this.own_revenue = data.own_revenue;
|
||||||
|
this.chanceOwnRevenue = Math.round( (Number( data.own_revenue ) * data.acceptance_chance) / 100 );
|
||||||
this.costs = data.costs;
|
this.costs = data.costs;
|
||||||
this.archive = data.archive;
|
this.archive = data.archive;
|
||||||
|
|
||||||
|
vm.totalOwnRevenue( Number( vm.totalOwnRevenue() ) + Number( this.own_revenue ) );
|
||||||
|
vm.totalChanceOwnRevenue( Number( vm.totalChanceOwnRevenue() ) + Number( this.chanceOwnRevenue ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Reference in New Issue
Block a user