Diversen nav mail Peter
This commit is contained in:
@@ -44,4 +44,17 @@ class vatController extends MY_Controller {
|
||||
$vatrate = $this->input->post( 'vatrate' );
|
||||
Vat::whereId( $vatID )->update( ['vatrate' => $vatrate] );
|
||||
}
|
||||
|
||||
public function removeVat( $vatID )
|
||||
{
|
||||
$removeVat = new RemoveVat($vatID);
|
||||
|
||||
$allowRemove = $removeVat->getRemoveAllowed();
|
||||
|
||||
if( $allowRemove === FALSE ) return $this->json( ['result'=>FALSE]);
|
||||
|
||||
Vat::whereId($vatID)->delete();
|
||||
|
||||
$this->json( ['result'=>TRUE]);
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ class MY_Controller extends CI_Controller {
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->version = '0.02.00';
|
||||
$this->version = '0.02.01';
|
||||
|
||||
$this->load->library( 'beheer/session/RetrieveUserSession' );
|
||||
|
||||
@@ -25,11 +25,25 @@ class MY_Controller extends CI_Controller {
|
||||
|
||||
private function handle()
|
||||
{
|
||||
$this->setSecureSite();
|
||||
|
||||
$this->retrieveusersession->handle();
|
||||
|
||||
$this->user = $this->User_model->get( USERID );
|
||||
}
|
||||
|
||||
public function setSecureSite()
|
||||
{
|
||||
if ( getenv( 'ENVIRONMENT' ) != 'production' ) return;
|
||||
|
||||
if ( ! isset( $_SERVER["HTTPS"] ) || $_SERVER["HTTPS"] != "on" )
|
||||
{
|
||||
header( "Location: " . getenv( 'APP_URL' ) );
|
||||
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
function clean_input( $post )
|
||||
{
|
||||
$value = $this->input->input_stream( $post, TRUE );
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 10/06/2018
|
||||
* Time: 17:06
|
||||
*/
|
||||
|
||||
class RemoveVat {
|
||||
|
||||
private $vatID;
|
||||
private $projects;
|
||||
private $invoices;
|
||||
private $removeAllowed;
|
||||
|
||||
public function __construct( $vatID )
|
||||
{
|
||||
$this->setVatID( $vatID );
|
||||
|
||||
$this->handle();
|
||||
}
|
||||
|
||||
public function getRemoveAllowed()
|
||||
{
|
||||
return $this->removeAllowed;
|
||||
}
|
||||
|
||||
private function setVatID( $vatID )
|
||||
{
|
||||
$this->vatID = $vatID;
|
||||
}
|
||||
|
||||
private function handle()
|
||||
{
|
||||
$this->setProject();
|
||||
|
||||
$this->setInvoices();
|
||||
|
||||
$this->setRemoveAllowed();
|
||||
}
|
||||
|
||||
private function setProject()
|
||||
{
|
||||
$projects = Project::whereVatId( $this->vatID );
|
||||
|
||||
$this->projects = $projects->count() == 0 ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
private function setInvoices()
|
||||
{
|
||||
$invoices = Invoice::whereVatId( $this->vatID );
|
||||
|
||||
$this->invoices = $invoices->count() == 0 ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
private function setRemoveAllowed()
|
||||
{
|
||||
if ( $this->projects === FALSE ) return $this->removeAllowed = FALSE;
|
||||
|
||||
if ( $this->invoices === FALSE ) return $this->removeAllowed = FALSE;
|
||||
|
||||
$this->removeAllowed = TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -12,16 +12,20 @@
|
||||
<tr>
|
||||
<td>
|
||||
<div class="percentage-sign-holder">
|
||||
<!-- ko if:inEdit() -->
|
||||
<input type="text"
|
||||
class="form-control percentage-input"
|
||||
data-bind="textInput:vatrate,
|
||||
event:{keyup:$root.validateNumber.bind($data, 'vatrate')}">
|
||||
<span class="percentage-sign">%</span>
|
||||
<!-- /ko -->
|
||||
<!-- ko if: !inEdit() -->
|
||||
<span data-bind="text:vatrate"></span>%
|
||||
<!-- /ko -->
|
||||
</div>
|
||||
</td>
|
||||
<td width="60px">
|
||||
<i class="icon fa-edit" data-bind="click:$root.toggleEdit"></i>
|
||||
<i class="icon fa-trash redish" data-bind="$root.removeVat"></i>
|
||||
<i class="icon fa-edit pointer" data-bind="click:$root.toggleEdit"></i>
|
||||
<i class="icon fa-trash redish pointer" data-bind="click:$root.removeVat"></i>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@@ -23,6 +23,13 @@ dbo.vatDataService = {
|
||||
|
||||
saveVat: function ( vatID, vatrate ) {
|
||||
$.post( 'index.php/beheer/vatController/saveVat/' + vatID, {vatrate: vatrate} );
|
||||
},
|
||||
|
||||
removeVat: function ( vatID, callback ) {
|
||||
$.getJSON( 'index.php/beheer/vatController/removeVat/' + vatID )
|
||||
.done( function (data) {
|
||||
callback(data);
|
||||
} );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,8 @@ dbo.vatInit = function () {
|
||||
|
||||
if ( dbo.vatModel !== undefined ) {
|
||||
|
||||
dbo.vatModel.refreshVat();
|
||||
|
||||
} else {
|
||||
|
||||
dbo.vatModel = {
|
||||
@@ -37,7 +39,7 @@ dbo.vatInit = function () {
|
||||
|
||||
_.each( data, function ( p ) {
|
||||
vm.vats.push( new vm.Vat( p ) );
|
||||
} )
|
||||
} );
|
||||
} );
|
||||
},
|
||||
|
||||
@@ -65,6 +67,24 @@ dbo.vatInit = function () {
|
||||
},
|
||||
|
||||
removeVat: function () {
|
||||
dbo.vatDataService.removeVat( this.id, function(data){
|
||||
if( data.result ){
|
||||
dbo.vatModel.refreshVat();
|
||||
|
||||
var message = 'BTW succesvol verwijderd';
|
||||
var modalClass = 'modal-success';
|
||||
}else{
|
||||
var message ='BTW is in gebruik en kan niet worden verwijderd';
|
||||
var modalClass= 'modal-danger';
|
||||
}
|
||||
tellMe( {
|
||||
title : 'verwijderen BTW',
|
||||
message : message,
|
||||
notify : false,
|
||||
modalClass: modalClass
|
||||
});
|
||||
} );
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ dbo.employeehoursInit = function () {
|
||||
hourdate : employeeHour ? employeeHour.hourdate() : null,
|
||||
hourtype_id: employeeHour ? employeeHour.hourtype_id() : 9,
|
||||
project_id : employeeHour ? employeeHour.projectID() : null,
|
||||
hours : employeeHour ? employeeHour.hours() : 0,
|
||||
hours : 0,
|
||||
inEdit : true
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user