fix for employeehours (remove) and refresh active offers / projects

This commit is contained in:
2019-04-13 10:39:58 +02:00
parent a71a7096d6
commit 0a891af5ec
6 changed files with 17 additions and 10 deletions
@@ -51,7 +51,7 @@ class EmployeeHoursController extends MY_Controller {
unset( $data['id'] ); unset( $data['id'] );
unset( $data['hourType'] ); unset( $data['hourType'] );
unset( $data['project_id'] ); unset( $data['project_id'] );
if( $hourType == 'OFFERS' ) $data['offer_id'] = $projectID; if ( $hourType == 'OFFERS' ) $data['offer_id'] = $projectID;
$data['hourdate'] = date2mysql( $data['hourdate'] ); $data['hourdate'] = date2mysql( $data['hourdate'] );
@@ -85,10 +85,18 @@ class EmployeeHoursController extends MY_Controller {
$this->json( ['employeehourID' => $employeehourID] ); $this->json( ['employeehourID' => $employeehourID] );
} }
public function removeEmployeehour( $employeehourID ) public function removeEmployeehour( $employeehourID, $hourType )
{ {
//TODO:check op delete //TODO:check op delete
Employeehour::whereId( $employeehourID )->delete(); if ( $hourType == 'OVERHEAD' )
{
Employeehour::whereId( $employeehourID )->delete();
}
else
{
Projecthour::whereId( $employeehourID )->delete();
}
$this->json( ['result' => TRUE] ); $this->json( ['result' => TRUE] );
} }
+1 -1
View File
@@ -16,7 +16,7 @@ class MY_Controller extends CI_Controller {
{ {
parent::__construct(); parent::__construct();
$this->version = '1.00.03'; $this->version = '1.00.04';
$this->load->library( 'beheer/session/RetrieveUserSession' ); $this->load->library( 'beheer/session/RetrieveUserSession' );
+1
View File
@@ -49,6 +49,7 @@ class Offer extends BaseModel {
$offersWithoutProject = Offer::orderBy('startdate') $offersWithoutProject = Offer::orderBy('startdate')
->whereNull('rejectdate') ->whereNull('rejectdate')
->whereNull('project_id') ->whereNull('project_id')
->whereArchive('F')
->get(); ->get();
return $offersWithoutProject; return $offersWithoutProject;
@@ -35,8 +35,8 @@ dbo.employeehoursDataService = {
} ); } );
}, },
removeEmployeehour: function ( employeehourID, callback ) { removeEmployeehour: function ( employeehourID, hourType, callback ) {
$.getJSON( 'index.php/projects/employeeHoursController/removeEmployeehour/' + employeehourID ) $.getJSON( 'index.php/projects/employeeHoursController/removeEmployeehour/' + employeehourID + '/' + hourType )
.done( function ( data ) { .done( function ( data ) {
callback( data ); callback( data );
} ) } )
-2
View File
@@ -48,8 +48,6 @@ $( function () {
vm[page]( true ); vm[page]( true );
var func = page.toLowerCase() + 'Init'; var func = page.toLowerCase() + 'Init';
console.log( func );
window.dbo[func](); window.dbo[func]();
}, },
@@ -9,7 +9,7 @@
dbo.employeehoursInit = function () { dbo.employeehoursInit = function () {
if ( dbo.employeehoursModel !== undefined ) { if ( dbo.employeehoursModel !== undefined ) {
dbo.employeehoursModel.refreshEmployeehours(); dbo.employeehoursModel.init();
} else { } else {
dbo.employeehoursModel = { dbo.employeehoursModel = {
@@ -138,7 +138,7 @@ dbo.employeehoursInit = function () {
modalClass: 'modal-warning' modalClass: 'modal-warning'
}, function ( response ) { }, function ( response ) {
if ( response ) { if ( response ) {
dbo.employeehoursDataService.removeEmployeehour( self.id(), function ( data ) { dbo.employeehoursDataService.removeEmployeehour( self.id(), self.hourType(), function ( data ) {
if ( data.result ) { if ( data.result ) {
vm.refreshEmployeehours(); vm.refreshEmployeehours();
} else { } else {